mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Support "immutable_history" doctrine in arc
Summary: When a project uses a conservative history mutability doctrine, never try to amend history. Test Plan: Ran "arc amend" in an "immutable_history" working copy. Reviewers: fratrik, Makinde, aran, jungejason, tuomaspelkonen Reviewed By: Makinde CC: aran, Makinde, epriestley Differential Revision: 862
This commit is contained in:
parent
44959afd4b
commit
c84d6255b4
3 changed files with 21 additions and 3 deletions
|
@ -65,6 +65,14 @@ EOTEXT
|
|||
}
|
||||
|
||||
public function run() {
|
||||
if ($this->isHistoryImmutable()) {
|
||||
throw new ArcanistUsageException(
|
||||
"This project is marked as adhering to a conservative history ".
|
||||
"mutability doctrine (having an immutable local history), which ".
|
||||
"precludes amending commit messages. You can use 'arc merge' to ".
|
||||
"merge feature branches instead.");
|
||||
}
|
||||
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
if (!($repository_api instanceof ArcanistGitAPI)) {
|
||||
throw new ArcanistUsageException(
|
||||
|
|
|
@ -913,4 +913,9 @@ class ArcanistBaseWorkflow {
|
|||
file_put_contents('php://stderr', $msg);
|
||||
}
|
||||
|
||||
protected function isHistoryImmutable() {
|
||||
$working_copy = $this->getWorkingCopy();
|
||||
return ($working_copy->getConfig('immutable_history') === true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -549,8 +549,10 @@ EOTEXT
|
|||
}
|
||||
|
||||
if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||
// TODO: This is unlikely to be correct since it excludes using local
|
||||
// branching in Mercurial.
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isHistoryImmutable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1112,10 @@ EOTEXT
|
|||
}
|
||||
$lint_workflow = $this->buildChildWorkflow('lint', $argv);
|
||||
|
||||
$lint_workflow->setShouldAmendChanges(true);
|
||||
if (!$this->isHistoryImmutable()) {
|
||||
// TODO: We should offer to create a checkpoint commit.
|
||||
$lint_workflow->setShouldAmendChanges(true);
|
||||
}
|
||||
|
||||
$lint_result = $lint_workflow->run();
|
||||
|
||||
|
|
Loading…
Reference in a new issue