]> gitweb @ CieloNegro.org - sugar.git/commitdiff
Auto commit by The Sugar System.
authorPHO <pho@cielonegro.org>
Sun, 7 Dec 2008 12:27:13 +0000 (21:27 +0900)
committerPHO <pho@cielonegro.org>
Sun, 7 Dec 2008 12:27:13 +0000 (21:27 +0900)
GNUmakefile
tools/find-changed.pl
tools/install.pl [new file with mode: 0644]

index d79d0fa54ab601291dc13c541fa7f83d1a02e2db..ca56c8862d4bcd61b07a2c62a7cc21386a31926d 100644 (file)
@@ -13,5 +13,9 @@ commit:
        git add -A
        git commit -m 'Auto commit by The Sugar System.'
        git push
+       git log --stat --unified -1 --color
 
-.PHONY: lint
\ No newline at end of file
+install: lint
+       perl ./tools/list-files.pl | perl ./tools/install.pl
+
+.PHONY: lint update commit install
index 7f9e084b22bf1a21f3721575a98176b263323864..2183f5c448fa361009e34eb881e744f0128994d3 100644 (file)
@@ -8,6 +8,8 @@ use File::Spec;
 use File::Compare;
 
 sub main {
+    my $found_updated;
+
     while (defined(my $rel = <>)) {
         chomp $rel;
         my $saved = rel2saved($rel);
@@ -23,6 +25,10 @@ sub main {
             print "M $rel\n";
         }
     }
+
+    if ($found_updated) {
+        exit 1;
+    }
 }
 
 main();
diff --git a/tools/install.pl b/tools/install.pl
new file mode 100644 (file)
index 0000000..a515f4e
--- /dev/null
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use Smart::Comments;
+use lib 'tools';
+require 'utils.pl';
+use File::stat;
+use File::Spec;
+use File::Compare;
+use File::Copy;
+
+sub main {
+    while (defined(my $rel = <>)) {
+        chomp $rel;
+        my $saved = rel2saved($rel);
+        next if !-e $saved;
+
+        my $abs = File::Spec->rel2abs($rel, $ENV{HOME});
+
+        my $current_st = stat($abs);
+        my $saved_st   = stat($saved);
+
+        if ($current_st->mtime < $saved_st->mtime &&
+              compare($abs, $saved) != 0) {
+            print "Copying $saved to $abs...\n";
+            unlink $abs or die $!;
+            copy($saved, $abs) or die $!;
+        }
+    }
+}
+
+main();