mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Improve "arc cover" parameters
Summary: Give "arc cover" --rev and paths parameters like "arc lint" and "arc unit". Test Plan: Ran 'arc cover' with various rev/path things. Ran in SVN to verify it works/fails correctly. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T707 Differential Revision: https://secure.phabricator.com/D1860
This commit is contained in:
parent
454a7de87e
commit
d8967290e9
2 changed files with 49 additions and 17 deletions
|
@ -950,9 +950,19 @@ abstract class ArcanistBaseWorkflow {
|
|||
*
|
||||
* @param list List of explicitly provided paths.
|
||||
* @param string|null Revision name, if provided.
|
||||
* @param mask Mask of ArcanistRepositoryAPI flags to exclude.
|
||||
* Defaults to ArcanistRepositoryAPI::FLAG_UNTRACKED.
|
||||
* @return list List of paths the workflow should act on.
|
||||
*/
|
||||
protected function selectPathsForWorkflow(array $paths, $rev) {
|
||||
protected function selectPathsForWorkflow(
|
||||
array $paths,
|
||||
$rev,
|
||||
$omit_mask = null) {
|
||||
|
||||
if ($omit_mask === null) {
|
||||
$omit_mask = ArcanistRepositoryAPI::FLAG_UNTRACKED;
|
||||
}
|
||||
|
||||
if ($paths) {
|
||||
$working_copy = $this->getWorkingCopy();
|
||||
foreach ($paths as $key => $path) {
|
||||
|
@ -973,7 +983,7 @@ abstract class ArcanistBaseWorkflow {
|
|||
|
||||
$paths = $repository_api->getWorkingCopyStatus();
|
||||
foreach ($paths as $path => $flags) {
|
||||
if ($flags & ArcanistRepositoryAPI::FLAG_UNTRACKED) {
|
||||
if ($flags & $omit_mask) {
|
||||
unset($paths[$path]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ final class ArcanistCoverWorkflow extends ArcanistBaseWorkflow {
|
|||
|
||||
public function getCommandSynopses() {
|
||||
return phutil_console_format(<<<EOTEXT
|
||||
**cover**
|
||||
**cover** [--rev __revision__] [__path__ ...]
|
||||
EOTEXT
|
||||
);
|
||||
}
|
||||
|
@ -34,12 +34,30 @@ EOTEXT
|
|||
return phutil_console_format(<<<EOTEXT
|
||||
Supports: svn, git
|
||||
Cover your... professional reputation. Show blame for the lines you
|
||||
changed in your working copy. This will take a minute because blame
|
||||
takes a minute, especially under SVN.
|
||||
changed in your working copy (svn) or since some commit (hg, git).
|
||||
This will take a minute because blame takes a minute, especially under
|
||||
SVN.
|
||||
EOTEXT
|
||||
);
|
||||
}
|
||||
|
||||
public function getArguments() {
|
||||
return array(
|
||||
'rev' => array(
|
||||
'param' => 'revision',
|
||||
'help' => 'Cover changes since a specific revision.',
|
||||
'supports' => array(
|
||||
'git',
|
||||
'hg',
|
||||
),
|
||||
'nosupport' => array(
|
||||
'svn' => "cover does not currently support --rev in svn.",
|
||||
),
|
||||
),
|
||||
'*' => 'paths',
|
||||
);
|
||||
}
|
||||
|
||||
public function requiresWorkingCopy() {
|
||||
return true;
|
||||
}
|
||||
|
@ -60,21 +78,20 @@ EOTEXT
|
|||
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
|
||||
$paths = $repository_api->getWorkingCopyStatus();
|
||||
$in_paths = $this->getArgument('paths');
|
||||
$in_rev = $this->getArgument('rev');
|
||||
|
||||
foreach ($paths as $path => $status) {
|
||||
if (is_dir($path)) {
|
||||
unset($paths[$path]);
|
||||
}
|
||||
if ($status & ArcanistRepositoryAPI::FLAG_UNTRACKED) {
|
||||
unset($paths[$path]);
|
||||
}
|
||||
if ($status & ArcanistRepositoryAPI::FLAG_ADDED) {
|
||||
unset($paths[$path]);
|
||||
}
|
||||
if ($in_rev) {
|
||||
// Although selectPathsForWorkflow() may set this, we want to set it
|
||||
// explicitly so we blame against the correct relative commit.
|
||||
$repository_api->parseRelativeLocalCommit(array($in_rev));
|
||||
}
|
||||
|
||||
$paths = array_keys($paths);
|
||||
$paths = $this->selectPathsForWorkflow(
|
||||
$in_paths,
|
||||
$in_rev,
|
||||
ArcanistRepositoryAPI::FLAG_UNTRACKED |
|
||||
ArcanistRepositoryAPI::FLAG_ADDED);
|
||||
|
||||
if (!$paths) {
|
||||
throw new ArcanistNoEffectException(
|
||||
|
@ -83,10 +100,15 @@ EOTEXT
|
|||
|
||||
$covers = array();
|
||||
foreach ($paths as $path) {
|
||||
if (is_dir($repository_api->getPath($path))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lines = $this->getChangedLines($path, 'cover');
|
||||
if (!$lines) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$blame = $repository_api->getBlame($path);
|
||||
foreach ($lines as $line) {
|
||||
list($author, $revision) = idx($blame, $line, array(null, null));
|
||||
|
|
Loading…
Reference in a new issue