Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
Show First 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | $futures = array( | ||||
$uncommitted_future, | $uncommitted_future, | ||||
$untracked_future, | $untracked_future, | ||||
// NOTE: `git diff-files` races with each of these other commands | // NOTE: `git diff-files` races with each of these other commands | ||||
// internally, and resolves with inconsistent results if executed | // internally, and resolves with inconsistent results if executed | ||||
// in parallel. To work around this, DO NOT run it at the same time. | // in parallel. To work around this, DO NOT run it at the same time. | ||||
// After the other commands exit, we can start the `diff-files` command. | // After the other commands exit, we can start the `diff-files` command. | ||||
); | ); | ||||
id(new FutureIterator($futures))->resolveAll(); | (new FutureIterator($futures))->resolveAll(); | ||||
// We're clear to start the `git diff-files` now. | // We're clear to start the `git diff-files` now. | ||||
$unstaged_future->start(); | $unstaged_future->start(); | ||||
$result = new PhutilArrayWithDefaultValue(); | $result = new PhutilArrayWithDefaultValue(); | ||||
list($stdout) = $uncommitted_future->resolvex(); | list($stdout) = $uncommitted_future->resolvex(); | ||||
$uncommitted_files = $this->parseGitRawDiff($stdout); | $uncommitted_files = $this->parseGitRawDiff($stdout); | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | foreach ($lines as $line) { | ||||
} | } | ||||
} | } | ||||
return $files; | return $files; | ||||
} | } | ||||
public function getAllFiles() { | public function getAllFiles() { | ||||
$future = $this->buildLocalFuture(array('ls-files -z')); | $future = $this->buildLocalFuture(array('ls-files -z')); | ||||
return id(new LinesOfALargeExecFuture($future)) | return (new LinesOfALargeExecFuture($future)) | ||||
->setDelimiter("\0"); | ->setDelimiter("\0"); | ||||
} | } | ||||
public function getChangedFiles($since_commit) { | public function getChangedFiles($since_commit) { | ||||
list($stdout) = $this->execxLocal( | list($stdout) = $this->execxLocal( | ||||
'diff --raw %s --', | 'diff --raw %s --', | ||||
gitsprintf('%s', $since_commit)); | gitsprintf('%s', $since_commit)); | ||||
return $this->parseGitRawDiff($stdout); | return $this->parseGitRawDiff($stdout); | ||||
▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | public function isGitLFSWorkingCopy() { | ||||
// If it exits with an error, we're in trouble. | // If it exits with an error, we're in trouble. | ||||
$future = $this->buildLocalFuture( | $future = $this->buildLocalFuture( | ||||
array( | array( | ||||
'ls-files -z -- %s', | 'ls-files -z -- %s', | ||||
':(attr:filter=lfs)', | ':(attr:filter=lfs)', | ||||
)); | )); | ||||
$lfs_list = id(new LinesOfALargeExecFuture($future)) | $lfs_list = (new LinesOfALargeExecFuture($future)) | ||||
->setDelimiter("\0"); | ->setDelimiter("\0"); | ||||
try { | try { | ||||
foreach ($lfs_list as $lfs_file) { | foreach ($lfs_list as $lfs_file) { | ||||
// We have our answer, so we can throw the subprocess away. | // We have our answer, so we can throw the subprocess away. | ||||
$future->resolveKill(); | $future->resolveKill(); | ||||
return true; | return true; | ||||
} | } | ||||
Show All 33 Lines | protected function newLandEngine() { | ||||
return new ArcanistGitLandEngine(); | return new ArcanistGitLandEngine(); | ||||
} | } | ||||
protected function newWorkEngine() { | protected function newWorkEngine() { | ||||
return new ArcanistGitWorkEngine(); | return new ArcanistGitWorkEngine(); | ||||
} | } | ||||
public function newLocalState() { | public function newLocalState() { | ||||
return id(new ArcanistGitLocalState()) | return (new ArcanistGitLocalState()) | ||||
->setRepositoryAPI($this); | ->setRepositoryAPI($this); | ||||
} | } | ||||
public function readRawCommit($hash) { | public function readRawCommit($hash) { | ||||
list($stdout) = $this->execxLocal( | list($stdout) = $this->execxLocal( | ||||
'cat-file commit -- %s', | 'cat-file commit -- %s', | ||||
$hash); | $hash); | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0