From b32b868a61078b3a40a745f4a0bb1e895beed946 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 30 Apr 2012 14:14:23 -0700 Subject: [PATCH] add support for using Arcanist with git's log.decorate setting enabled Summary: Arcanist fails to find git's 'commit ' header when log.decorate is set in one of git's config files. git adds the named refs that point to the commit in parentheses following the hash. This changes the regex used by arcanist to match git commit headers to optionally match the branch names in parentheses following the hash. Test Plan: Run `git config --global log.decorate short` and check that `arc diff` runs successfully. Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2344 --- src/parser/diff/ArcanistDiffParser.php | 2 +- .../__tests__/ArcanistDiffParserTestCase.php | 1 + .../data/git-commit-logdecorate.gitdiff | 31 +++++++++++++++++++ src/repository/api/git/ArcanistGitAPI.php | 5 +-- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/parser/diff/__tests__/data/git-commit-logdecorate.gitdiff diff --git a/src/parser/diff/ArcanistDiffParser.php b/src/parser/diff/ArcanistDiffParser.php index 344c72c2..7a93b524 100644 --- a/src/parser/diff/ArcanistDiffParser.php +++ b/src/parser/diff/ArcanistDiffParser.php @@ -215,7 +215,7 @@ final class ArcanistDiffParser { // This is an SVN property change, probably from "svn diff". '(?PProperty changes on): (?P.+)', // This is a git commit message, probably from "git show". - '(?Pcommit) (?P[a-f0-9]+)', + '(?Pcommit) (?P[a-f0-9]+)(?: \(.*\))?', // This is a git diff, probably from "git show" or "git diff". // Note that the filenames may appear quoted. '(?Pdiff --git) '. diff --git a/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php b/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php index 450cc7a5..bdfa724c 100644 --- a/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php +++ b/src/parser/diff/__tests__/ArcanistDiffParserTestCase.php @@ -428,6 +428,7 @@ EOTEXT $this->assertEqual(1, count(reset($changes)->getHunks())); break; case 'git-commit.gitdiff': + case 'git-commit-logdecorate.gitdiff': $this->assertEqual(1, count($changes)); $change = reset($changes); $this->assertEqual( diff --git a/src/parser/diff/__tests__/data/git-commit-logdecorate.gitdiff b/src/parser/diff/__tests__/data/git-commit-logdecorate.gitdiff new file mode 100644 index 00000000..70b64fd8 --- /dev/null +++ b/src/parser/diff/__tests__/data/git-commit-logdecorate.gitdiff @@ -0,0 +1,31 @@ +commit 76e2f1339c298c748aa0b52030799ed202a6537b (HEAD, refs/heads/master) +Author: ngao +Date: Wed Mar 3 20:39:39 2010 +0000 + + Deprecating UIActionButton (Part 1) + + Summary: Replaces calls to UIActionButton with . I tested most + of these calls, but there were some that I didn't know how to + reach, so if you are one of the owners of this code, please test + your feature in my sandbox: www.ngao.devrs013.facebook.com + + @brosenthal, I removed some logic that was setting a disabled state + on a UIActionButton, which is actually a no-op. + + Reviewed By: brosenthal + + Other Commenters: sparker, egiovanola + + Test Plan: www.ngao.devrs013.facebook.com + + Explicitly tested: + * ads creation flow (add keyword) + * ads manager (conversion tracking) + * help center (create a discussion) + * new user wizard (next step button) + + Revert: OK + + DiffCamp Revision: 94064 + + git-svn-id: svn+ssh://tubbs/svnroot/tfb/trunk/www@223593 2c7ba8d8 diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 3511e715..d4ba6c31 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -281,11 +281,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { return ''; } else if ($relative == self::GIT_MAGIC_ROOT_COMMIT) { // First commit. - list($stdout) = $this->execxLocal('log --format=medium HEAD'); + list($stdout) = $this->execxLocal( + 'log --no-decorate --format=medium HEAD'); } else { // 2..N commits. list($stdout) = $this->execxLocal( - 'log --first-parent --format=medium %s..HEAD', + 'log --no-decorate --first-parent --format=medium %s..HEAD', $this->getRelativeCommit()); } return $stdout;