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
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");
}