Commit 18b51aa4 authored by Robert Ricci's avatar Robert Ricci

Set mtime on files for 'make class'

Set it to the last time the directory had a commit
parent a24842ed
...@@ -8,6 +8,7 @@ use strict; ...@@ -8,6 +8,7 @@ use strict;
sub transmogrify($); sub transmogrify($);
sub cleanup(@); sub cleanup(@);
sub setmtime($$);
my $CLASSDIR = "class"; my $CLASSDIR = "class";
...@@ -19,15 +20,20 @@ my @others = ("syllabus", "schedule"); ...@@ -19,15 +20,20 @@ my @others = ("syllabus", "schedule");
@lecturenotes = cleanup(@lecturenotes); @lecturenotes = cleanup(@lecturenotes);
foreach my $file (@handouts, @lecturenotes) { foreach my $file (@handouts, @lecturenotes) {
my $command = "cp $file $CLASSDIR/" . transmogrify($file); my $destfile = $CLASSDIR . "/" . transmogrify($file);
my $command = "cp $file $destfile";
print "$command\n"; print "$command\n";
system "$command"; system "$command";
setmtime($destfile,$file);
} }
foreach my $file (@others) { foreach my $file (@others) {
my $command = "cp $file/$file.pdf $CLASSDIR/$file.pdf"; my $sourcefile = $file . "/" . $file . ".pdf";
my $destfile = $CLASSDIR . "/" . $file . ".pdf";
my $command = "cp $sourcefile $destfile";
print "$command\n"; print "$command\n";
system "$command"; system "$command";
setmtime($destfile,$sourcefile);
} }
sub transmogrify($) { sub transmogrify($) {
...@@ -49,3 +55,15 @@ sub cleanup(@) { ...@@ -49,3 +55,15 @@ sub cleanup(@) {
@list = grep(!/template/,@list); @list = grep(!/template/,@list);
return @list; return @list;
} }
sub setmtime($$) {
my ($file, $sourcefile) = @_;
# Find out last modified time for the directory the source file was in
my $directory = `dirname $sourcefile`;
chomp $directory;
my $mtime = `git log -1 --format=%ct -- $directory`;
chomp $mtime;
utime(time(),$mtime,$file);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment