mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Enable lint amending commits in mercurial
Summary: arc lint was hardcoded for git for amending commits with lint patches. This enables the same functionality for mercurial. Test Plan: Made some changes that would result in a lint patch. arc diff Verify that the patches it produces were amended into the commit. Verified it still works in git as well. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5716
This commit is contained in:
parent
bfc1eeba07
commit
b3108661bb
4 changed files with 30 additions and 16 deletions
|
@ -514,12 +514,17 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function amendCommit($message) {
|
||||
$tmp_file = new TempFile();
|
||||
Filesystem::writeFile($tmp_file, $message);
|
||||
$this->execxLocal(
|
||||
'commit --amend --allow-empty -F %s',
|
||||
$tmp_file);
|
||||
public function amendCommit($message = null) {
|
||||
if ($message === null) {
|
||||
$this->execxLocal('commit --amend --allow-empty -C HEAD');
|
||||
} else {
|
||||
$tmp_file = new TempFile();
|
||||
Filesystem::writeFile($tmp_file, $message);
|
||||
$this->execxLocal(
|
||||
'commit --amend --allow-empty -F %s',
|
||||
$tmp_file);
|
||||
}
|
||||
|
||||
$this->reloadWorkingCopy();
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -715,7 +715,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
$this->reloadWorkingCopy();
|
||||
}
|
||||
|
||||
public function amendCommit($message) {
|
||||
public function amendCommit($message = null) {
|
||||
if ($message === null) {
|
||||
$message = $this->getCommitMessage('.');
|
||||
}
|
||||
|
||||
$tmp_file = new TempFile();
|
||||
Filesystem::writeFile($tmp_file, $message);
|
||||
$this->execxLocal(
|
||||
|
|
|
@ -370,7 +370,7 @@ abstract class ArcanistRepositoryAPI {
|
|||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function amendCommit($message) {
|
||||
public function amendCommit($message = null) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
|
|
|
@ -380,6 +380,12 @@ EOTEXT
|
|||
$prompt_autofix_patches = true;
|
||||
}
|
||||
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
if ($this->shouldAmendChanges) {
|
||||
$this->shouldAmendChanges = $repository_api->supportsAmend() &&
|
||||
!$this->isHistoryImmutable();
|
||||
}
|
||||
|
||||
$wrote_to_disk = false;
|
||||
|
||||
switch ($this->getArgument('output')) {
|
||||
|
@ -461,11 +467,7 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
if ($wrote_to_disk &&
|
||||
($repository_api instanceof ArcanistGitAPI) &&
|
||||
$this->shouldAmendChanges) {
|
||||
|
||||
if ($wrote_to_disk && $this->shouldAmendChanges) {
|
||||
if ($this->shouldAmendWithoutPrompt ||
|
||||
($this->shouldAmendAutofixesWithoutPrompt && $all_autofix)) {
|
||||
$console->writeOut(
|
||||
|
@ -477,9 +479,12 @@ EOTEXT
|
|||
}
|
||||
|
||||
if ($amend) {
|
||||
execx(
|
||||
'(cd %s; git commit -a --amend -C HEAD)',
|
||||
$repository_api->getPath());
|
||||
if ($repository_api instanceof ArcanistGitAPI) {
|
||||
// Add the changes to the index before amending
|
||||
$repository_api->execxLocal('add -A');
|
||||
}
|
||||
|
||||
$repository_api->amendCommit();
|
||||
} else {
|
||||
throw new ArcanistUsageException(
|
||||
"Sort out the lint changes that were applied to the working ".
|
||||
|
|
Loading…
Reference in a new issue