diff --git a/src/GitRepository.php b/src/GitRepository.php index 2ef6f83..1fa674c 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -620,4 +620,17 @@ protected function run(...$args) return $result; } + /** + * Returns last commit ID on remote + * `git log origin master --pretty=format:"%H" -n 1` + * @return CommitId + * @throws GitException + */ + + public function getLastRemoteCommitId($remote) + { + $result = $this->run('log', $remote, '--pretty=format:%H', '-n', '1'); + $lastLine = $result->getOutputLastLine(); + return new CommitId((string) $lastLine); + } }