]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Imports: Add reporting of new and removed files
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 20 Nov 2010 10:25:06 +0000 (10:25 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 21 Nov 2010 14:37:35 +0000 (06:37 -0800)
Make the commit message produced by import-external-git.pl also report
which files the script added and removed. Whilst this information is
available from the patch itself, having it in the commit message makes
it much easier to tell what happened when reviewing history through
git log.

Change-Id: I59e7deb0f4f1e8c22d07222e1789c66c65612992
Reviewed-on: http://gerrit.openafs.org/3334
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/external/import-external-git.pl

index 2f2ca78d1b7c9ae91f1d1b4011e82ff173c95644..45b813863dbdddcf835be47e598e7e2ebfa9eb66 100755 (executable)
@@ -134,7 +134,11 @@ if (system("git diff-index --quiet --cached HEAD --ignore-submodules") != 0 ||
   $stashed = 1;
 }
 
+
 eval {
+  my @addedFiles;
+  my @deletedFiles;
+
   # Use git-ls-files to get the list of currently committed files for the module
   my $lspipe = IO::Pipe->new();
   $lspipe->reader(qw(git ls-files));
@@ -148,6 +152,9 @@ eval {
   foreach my $source (sort keys(%mapping)) {
     if (-f "$tempdir/source/$source") {
       File::Path::make_path(File::Basename::dirname($mapping{$source}));
+      if (!-f "$externalDir/$module/".$mapping{$source}) {
+        push @addedFiles, $mapping{$source};
+      }
       system("cp $tempdir/source/$source ".
             "   $externalDir/$module/".$mapping{$source}) == 0
          or die "Copy failed with $!\n";
@@ -164,6 +171,7 @@ eval {
   foreach my $missing (keys(%filesInTree)) {
     system("git rm $missing") == 0
       or die "Couldn't git rm $missing : $!\n";
+    push @deletedFiles, $missing;
   }
 
   if (system("git status") == 0) {
@@ -184,6 +192,18 @@ eval {
        $fh->print("Upstream changes are:\n\n");
        $fh->print($changes);
     }
+    if (@addedFiles) {
+       $fh->print("\n");
+       $fh->print("New files are:\n");
+       $fh->print(join("\n", map { "\t".$_  } sort @addedFiles));
+       $fh->print("\n");
+    }
+    if (@deletedFiles) {
+       $fh->print("\n");
+       $fh->print("Deleted files are:\n");
+       $fh->print(join("\n", map { "\t".$_  } sort @deletedFiles));
+       $fh->print("\n");
+    }
     undef $fh;
     $author="--author '$author'" if ($author);
     system("git commit -F $tempdir/commit-msg $author") == 0