Title: [196097] trunk/Tools
Revision
196097
Author
[email protected]
Date
2016-02-03 16:35:33 -0800 (Wed, 03 Feb 2016)

Log Message

git-add-reviewer should work when run from a subdirectory within the repository
https://bugs.webkit.org/show_bug.cgi?id=153842

Reviewed by David Kilzer.

There are two problems that needed to be fixed:

 - We can't assume .git is in $PWD/.git
 - We can't specify absolute paths to `git commit`

Fix these problems using the helpers in VCSUtils that were added to
fix this same issue for prepare-changeCogs.

* Scripts/VCSUtils.pm: Export gitDirectory()
* Scripts/git-add-reviewer:
(nonInteractive): Cache gitDirectory() result.
(addReviewer):
(commit):
(changeLogsForCommit): Make paths relative.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (196096 => 196097)


--- trunk/Tools/ChangeLog	2016-02-04 00:27:03 UTC (rev 196096)
+++ trunk/Tools/ChangeLog	2016-02-04 00:35:33 UTC (rev 196097)
@@ -1,3 +1,25 @@
+2016-02-03  Brian Burg  <[email protected]>
+
+        git-add-reviewer should work when run from a subdirectory within the repository
+        https://bugs.webkit.org/show_bug.cgi?id=153842
+
+        Reviewed by David Kilzer.
+
+        There are two problems that needed to be fixed:
+
+         - We can't assume .git is in $PWD/.git
+         - We can't specify absolute paths to `git commit`
+
+        Fix these problems using the helpers in VCSUtils that were added to
+        fix this same issue for prepare-changeCogs.
+
+        * Scripts/VCSUtils.pm: Export gitDirectory()
+        * Scripts/git-add-reviewer:
+        (nonInteractive): Cache gitDirectory() result.
+        (addReviewer):
+        (commit):
+        (changeLogsForCommit): Make paths relative.
+
 2016-02-03  Jer Noble  <[email protected]>
 
         Yet another Yosemite build fix.

Modified: trunk/Tools/Scripts/VCSUtils.pm (196096 => 196097)


--- trunk/Tools/Scripts/VCSUtils.pm	2016-02-04 00:27:03 UTC (rev 196096)
+++ trunk/Tools/Scripts/VCSUtils.pm	2016-02-04 00:35:33 UTC (rev 196097)
@@ -60,6 +60,7 @@
         &exitStatus
         &fixChangeLogPatch
         &gitBranch
+        &gitDirectory
         &gitTreeDirectory
         &gitdiff2svndiff
         &isGit

Modified: trunk/Tools/Scripts/git-add-reviewer (196096 => 196097)


--- trunk/Tools/Scripts/git-add-reviewer	2016-02-04 00:27:03 UTC (rev 196096)
+++ trunk/Tools/Scripts/git-add-reviewer	2016-02-04 00:35:33 UTC (rev 196097)
@@ -31,6 +31,11 @@
 use POSIX;
 use IPC::Open2;
 
+use FindBin;
+use lib $FindBin::Bin;
+use webkitdirs;
+use VCSUtils;
+
 my $defaultReviewer = "NOBODY";
 
 sub addReviewer(\%);
@@ -81,6 +86,8 @@
     'i|interactive' => \$interactive,
 );
 
+my $gitDirectory = gitDirectory();
+
 usage() if !$getOptionsResult || $showHelp;
 
 requireCleanWorkTree();
@@ -181,8 +188,7 @@
     $item{changeLogs} or die;
 
     unless ((($commit eq $headCommit) or checkout($commit))
-            # FIXME: We need to use $ENV{GIT_DIR}/.git/MERGE_MSG
-            && writeCommitMessageToFile(".git/MERGE_MSG")
+            && writeCommitMessageToFile("$gitDirectory/MERGE_MSG")
             && addReviewer(%item)
             && commit(1)
             && (($commit eq $headCommit) or rebaseOntoHead($commit, $head))) {
@@ -233,7 +239,7 @@
         addReviewerToChangeLog($item->{reviewer}, $item->{rubberstamp}, $log) or return fail();
     }
 
-    addReviewerToCommitMessage($item->{reviewer}, $item->{rubberstamp}, ".git/MERGE_MSG") or return fail();
+    addReviewerToCommitMessage($item->{reviewer}, $item->{rubberstamp}, "$gitDirectory/MERGE_MSG") or return fail();
 
     return 1;
 }
@@ -242,7 +248,8 @@
 {
     my ($amend) = @_;
 
-    my @command = qw(git commit -F .git/MERGE_MSG);
+    my @command = qw(git commit -F);
+    push @command, "$gitDirectory/MERGE_MSG";
     push @command, "--amend" if $amend;
     my $result = system @command;
     !($result >> 8) or return fail("Failed to commit revision");
@@ -329,7 +336,7 @@
     my @files = runCommandWithOutput('git', 'diff', '-r', '--name-status', "$commit^", "$commit");
     @files or return fail("Couldn't determine changed files for $commit.");
 
-    my @changeLogs = map { /^[ACMR]\s*(.*)/; $1 } grep { /^[ACMR].*[^-]ChangeLog/ } @files;
+    my @changeLogs = map { /^[ACMR]\s*(.*)/; makeFilePathRelative($1) } grep { /^[ACMR].*[^-]ChangeLog/ } @files;
     return \@changeLogs;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to