mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-13 02:12:41 +01:00
add short option for fetching git revision hash
Summary: Sometimes we need to show abbreviated hashes, passing --short is more reliable than substring of fixed number of characters. Test Plan: - called with and without the parameter, got correct results - Reviewed By: jungejason Reviewers: jungejason CC: jungejason Revert Plan: sure Other Notes: Differential Revision: 170
This commit is contained in:
parent
8ffba323ea
commit
8332d86ad2
1 changed files with 13 additions and 3 deletions
|
@ -147,10 +147,20 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
return rtrim($stdout, "\n");
|
return rtrim($stdout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGitHeadRevision() {
|
/**
|
||||||
|
* Returns the sha1 of the HEAD revision
|
||||||
|
* @param boolean $short whether return the abbreviated or full hash.
|
||||||
|
*/
|
||||||
|
public function getGitHeadRevision($short=false) {
|
||||||
|
if ($short) {
|
||||||
|
$flags = '--short';
|
||||||
|
} else {
|
||||||
|
$flags = '';
|
||||||
|
}
|
||||||
list($stdout) = execx(
|
list($stdout) = execx(
|
||||||
'(cd %s; git rev-parse HEAD)',
|
'(cd %s; git rev-parse %s HEAD)',
|
||||||
$this->getPath());
|
$this->getPath(),
|
||||||
|
$flags);
|
||||||
return rtrim($stdout, "\n");
|
return rtrim($stdout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue