mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 02:02:40 +01:00
Fix "arc diff --raw-command --create"
Summary: Fixes T5082. We try to access the repository API in some cases when we don't have one. Test Plan: - Made revisions with "arc diff --raw-command --create". - Made this revision, without "--raw-command". Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5082 Differential Revision: https://secure.phabricator.com/D9165
This commit is contained in:
parent
1493e043e1
commit
b52f3fafe3
2 changed files with 26 additions and 10 deletions
|
@ -760,6 +760,14 @@ abstract class ArcanistBaseWorkflow extends Phobject {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasRepositoryAPI() {
|
||||||
|
try {
|
||||||
|
return (bool)$this->getRepositoryAPI();
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getRepositoryAPI() {
|
public function getRepositoryAPI() {
|
||||||
if (!$this->repositoryAPI) {
|
if (!$this->repositoryAPI) {
|
||||||
$workflow = get_class($this);
|
$workflow = get_class($this);
|
||||||
|
|
|
@ -1169,11 +1169,11 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shouldAmend() {
|
private function shouldAmend() {
|
||||||
if ($this->haveUncommittedChanges) {
|
if ($this->isRawDiffSource()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isHistoryImmutable()) {
|
if ($this->haveUncommittedChanges) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,7 +1181,9 @@ EOTEXT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isRawDiffSource()) {
|
// Run this last: with --raw or --raw-command, we won't have a repository
|
||||||
|
// API.
|
||||||
|
if ($this->isHistoryImmutable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1638,13 +1640,19 @@ EOTEXT
|
||||||
|
|
||||||
$template = ArcanistCommentRemover::removeComments($new_template);
|
$template = ArcanistCommentRemover::removeComments($new_template);
|
||||||
|
|
||||||
$repository_api = $this->getRepositoryAPI();
|
// With --raw-command, we may not have a repository API.
|
||||||
// special check for whether to amend here. optimizes a common git
|
if ($this->hasRepositoryAPI()) {
|
||||||
// workflow. we can't do this for mercurial because the mq extension
|
$repository_api = $this->getRepositoryAPI();
|
||||||
// is popular and incompatible with hg commit --amend ; see T2011.
|
// special check for whether to amend here. optimizes a common git
|
||||||
$should_amend = (count($included_commits) == 1 &&
|
// workflow. we can't do this for mercurial because the mq extension
|
||||||
$repository_api instanceof ArcanistGitAPI &&
|
// is popular and incompatible with hg commit --amend ; see T2011.
|
||||||
$this->shouldAmend());
|
$should_amend = (count($included_commits) == 1 &&
|
||||||
|
$repository_api instanceof ArcanistGitAPI &&
|
||||||
|
$this->shouldAmend());
|
||||||
|
} else {
|
||||||
|
$should_amend = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($should_amend) {
|
if ($should_amend) {
|
||||||
$wrote = (rtrim($old_message) != rtrim($template));
|
$wrote = (rtrim($old_message) != rtrim($template));
|
||||||
if ($wrote) {
|
if ($wrote) {
|
||||||
|
|
Loading…
Reference in a new issue