Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistCoverWorkflow.php
| Show All 25 Lines | |||||
| EOTEXT | EOTEXT | ||||
| ); | ); | ||||
| } | } | ||||
| public function getArguments() { | public function getArguments() { | ||||
| return array( | return array( | ||||
| 'rev' => array( | 'rev' => array( | ||||
| 'param' => 'revision', | 'param' => 'revision', | ||||
| 'help' => 'Cover changes since a specific revision.', | 'help' => pht('Cover changes since a specific revision.'), | ||||
| 'supports' => array( | 'supports' => array( | ||||
| 'git', | 'git', | ||||
| 'hg', | 'hg', | ||||
| ), | ), | ||||
| 'nosupport' => array( | 'nosupport' => array( | ||||
| 'svn' => 'cover does not currently support --rev in svn.', | 'svn' => pht('cover does not currently support %s in svn.', '--rev'), | ||||
| ), | ), | ||||
| ), | ), | ||||
| '*' => 'paths', | '*' => 'paths', | ||||
| ); | ); | ||||
| } | } | ||||
| public function requiresWorkingCopy() { | public function requiresWorkingCopy() { | ||||
| return true; | return true; | ||||
| Show All 24 Lines | public function run() { | ||||
| $paths = $this->selectPathsForWorkflow( | $paths = $this->selectPathsForWorkflow( | ||||
| $in_paths, | $in_paths, | ||||
| $in_rev, | $in_rev, | ||||
| ArcanistRepositoryAPI::FLAG_UNTRACKED | | ArcanistRepositoryAPI::FLAG_UNTRACKED | | ||||
| ArcanistRepositoryAPI::FLAG_ADDED); | ArcanistRepositoryAPI::FLAG_ADDED); | ||||
| if (!$paths) { | if (!$paths) { | ||||
| throw new ArcanistNoEffectException( | throw new ArcanistNoEffectException( | ||||
| "You're covered, you didn't change anything."); | pht("You're covered, you didn't change anything.")); | ||||
| } | } | ||||
| $covers = array(); | $covers = array(); | ||||
| foreach ($paths as $path) { | foreach ($paths as $path) { | ||||
| if (is_dir($repository_api->getPath($path))) { | if (is_dir($repository_api->getPath($path))) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Show All 31 Lines | if (count($covers)) { | ||||
| $line_noun = pht( | $line_noun = pht( | ||||
| '%s line(s)', | '%s line(s)', | ||||
| new PhutilNumber(count($info['lines']))); | new PhutilNumber(count($info['lines']))); | ||||
| $lines = $this->readableSequenceFromLineNumbers($info['lines']); | $lines = $this->readableSequenceFromLineNumbers($info['lines']); | ||||
| echo " {$file}: {$line_noun} {$lines}\n"; | echo " {$file}: {$line_noun} {$lines}\n"; | ||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| echo "You're covered, your changes didn't touch anyone else's code.\n"; | echo pht( | ||||
| "You're covered, your changes didn't touch anyone else's code.\n"); | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| private function readableSequenceFromLineNumbers(array $array) { | private function readableSequenceFromLineNumbers(array $array) { | ||||
| $sequence = array(); | $sequence = array(); | ||||
| $last = null; | $last = null; | ||||
| Show All 34 Lines | |||||