From: vrana Date: Tue, 20 Nov 2012 18:43:19 +0000 (-0800) Subject: Don't amend commits with different author X-Git-Tag: conduit-6~17 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0cf8ef02d8a64c103df48082a95fb1c8fb05670b;p=arcanist.git Don't amend commits with different author Summary: Also delete extra newlines. Test Plan: $ arc diff # on top of my commit Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2025 Differential Revision: https://secure.phabricator.com/D3996 --- diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 9e51c0a0..6a2dcb1a 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -472,6 +472,18 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { return $this->status; } + public function getGitConfig($key, $default = null) { + list($stdout) = $this->execxLocal('config %s', $key); + if ($stdout == '') { + return $default; + } + return rtrim($stdout); + } + + public function getAuthor() { + return $this->getGitConfig('user.name'); + } + public function addToCommit(array $paths) { $this->execxLocal( 'add -- %Ls', diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 2f9aa167..6d5cfc78 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -594,6 +594,18 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $this->execxLocal('up'); } + private function getMercurialConfig($key, $default = null) { + list($stdout) = $this->execxLocal('showconfig %s', $key); + if ($stdout == '') { + return $default; + } + return rtrim($stdout); + } + + public function getAuthor() { + return $this->getMercurialConfig('ui.username'); + } + public function addToCommit(array $paths) { $this->execxLocal( 'add -- %Ls', diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php index cc5b27f5..b27241ac 100644 --- a/src/repository/api/ArcanistRepositoryAPI.php +++ b/src/repository/api/ArcanistRepositoryAPI.php @@ -192,6 +192,10 @@ abstract class ArcanistRepositoryAPI { throw new ArcanistCapabilityNotSupportedException($this); } + public function getAuthor() { + throw new ArcanistCapabilityNotSupportedException($this); + } + public function addToCommit(array $paths) { throw new ArcanistCapabilityNotSupportedException($this); } diff --git a/src/workflow/ArcanistBaseWorkflow.php b/src/workflow/ArcanistBaseWorkflow.php index 1b9cccd1..f53936c8 100644 --- a/src/workflow/ArcanistBaseWorkflow.php +++ b/src/workflow/ArcanistBaseWorkflow.php @@ -795,7 +795,7 @@ abstract class ArcanistBaseWorkflow { echo "You have unstaged changes in this working copy.\n\n". $working_copy_desc. " Unstaged changes in working copy:\n". - " ".implode("\n ", $unstaged)."\n\n"; + " ".implode("\n ", $unstaged); if ($this->askForAdd()) { $api->addToCommit($unstaged); $must_commit += array_flip($unstaged); @@ -815,7 +815,7 @@ abstract class ArcanistBaseWorkflow { echo "You have uncommitted changes in this working copy.\n\n". $working_copy_desc. " Uncommitted changes in working copy:\n". - " ".implode("\n ", $uncommitted)."\n\n"; + " ".implode("\n ", $uncommitted); if ($this->askForAdd()) { $must_commit += array_flip($uncommitted); } else { @@ -853,7 +853,10 @@ abstract class ArcanistBaseWorkflow { return false; } - // TODO: Check last commit's author. If not me then return false. + if ($api->getAuthor() != $commit['author']) { + return false; + } + // TODO: Check commits since tracking branch. If empty then return false. $repository_phid = idx($this->getProjectInfo(), 'repositoryPHID');