1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 08:12:40 +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:
slawekbiel 2011-04-27 14:10:19 -07:00
parent 8ffba323ea
commit 8332d86ad2

View file

@ -147,10 +147,20 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI {
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(
'(cd %s; git rev-parse HEAD)',
$this->getPath());
'(cd %s; git rev-parse %s HEAD)',
$this->getPath(),
$flags);
return rtrim($stdout, "\n");
}