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;
}
$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(
throw new ArcanistCapabilityNotSupportedException($this);
}
- public function amendCommit($message) {
+ public function amendCommit($message = null) {
throw new ArcanistCapabilityNotSupportedException($this);
}
$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')) {
}
}
- $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(
}
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 ".