]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Arcanist - fix shouldAmend code
authorBob Trahan <btrahan@phacility.com>
Fri, 11 Apr 2014 20:07:54 +0000 (13:07 -0700)
committerBob Trahan <btrahan@phacility.com>
Fri, 11 Apr 2014 20:07:54 +0000 (13:07 -0700)
Summary: make it a real member variable. See rARC77a9c1814063 and D8753#33914.

Test Plan: sending up this diff!

Reviewers: shadowhand, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8761

src/workflow/ArcanistBaseWorkflow.php

index d0fcd92936c710289de60bea1a57d326b6e7b9e8..868370739c643baeb4d162cef540a6969d65d6c6 100644 (file)
@@ -62,6 +62,7 @@ abstract class ArcanistBaseWorkflow extends Phobject {
   private $command;
 
   private $stashed;
+  private $shouldAmend;
 
   private $projectInfo;
   private $repositoryInfo;
@@ -913,7 +914,7 @@ abstract class ArcanistBaseWorkflow extends Phobject {
     }
 
     if ($must_commit) {
-      if ($this->shouldAmend()) {
+      if ($this->getShouldAmend()) {
         $commit = head($api->getLocalCommitInformation());
         $api->amendCommit($commit['message']);
       } else if ($api->supportsLocalCommits()) {
@@ -926,8 +927,11 @@ abstract class ArcanistBaseWorkflow extends Phobject {
     }
   }
 
-  private function shouldAmend() {
-    return $this->calculateShouldAmend();
+  private function getShouldAmend() {
+    if ($this->shouldAmend === null) {
+      $this->shouldAmend = $this->calculateShouldAmend();
+    }
+    return $this->shouldAmend;
   }
 
   private function calculateShouldAmend() {
@@ -1000,7 +1004,7 @@ abstract class ArcanistBaseWorkflow extends Phobject {
   }
 
   private function getAskForAddPrompt(array $files) {
-    if ($this->shouldAmend()) {
+    if ($this->getShouldAmend()) {
       $prompt = pht(
         'Do you want to amend these files to the commit?',
         count($files));