mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-16 16:58:38 +01:00
Prompt users to ignore or abort on untracked files
Summary: Fixes T7521. This separates things into two prompts and doesn't try to automatically add untracked files. This also fixes T7512, or at least I can't reproduce it after this change. Test Plan: - Ran `arc diff` in a `git` directory with untracked files. - Ran `arc diff` in a `svn` directory with untracked files. - Ran `arc diff` in a `hg` directory with untracked files. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7512, T7521 Differential Revision: https://secure.phabricator.com/D12258
This commit is contained in:
parent
e79032fec2
commit
8bbcbdd3b6
3 changed files with 47 additions and 48 deletions
|
@ -74,6 +74,11 @@ final class ArcanistUSEnglishTranslation extends PhutilTranslation {
|
||||||
'%d assertion passed.',
|
'%d assertion passed.',
|
||||||
'%d assertions passed.',
|
'%d assertions passed.',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'Ignore these %s untracked file(s) and continue?' => array(
|
||||||
|
'Ignore this untracked file and continue?',
|
||||||
|
'Ignore these untracked files and continue?',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,8 +294,7 @@ EOTEXT
|
||||||
'add-all' => array(
|
'add-all' => array(
|
||||||
'short' => 'a',
|
'short' => 'a',
|
||||||
'help' =>
|
'help' =>
|
||||||
'Automatically add all untracked, unstaged and uncommitted files to '.
|
'Automatically add all unstaged and uncommitted files to the commit.',
|
||||||
'the commit.',
|
|
||||||
),
|
),
|
||||||
'json' => array(
|
'json' => array(
|
||||||
'help' =>
|
'help' =>
|
||||||
|
|
|
@ -880,8 +880,43 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
$untracked = array();
|
$untracked = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($untracked) {
|
||||||
|
echo pht(
|
||||||
|
"You have untracked files in this working copy.\n\n%s",
|
||||||
|
$working_copy_desc);
|
||||||
|
|
||||||
|
if ($api instanceof ArcanistGitAPI) {
|
||||||
|
$hint = pht(
|
||||||
|
'(To ignore these %s change(s), add them to ".git/info/exclude".)',
|
||||||
|
new PhutilNumber(count($untracked)));
|
||||||
|
} else if ($api instanceof ArcanistSubversionAPI) {
|
||||||
|
$hint = pht(
|
||||||
|
'(To ignore these %s change(s), add them to "svn:ignore".)',
|
||||||
|
new PhutilNumber(count($untracked)));
|
||||||
|
} else if ($api instanceof ArcanistMercurialAPI) {
|
||||||
|
$hint = pht(
|
||||||
|
'(To ignore these %s change(s), add them to ".hgignore".)',
|
||||||
|
new PhutilNumber(count($untracked)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$untracked_list = " ".implode("\n ", $untracked);
|
||||||
|
echo pht(
|
||||||
|
" Untracked changes in working copy:\n %s\n%s",
|
||||||
|
$hint,
|
||||||
|
$untracked_list);
|
||||||
|
|
||||||
|
$prompt = pht(
|
||||||
|
'Ignore these %s untracked file(s) and continue?',
|
||||||
|
new PhutilNumber(count($untracked)));
|
||||||
|
|
||||||
|
if (!phutil_console_confirm($prompt)) {
|
||||||
|
throw new ArcanistUserAbortException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$should_commit = false;
|
$should_commit = false;
|
||||||
if ($untracked || $unstaged || $uncommitted) {
|
if ($unstaged || $uncommitted) {
|
||||||
|
|
||||||
// NOTE: We're running this because it builds a cache and can take a
|
// NOTE: We're running this because it builds a cache and can take a
|
||||||
// perceptible amount of time to arrive at an answer, but we don't want
|
// perceptible amount of time to arrive at an answer, but we don't want
|
||||||
|
@ -894,28 +929,6 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
|
|
||||||
$lists = array();
|
$lists = array();
|
||||||
|
|
||||||
if ($untracked) {
|
|
||||||
if ($api instanceof ArcanistGitAPI) {
|
|
||||||
$hint = pht(
|
|
||||||
'(To ignore these %s change(s), add them to ".git/info/exclude".)',
|
|
||||||
new PhutilNumber(count($untracked)));
|
|
||||||
} else if ($api instanceof ArcanistSubversionAPI) {
|
|
||||||
$hint = pht(
|
|
||||||
'(To ignore these %s change(s), add them to "svn:ignore".)',
|
|
||||||
new PhutilNumber(count($untracked)));
|
|
||||||
} else if ($api instanceof ArcanistMercurialAPI) {
|
|
||||||
$hint = pht(
|
|
||||||
'(To ignore these %s change(s), add them to ".hgignore".)',
|
|
||||||
new PhutilNumber(count($untracked)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$untracked_list = " ".implode("\n ", $untracked);
|
|
||||||
$lists[] = pht(
|
|
||||||
" Untracked changes in working copy:\n %s\n%s",
|
|
||||||
$hint,
|
|
||||||
$untracked_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($unstaged) {
|
if ($unstaged) {
|
||||||
$unstaged_list = " ".implode("\n ", $unstaged);
|
$unstaged_list = " ".implode("\n ", $unstaged);
|
||||||
$lists[] = pht(
|
$lists[] = pht(
|
||||||
|
@ -932,12 +945,8 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
|
|
||||||
echo implode("\n\n", $lists)."\n";
|
echo implode("\n\n", $lists)."\n";
|
||||||
|
|
||||||
$all_uncommitted = array_merge($untracked, $unstaged, $uncommitted);
|
$all_uncommitted = array_merge($unstaged, $uncommitted);
|
||||||
if ($this->askForAdd($all_uncommitted)) {
|
if ($this->askForAdd($all_uncommitted)) {
|
||||||
if ($untracked) {
|
|
||||||
$api->addToCommit($untracked);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($unstaged) {
|
if ($unstaged) {
|
||||||
$api->addToCommit($unstaged);
|
$api->addToCommit($unstaged);
|
||||||
}
|
}
|
||||||
|
@ -952,20 +961,10 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
$api->stashChanges();
|
$api->stashChanges();
|
||||||
$this->stashed = true;
|
$this->stashed = true;
|
||||||
} else {
|
} else {
|
||||||
if ($untracked && !$unstaged && !$uncommitted) {
|
throw new ArcanistUsageException(
|
||||||
// Give a tailored message if there are only untracked files,
|
pht(
|
||||||
// because the advice to commit files does not make sense in
|
'You can not continue with uncommitted changes. Commit '.
|
||||||
// Subversion.
|
'or discard them before proceeding.'));
|
||||||
throw new ArcanistUsageException(
|
|
||||||
pht(
|
|
||||||
'You can not continue with untracked changes. Add them, '.
|
|
||||||
'discard them, or mark them as ignored before proceeding.'));
|
|
||||||
} else {
|
|
||||||
throw new ArcanistUsageException(
|
|
||||||
pht(
|
|
||||||
'You can not continue with uncommitted changes. Commit '.
|
|
||||||
'or discard them before proceeding.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -980,10 +979,6 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
"# ".pht('Enter a commit message.')."\n#\n".
|
"# ".pht('Enter a commit message.')."\n#\n".
|
||||||
"# ".pht('Changes:')."\n#\n";
|
"# ".pht('Changes:')."\n#\n";
|
||||||
|
|
||||||
foreach ($untracked as $untracked_path) {
|
|
||||||
$template .= "# ".$untracked_path." (".pht('Added').")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = array_merge($uncommitted, $unstaged);
|
$paths = array_merge($uncommitted, $unstaged);
|
||||||
$paths = array_unique($paths);
|
$paths = array_unique($paths);
|
||||||
sort($paths);
|
sort($paths);
|
||||||
|
|
Loading…
Add table
Reference in a new issue