From 628de7d7a15cd7b5737515ec2831b3b4c3f601a5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 12 Mar 2011 18:16:15 -0800 Subject: [PATCH] Make all the working-copy-paths errors extremely explicit. --- src/__phutil_library_map__.php | 2 + src/repository/api/git/ArcanistGitAPI.php | 3 ++ src/workflow/base/ArcanistBaseWorkflow.php | 45 +++++++++++++++------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index dd5b4f0c..04bb86ce 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -50,6 +50,7 @@ phutil_register_library_map(array( 'ArcanistNoEffectException' => 'exception/usage/noeffect', 'ArcanistNoEngineException' => 'exception/usage/noengine', 'ArcanistNoLintLinter' => 'lint/linter/nolint', + 'ArcanistNoLintTestCaseMisnamed' => 'lint/linter/nolint/__tests__', 'ArcanistPEP8Linter' => 'lint/linter/pep8', 'ArcanistPatchWorkflow' => 'workflow/patch', 'ArcanistPhutilModuleLinter' => 'lint/linter/phutilmodule', @@ -100,6 +101,7 @@ phutil_register_library_map(array( 'ArcanistNoEffectException' => 'ArcanistUsageException', 'ArcanistNoEngineException' => 'ArcanistUsageException', 'ArcanistNoLintLinter' => 'ArcanistLinter', + 'ArcanistNoLintTestCaseMisnamed' => 'ArcanistLinterTestCase', 'ArcanistPEP8Linter' => 'ArcanistLinter', 'ArcanistPatchWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistPhutilModuleLinter' => 'ArcanistLinter', diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 15f5c952..cc961d35 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -182,6 +182,9 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI { } } + // TODO: This doesn't list unstaged adds. It's not clear how to get that + // list other than "git status --porcelain" and then parsing it. :/ + // Find unstaged changes. list($stdout) = execx( '(cd %s; git ls-files -m)', diff --git a/src/workflow/base/ArcanistBaseWorkflow.php b/src/workflow/base/ArcanistBaseWorkflow.php index c66c300a..aa96dc0e 100644 --- a/src/workflow/base/ArcanistBaseWorkflow.php +++ b/src/workflow/base/ArcanistBaseWorkflow.php @@ -316,21 +316,26 @@ class ArcanistBaseWorkflow { protected function requireCleanWorkingCopy() { $api = $this->getRepositoryAPI(); + $working_copy_desc = phutil_console_format( + " Working copy: __%s__\n\n", + $api->getPath()); + $untracked = $api->getUntrackedChanges(); if ($this->shouldRequireCleanUntrackedFiles()) { if (!empty($untracked)) { - - echo "You have untracked files in this working copy:\n\n". + echo "You have untracked files in this working copy.\n\n". + $working_copy_desc. + " Untracked files in working copy:\n". " ".implode("\n ", $untracked)."\n\n"; if ($api instanceof ArcanistGitAPI) { echo phutil_console_wrap( - "Since you don't have .gitignore rules for these files and have ". - "not listed them in .git/info/exclude, you may have forgotten ". + "Since you don't have '.gitignore' rules for these files and have ". + "not listed them in '.git/info/exclude', you may have forgotten ". "to 'git add' them to your commit."); } else if ($api instanceof ArcanistSubversionAPI) { echo phutil_console_wrap( - "Since you don't have svn:ignore rules for these files, you may ". + "Since you don't have 'svn:ignore' rules for these files, you may ". "have forgotten to 'svn add' them."); } @@ -345,27 +350,41 @@ class ArcanistBaseWorkflow { if ($incomplete) { throw new ArcanistUsageException( "You have incompletely checked out directories in this working copy. ". - "Fix them before proceeding: \n\n". + "Fix them before proceeding.\n\n". + $working_copy_desc. + " Incomplete directories in working copy:\n". " ".implode("\n ", $incomplete)."\n\n". "You can fix these paths by running 'svn update' on them."); } - if ($api->getMergeConflicts()) { + $conflicts = $api->getMergeConflicts(); + if ($conflicts) { throw new ArcanistUsageException( "You have merge conflicts in this working copy. Resolve merge ". - "conflicts before proceeding."); + "conflicts before proceeding.\n\n". + $working_copy_desc. + " Conflicts in working copy:\n". + " ".implode("\n ", $conflicts)."\n"); } - if ($api->getUnstagedChanges()) { + $unstaged = $api->getUnstagedChanges(); + if ($unstaged) { throw new ArcanistUsageException( - "You have unstaged changes in this branch. Stage and commit (or ". - "revert) them before proceeding."); + "You have unstaged changes in this working copy. Stage and commit (or ". + "revert) them before proceeding.\n\n". + $working_copy_desc. + " Unstaged changes in working copy:\n". + " ".implode("\n ", $unstaged)."\n"); } - if ($api->getUncommittedChanges()) { + $uncommitted = $api->getUncommittedChanges(); + if ($uncommitted) { throw new ArcanistUsageException( "You have uncommitted changes in this branch. Commit (or revert) them ". - "before proceeding."); + "before proceeding.\n\n". + $working_copy_desc. + " Uncommitted changes in working copy\n". + " ".implode("\n ", $uncommitted)."\n"); } }