Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistPatchWorkflow.php
Show First 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | if ($repository_api instanceof ArcanistSubversionAPI) { | ||||
$patchfile = new TempFile(); | $patchfile = new TempFile(); | ||||
Filesystem::writeFile($patchfile, $bundle->toGitPatch()); | Filesystem::writeFile($patchfile, $bundle->toGitPatch()); | ||||
$passthru = new PhutilExecPassthru( | $passthru = new PhutilExecPassthru( | ||||
'git apply --whitespace nowarn --index --reject -- %s', | 'git apply --whitespace nowarn --index --reject -- %s', | ||||
$patchfile); | $patchfile); | ||||
$passthru->setCWD($repository_api->getPath()); | $passthru->setCWD($repository_api->getPath()); | ||||
$err = $passthru->execute(); | $err = $passthru->resolve(); | ||||
if ($err) { | if ($err) { | ||||
echo phutil_console_format( | echo phutil_console_format( | ||||
"\n<bg:red>** %s **</bg>\n", | "\n<bg:red>** %s **</bg>\n", | ||||
pht('Patch Failed!')); | pht('Patch Failed!')); | ||||
// NOTE: Git patches may fail if they change the case of a filename | // NOTE: Git patches may fail if they change the case of a filename | ||||
// (for instance, from 'example.c' to 'Example.c'). As of now, Git | // (for instance, from 'example.c' to 'Example.c'). As of now, Git | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if ($revision_id && $this->isConduitAuthenticated()) { | ||||
$conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
$commit_message = $conduit->callMethodSynchronous( | $commit_message = $conduit->callMethodSynchronous( | ||||
'differential.getcommitmessage', | 'differential.getcommitmessage', | ||||
array( | array( | ||||
'revision_id' => $revision_id, | 'revision_id' => $revision_id, | ||||
)); | )); | ||||
$prompt_message = pht( | $prompt_message = pht( | ||||
' Note arcanist failed to load the commit message '. | ' NOTE: Failed to load the commit message from Differential (for '. | ||||
'from differential for revision %s.', | 'revision "%s".)', | ||||
"D{$revision_id}"); | "D{$revision_id}"); | ||||
} | } | ||||
// no revision id or failed to fetch commit message so get it from the | // no revision id or failed to fetch commit message so get it from the | ||||
// user on the command line | // user on the command line | ||||
if (!$commit_message) { | if (!$commit_message) { | ||||
$template = sprintf( | $template = sprintf( | ||||
"\n\n# %s%s\n", | "\n\n# %s%s\n", | ||||
pht( | pht( | ||||
'Enter a commit message for this patch. If you just want to apply '. | 'Enter a commit message for this patch. If you just want to apply '. | ||||
'the patch to the working copy without committing, re-run arc patch '. | 'the patch to the working copy without committing, re-run arc patch '. | ||||
'with the %s flag.', | 'with the %s flag.', | ||||
'--nocommit'), | '--nocommit'), | ||||
$prompt_message); | $prompt_message); | ||||
$commit_message = $this->newInteractiveEditor($template) | $commit_message = $this->newInteractiveEditor($template) | ||||
->setName('arcanist-patch-commit-message') | ->setName('arcanist-patch-commit-message') | ||||
->setTaskMessage(pht( | |||||
'Supply a commit message for this patch, then save and exit.')) | |||||
->editInteractively(); | ->editInteractively(); | ||||
$commit_message = ArcanistCommentRemover::removeComments($commit_message); | $commit_message = ArcanistCommentRemover::removeComments($commit_message); | ||||
if (!strlen(trim($commit_message))) { | if (!strlen(trim($commit_message))) { | ||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0