8 I have two separate git repos, each of which includes its own copy of the identical
9 eruby_util.rb script. I want to make sure that these stay consistent.
10 If I edit the master, so it's newer than the copies, this script automatically updates
11 the copies; this shouldn't cause data loss, since any overwritten version was presumably
12 committed to its own project's git repo. If a copy differs from the master and is newer,
13 it's an error. The script 101_reconcile_eruby_util.pl should not be in the git
14 repos, because it's only useful to me.
17 my $master = "/home/bcrowell/Documents/programming/eruby_util_for_books/eruby_util.rb";
20 "/home/bcrowell/Documents/writing/books/genrel/scripts/eruby_util.rb",
21 "/home/bcrowell/Documents/writing/books/sr/scripts/eruby_util.rb",
22 "/home/bcrowell/Documents/writing/books/fund/scripts/eruby_util.rb",
23 "/home/bcrowell/Documents/writing/books/physics/eruby_util.rb",
24 "/home/bcrowell/Documents/writing/books/poets/scripts/eruby_util.rb",
27 my $master_mod = last_modification_time
($master);
28 foreach my $copy(@copies) {
29 if (compare
($master,$copy) != 0) {
30 my $copy_mod = last_modification_time
($copy);
31 if ($copy_mod>$master_mod) {
32 die "error in 101_reconcile_eruby_util.pl:\nfile\n $copy\ndiffers from, and is newer than,\n $master\nInfo:\n $info\n";
35 print "101_reconcile_eruby_util.pl: overwriting\n $copy\nwith newer version from\n $master\n";
36 copy
($master,$copy); # This causes the copy to be newer than the master, but that won't trigger future alarms, because they're identical.
41 sub last_modification_time
{
43 return ((stat ($filename))[9]); # in seconds, since 1970