mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 10:12:41 +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 list List of explicitly provided paths.
|
||||||
* @param string|null Revision name, if provided.
|
* @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.
|
* @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) {
|
if ($paths) {
|
||||||
$working_copy = $this->getWorkingCopy();
|
$working_copy = $this->getWorkingCopy();
|
||||||
foreach ($paths as $key => $path) {
|
foreach ($paths as $key => $path) {
|
||||||
|
@ -973,7 +983,7 @@ abstract class ArcanistBaseWorkflow {
|
||||||
|
|
||||||
$paths = $repository_api->getWorkingCopyStatus();
|
$paths = $repository_api->getWorkingCopyStatus();
|
||||||
foreach ($paths as $path => $flags) {
|
foreach ($paths as $path => $flags) {
|
||||||
if ($flags & ArcanistRepositoryAPI::FLAG_UNTRACKED) {
|
if ($flags & $omit_mask) {
|
||||||
unset($paths[$path]);
|
unset($paths[$path]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class ArcanistCoverWorkflow extends ArcanistBaseWorkflow {
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getCommandSynopses() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
**cover**
|
**cover** [--rev __revision__] [__path__ ...]
|
||||||
EOTEXT
|
EOTEXT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,30 @@ EOTEXT
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
Supports: svn, git
|
Supports: svn, git
|
||||||
Cover your... professional reputation. Show blame for the lines you
|
Cover your... professional reputation. Show blame for the lines you
|
||||||
changed in your working copy. This will take a minute because blame
|
changed in your working copy (svn) or since some commit (hg, git).
|
||||||
takes a minute, especially under SVN.
|
This will take a minute because blame takes a minute, especially under
|
||||||
|
SVN.
|
||||||
EOTEXT
|
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() {
|
public function requiresWorkingCopy() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -60,21 +78,20 @@ EOTEXT
|
||||||
|
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
|
||||||
$paths = $repository_api->getWorkingCopyStatus();
|
$in_paths = $this->getArgument('paths');
|
||||||
|
$in_rev = $this->getArgument('rev');
|
||||||
|
|
||||||
foreach ($paths as $path => $status) {
|
if ($in_rev) {
|
||||||
if (is_dir($path)) {
|
// Although selectPathsForWorkflow() may set this, we want to set it
|
||||||
unset($paths[$path]);
|
// explicitly so we blame against the correct relative commit.
|
||||||
}
|
$repository_api->parseRelativeLocalCommit(array($in_rev));
|
||||||
if ($status & ArcanistRepositoryAPI::FLAG_UNTRACKED) {
|
|
||||||
unset($paths[$path]);
|
|
||||||
}
|
|
||||||
if ($status & ArcanistRepositoryAPI::FLAG_ADDED) {
|
|
||||||
unset($paths[$path]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$paths = array_keys($paths);
|
$paths = $this->selectPathsForWorkflow(
|
||||||
|
$in_paths,
|
||||||
|
$in_rev,
|
||||||
|
ArcanistRepositoryAPI::FLAG_UNTRACKED |
|
||||||
|
ArcanistRepositoryAPI::FLAG_ADDED);
|
||||||
|
|
||||||
if (!$paths) {
|
if (!$paths) {
|
||||||
throw new ArcanistNoEffectException(
|
throw new ArcanistNoEffectException(
|
||||||
|
@ -83,10 +100,15 @@ EOTEXT
|
||||||
|
|
||||||
$covers = array();
|
$covers = array();
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
|
if (is_dir($repository_api->getPath($path))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$lines = $this->getChangedLines($path, 'cover');
|
$lines = $this->getChangedLines($path, 'cover');
|
||||||
if (!$lines) {
|
if (!$lines) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$blame = $repository_api->getBlame($path);
|
$blame = $repository_api->getBlame($path);
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
list($author, $revision) = idx($blame, $line, array(null, null));
|
list($author, $revision) = idx($blame, $line, array(null, null));
|
||||||
|
|
Loading…
Reference in a new issue