Commits

Jeff Squyres committed 6347c3b

Update the update-my-copyright.pl script to also be able to handle git
checkouts.

Comments (0)

Files changed (1)

contrib/update-my-copyright.pl

 
 # Are we hg or svn?  If we're both hg and svn, assume svn.
 my $cmd;
-$cmd = "svn st ."
-    if (-d "$top/.svn");
-$cmd = "hg st ."
-    if (-d "$top/.hg" && ! -d "$top/.svn");
-die "Can't find SVN or HG meta dirs" 
-    if (!defined($cmd));
+if (-d "$top/.svn") {
+    $cmd = "svn st .";
+} elsif (-d "$top/.hg") {
+    $cmd = "hg st .";
+} elsif (-d "$top/.git") {
+    $cmd = "git status .";
+} else {
+    die "Can't find SVN or HG meta dirs";
+}
 
 # Run the command, parsing the output.  Make a list of files that are
 # added or modified.
 my @files;
 while (<CMD>) {
     chomp;
+    # SVN and HG use this form
     if ($_ =~ /^M/ || $_ =~ /^A/) {
         my @tokens = split(/\s+/, $_);
         # Handle output of both forms:
         push(@files, $filename)
             if (-f $filename);
     }
+
+    # Git uses these forms
+    elsif ($_ =~ m/^#\s+modified:\s+(\S+)$/) {
+        push(@files, $1)
+            if (-f $1);
+    } elsif ($_ =~ m/^#\s+new file:\s+(\S+)$/) {
+        push(@files, $1)
+            if (-f $1);
+    }
 }
 close(CMD);
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.