From 4ea25d16ac38fff2cb81fdff8aaec3e64d3a3693 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 14 Aug 2020 09:04:03 +0200 Subject: [PATCH 1/2] Add option to get the remote url --- src/GitRepository.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/GitRepository.php b/src/GitRepository.php index 66d67b2..e57e31b 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -542,6 +542,21 @@ public function setRemoteUrl($name, $url, array $params = NULL) } + /** + * Get remote repository URL + * @return string + * @throws GitException + */ + public function getRemoteUrl() + { + $this->begin(); + $remoteUrl = exec('git remote get-url origin'); + $this->end(); + + return $remoteUrl; + } + + /** * @param string|string[] * @return string[] returns output From 61fb7f75eeb974ec657606491152f931458ce152 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 14 Aug 2020 09:23:07 +0200 Subject: [PATCH 2/2] Add option to fetch default branch name --- src/GitRepository.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/GitRepository.php b/src/GitRepository.php index e57e31b..01898e7 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -557,6 +557,21 @@ public function getRemoteUrl() } + /** + * Get the default branch name + * @return string + * @throws GitException + */ + public function getDefaultBranchName($remote = false) + { + $this->begin(); + $branchName = exec('git symbolic-ref --short ' . ($remote ? 'refs/remotes/origin/HEAD' : 'HEAD')); + $this->end(); + + return $branchName; + } + + /** * @param string|string[] * @return string[] returns output