]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't amend commits with different author
authorvrana <jakubv@fb.com>
Tue, 20 Nov 2012 18:43:19 +0000 (10:43 -0800)
committervrana <jakubv@fb.com>
Wed, 21 Nov 2012 21:09:11 +0000 (13:09 -0800)
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

src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/workflow/ArcanistBaseWorkflow.php

index 9e51c0a03b301232a2ed5af1f84e423bd0bcf8d2..6a2dcb1abe4bd7b6f988fe2cf8967a5bff194024 100644 (file)
@@ -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',
index 2f9aa167b034a4533ae6f60fc69914c5f0cea905..6d5cfc78a720b53161d985298009d3098d447f22 100644 (file)
@@ -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',
index cc5b27f50dd2c470da11a41f80a491db0c70c68e..b27241ac8c3fef187c9591521a0d450e54f34e92 100644 (file)
@@ -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);
   }
index 1b9cccd1bb7ec0d79f8c2bd412ef18795fbb55e9..f53936c83759e5ba3a00834ca5ed074e76d16764 100644 (file)
@@ -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');