Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
| Show All 22 Lines | protected function buildLocalFuture(array $argv) { | ||||
| $future = newv('ExecFuture', $argv); | $future = newv('ExecFuture', $argv); | ||||
| $future->setCWD($this->getPath()); | $future->setCWD($this->getPath()); | ||||
| return $future; | return $future; | ||||
| } | } | ||||
| public function execPassthru($pattern /* , ... */) { | public function execPassthru($pattern /* , ... */) { | ||||
| $args = func_get_args(); | $args = func_get_args(); | ||||
| static $git = null; | $args[0] = 'git '.$args[0]; | ||||
| if ($git === null) { | |||||
| if (phutil_is_windows()) { | |||||
| // NOTE: On Windows, phutil_passthru() uses 'bypass_shell' because | |||||
| // everything goes to hell if we don't. We must provide an absolute | |||||
| // path to Git for this to work properly. | |||||
| $git = Filesystem::resolveBinary('git'); | |||||
| $git = csprintf('%s', $git); | |||||
| } else { | |||||
| $git = 'git'; | |||||
| } | |||||
| } | |||||
| $args[0] = $git.' '.$args[0]; | |||||
| return call_user_func_array('phutil_passthru', $args); | return call_user_func_array('phutil_passthru', $args); | ||||
| } | } | ||||
| public function getSourceControlSystemName() { | public function getSourceControlSystemName() { | ||||
| return 'git'; | return 'git'; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if ($this->repositoryHasNoCommits) { | ||||
| } | } | ||||
| $against = csprintf( | $against = csprintf( | ||||
| '%s --not %s', | '%s --not %s', | ||||
| $this->getHeadCommit(), | $this->getHeadCommit(), | ||||
| $this->getBaseCommit()); | $this->getBaseCommit()); | ||||
| } | } | ||||
| // NOTE: Windows escaping of "%" symbols apparently is inherently broken; | |||||
| // when passed through escapeshellarg() they are replaced with spaces. | |||||
| // TODO: Learn how cmd.exe works and find some clever workaround? | |||||
| // NOTE: If we use "%x00", output is truncated in Windows. | // NOTE: If we use "%x00", output is truncated in Windows. | ||||
| list($info) = $this->execxLocal( | list($info) = $this->execxLocal( | ||||
| phutil_is_windows() | 'log %C --format=%s --', | ||||
| ? 'log %C --format=%C --' | |||||
| : 'log %C --format=%s --', | |||||
| $against, | $against, | ||||
| // NOTE: "%B" is somewhat new, use "%s%n%n%b" instead. | // NOTE: "%B" is somewhat new, use "%s%n%n%b" instead. | ||||
| '%H%x01%T%x01%P%x01%at%x01%an%x01%aE%x01%s%x01%s%n%n%b%x02'); | '%H%x01%T%x01%P%x01%at%x01%an%x01%aE%x01%s%x01%s%n%n%b%x02'); | ||||
| $commits = array(); | $commits = array(); | ||||
| $info = trim($info, " \n\2"); | $info = trim($info, " \n\2"); | ||||
| if (!strlen($info)) { | if (!strlen($info)) { | ||||
| ▲ Show 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
| } | } | ||||
| public function getCanonicalRevisionName($string) { | public function getCanonicalRevisionName($string) { | ||||
| $match = null; | $match = null; | ||||
| if (preg_match('/@([0-9]+)$/', $string, $match)) { | if (preg_match('/@([0-9]+)$/', $string, $match)) { | ||||
| $stdout = $this->getHashFromFromSVNRevisionNumber($match[1]); | $stdout = $this->getHashFromFromSVNRevisionNumber($match[1]); | ||||
| } else { | } else { | ||||
| list($stdout) = $this->execxLocal( | list($stdout) = $this->execxLocal( | ||||
| phutil_is_windows() | 'show -s --format=%s %s --', | ||||
| ? 'show -s --format=%C %s --' | |||||
| : 'show -s --format=%s %s --', | |||||
| '%H', | '%H', | ||||
| $string); | $string); | ||||
| } | } | ||||
| return rtrim($stdout); | return rtrim($stdout); | ||||
| } | } | ||||
| private function executeSVNFindRev($input, $vcs) { | private function executeSVNFindRev($input, $vcs) { | ||||
| $match = array(); | $match = array(); | ||||
| ▲ Show 20 Lines • Show All 859 Lines • Show Last 20 Lines | |||||