Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
| Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | if ($this->repositoryHasNoCommits) { | ||||
| '%s --not %s', | '%s --not %s', | ||||
| $this->getHeadCommit(), | $this->getHeadCommit(), | ||||
| $this->getBaseCommit()); | $this->getBaseCommit()); | ||||
| } | } | ||||
| // NOTE: Windows escaping of "%" symbols apparently is inherently broken; | // NOTE: Windows escaping of "%" symbols apparently is inherently broken; | ||||
| // when passed through escapeshellarg() they are replaced with spaces. | // when passed through escapeshellarg() they are replaced with spaces. | ||||
| // TODO: Learn how cmd.exe works and find some clever workaround? | // TODO: Learn how cmd.exe works and find some clever workaround? | ||||
Lint: TODO Comment: This comment has a TODO. | |||||
| // 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() | phutil_is_windows() | ||||
| ? 'log %C --format=%C --' | ? 'log %C --format=%C --' | ||||
| : 'log %C --format=%s --', | : 'log %C --format=%s --', | ||||
| $against, | $against, | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if (!$default_relative) { | ||||
| "it is the merge-base of '%s' and HEAD, as specified in '%s'.", | "it is the merge-base of '%s' and HEAD, as specified in '%s'.", | ||||
| $default_relative, | $default_relative, | ||||
| '.git/arc/default-relative-commit')); | '.git/arc/default-relative-commit')); | ||||
| } | } | ||||
| } | } | ||||
| if (!$default_relative) { | if (!$default_relative) { | ||||
| // TODO: Remove the history lesson soon. | // TODO: Remove the history lesson soon. | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| echo phutil_console_format( | echo phutil_console_format( | ||||
| "<bg:green>** %s **</bg>\n\n", | "<bg:green>** %s **</bg>\n\n", | ||||
| pht('Select a Default Commit Range')); | pht('Select a Default Commit Range')); | ||||
| echo phutil_console_wrap( | echo phutil_console_wrap( | ||||
| pht( | pht( | ||||
| "You're running a command which operates on a range of revisions ". | "You're running a command which operates on a range of revisions ". | ||||
| "(usually, from some revision to HEAD) but have not specified the ". | "(usually, from some revision to HEAD) but have not specified the ". | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
| } | } | ||||
| private function getDiffBaseOptions() { | private function getDiffBaseOptions() { | ||||
| $options = array( | $options = array( | ||||
| // Disable external diff drivers, like graphical differs, since Arcanist | // Disable external diff drivers, like graphical differs, since Arcanist | ||||
| // needs to capture the diff text. | // needs to capture the diff text. | ||||
| '--no-ext-diff', | '--no-ext-diff', | ||||
| // Disable textconv so we treat binary files as binary, even if they have | // Disable textconv so we treat binary files as binary, even if they have | ||||
| // an alternative textual representation. TODO: Ideally, Differential | // an alternative textual representation. TODO: Ideally, Differential | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| // would ship up the binaries for 'arc patch' but display the textconv | // would ship up the binaries for 'arc patch' but display the textconv | ||||
| // output in the visual diff. | // output in the visual diff. | ||||
| '--no-textconv', | '--no-textconv', | ||||
| // Provide a standard view of submodule changes; the 'log' and 'diff' | // Provide a standard view of submodule changes; the 'log' and 'diff' | ||||
| // values do not parse by the diff parser. | // values do not parse by the diff parser. | ||||
| '--submodule=short', | '--submodule=short', | ||||
| ); | ); | ||||
| return implode(' ', $options); | return implode(' ', $options); | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public function getRemoteURI() { | ||||
| if (version_compare($version, '1.7.5', '>=')) { | if (version_compare($version, '1.7.5', '>=')) { | ||||
| list($stdout) = $this->execxLocal('ls-remote --get-url %s', $remote); | list($stdout) = $this->execxLocal('ls-remote --get-url %s', $remote); | ||||
| } else { | } else { | ||||
| list($stdout) = $this->execxLocal('config %s', "remote.{$remote}.url"); | list($stdout) = $this->execxLocal('config %s', "remote.{$remote}.url"); | ||||
| } | } | ||||
| $uri = rtrim($stdout); | $uri = rtrim($stdout); | ||||
| // ls-remote echos the remote name (ie 'origin') if no remote URI is found | // ls-remote echos the remote name (ie 'origin') if no remote URI is found | ||||
| // TODO: In 2.7.0 (circa 2016) git introduced `git remote get-url` | // TODO: In 2.7.0 (circa 2016) git introduced `git remote get-url` | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| // with saner error handling. | // with saner error handling. | ||||
| if (!$uri || $uri === $remote) { | if (!$uri || $uri === $remote) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $uri; | return $uri; | ||||
| } | } | ||||
| public function getSourceControlPath() { | public function getSourceControlPath() { | ||||
| // TODO: Try to get something useful here. | // TODO: Try to get something useful here. | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| return null; | return null; | ||||
| } | } | ||||
| public function getGitCommitLog() { | public function getGitCommitLog() { | ||||
| $relative = $this->getBaseCommit(); | $relative = $this->getBaseCommit(); | ||||
| if ($this->repositoryHasNoCommits) { | if ($this->repositoryHasNoCommits) { | ||||
| // No commits yet. | // No commits yet. | ||||
| return ''; | return ''; | ||||
| ▲ Show 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | foreach ($branches as $branch) { | ||||
| ->setRefName($branch['ref']) | ->setRefName($branch['ref']) | ||||
| ->setIsCurrentBranch($branch['current']) | ->setIsCurrentBranch($branch['current']) | ||||
| ->attachCommitRef($commit_ref); | ->attachCommitRef($commit_ref); | ||||
| } | } | ||||
| return $refs; | return $refs; | ||||
| } | } | ||||
| public function getWorkingCopyRevision() { | public function getBaseCommitRef() { | ||||
| list($stdout) = $this->execxLocal('rev-parse HEAD'); | $base_commit = $this->getSourceControlBaseRevision(); | ||||
| return rtrim($stdout, "\n"); | $base_message = $this->getCommitMessage($base_commit); | ||||
| // TODO: We should also pull the tree hash. | |||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| return $this->newCommitRef() | |||||
| ->setCommitHash($base_commit) | |||||
| ->attachMessage($base_message); | |||||
| } | } | ||||
| public function getUnderlyingWorkingCopyRevision() { | public function getWorkingCopyRevision() { | ||||
| list($err, $stdout) = $this->execManualLocal('svn find-rev HEAD'); | list($stdout) = $this->execxLocal('rev-parse HEAD'); | ||||
| if (!$err && $stdout) { | |||||
| return rtrim($stdout, "\n"); | return rtrim($stdout, "\n"); | ||||
| } | } | ||||
| return $this->getWorkingCopyRevision(); | |||||
| } | |||||
| public function isHistoryDefaultImmutable() { | public function isHistoryDefaultImmutable() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function supportsAmend() { | public function supportsAmend() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines | |||||
This comment has a TODO.