mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Improve getting Git author
Summary: It has one more than source, see http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html#_commit_information. Also 'user.name' may not be set at all. Also `git config` returns non-zero for non-existing value. Test Plan: var_dump($api->getAuthor()); Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4053
This commit is contained in:
parent
9917c1f06a
commit
6cb8d483b2
1 changed files with 4 additions and 3 deletions
|
@ -473,15 +473,16 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGitConfig($key, $default = null) {
|
public function getGitConfig($key, $default = null) {
|
||||||
list($stdout) = $this->execxLocal('config %s', $key);
|
list($err, $stdout) = $this->execManualLocal('config %s', $key);
|
||||||
if ($stdout == '') {
|
if ($err) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
return rtrim($stdout);
|
return rtrim($stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthor() {
|
public function getAuthor() {
|
||||||
return $this->getGitConfig('user.name');
|
list($stdout) = $this->execxLocal('var GIT_AUTHOR_IDENT');
|
||||||
|
return preg_replace('/\s+<.*/', '', rtrim($stdout, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addToCommit(array $paths) {
|
public function addToCommit(array $paths) {
|
||||||
|
|
Loading…
Reference in a new issue