Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
Show All 11 Lines | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
* For the repository's initial commit, 'git diff HEAD^' and similar do | * For the repository's initial commit, 'git diff HEAD^' and similar do | ||||
* not work. Using this instead does work; it is the hash of the empty tree. | * not work. Using this instead does work; it is the hash of the empty tree. | ||||
*/ | */ | ||||
const GIT_MAGIC_ROOT_COMMIT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; | const GIT_MAGIC_ROOT_COMMIT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; | ||||
private $symbolicHeadCommit; | private $symbolicHeadCommit; | ||||
private $resolvedHeadCommit; | private $resolvedHeadCommit; | ||||
public static function newHookAPI($root) { | |||||
return new ArcanistGitAPI($root); | |||||
} | |||||
protected function buildLocalFuture(array $argv) { | protected function buildLocalFuture(array $argv) { | ||||
$argv[0] = 'git '.$argv[0]; | $argv[0] = 'git '.$argv[0]; | ||||
$future = newv('ExecFuture', $argv); | $future = newv('ExecFuture', $argv); | ||||
$future->setCWD($this->getPath()); | $future->setCWD($this->getPath()); | ||||
return $future; | return $future; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 667 Lines • ▼ Show 20 Lines | if ($message === null) { | ||||
'commit --amend --allow-empty -F %s', | 'commit --amend --allow-empty -F %s', | ||||
$tmp_file); | $tmp_file); | ||||
} | } | ||||
$this->reloadWorkingCopy(); | $this->reloadWorkingCopy(); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPreReceiveHookStatus($old_ref, $new_ref) { | |||||
$options = $this->getDiffBaseOptions(); | |||||
list($stdout) = $this->execxLocal( | |||||
"diff {$options} --raw %s %s --", | |||||
$old_ref, | |||||
$new_ref); | |||||
return $this->parseGitStatus($stdout, $full = true); | |||||
} | |||||
private function parseGitStatus($status, $full = false) { | private function parseGitStatus($status, $full = false) { | ||||
static $flags = array( | static $flags = array( | ||||
'A' => self::FLAG_ADDED, | 'A' => self::FLAG_ADDED, | ||||
'M' => self::FLAG_MODIFIED, | 'M' => self::FLAG_MODIFIED, | ||||
'D' => self::FLAG_DELETED, | 'D' => self::FLAG_DELETED, | ||||
); | ); | ||||
$status = trim($status); | $status = trim($status); | ||||
▲ Show 20 Lines • Show All 496 Lines • Show Last 20 Lines |