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;
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);
}
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