diff --git a/makeclass b/makeclass index 28d1223b4dc1890740fc7e5af92d5506b6f71df3..79374fe5565ae5d2bfbfed09f5653293bd9a50d6 100755 --- a/makeclass +++ b/makeclass @@ -8,6 +8,7 @@ use strict; sub transmogrify($); sub cleanup(@); +sub setmtime($$); my $CLASSDIR = "class"; @@ -19,15 +20,20 @@ my @others = ("syllabus", "schedule"); @lecturenotes = cleanup(@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"; system "$command"; + setmtime($destfile,$file); } 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"; system "$command"; + setmtime($destfile,$sourcefile); } sub transmogrify($) { @@ -49,3 +55,15 @@ sub cleanup(@) { @list = grep(!/template/,@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); +}