Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2021-06-16 17:05:29 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2021-06-16 18:14:27 +0300
commite63b471d60ff51938b3b428910a2880a5da01006 (patch)
tree829d3c88bef33fd308db18cf24325d9363ccf7cd /lib
parent8d7b1825f9b3af99c21c2c6e5be723f882baff46 (diff)
Use the API to fetch the remote default branch
Diffstat (limited to 'lib')
-rw-r--r--lib/task_helpers.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/task_helpers.rb b/lib/task_helpers.rb
index 5614ef37..358169b4 100644
--- a/lib/task_helpers.rb
+++ b/lib/task_helpers.rb
@@ -64,6 +64,10 @@ def chart_version(gitlab_version)
config.fetch(gitlab_version)
end
-def default_branch(remote_url)
- `git remote show #{remote_url} | grep 'HEAD branch' | cut -d' ' -f5`.tr("\n", '')
+def default_branch(repo)
+ # Get the URL-encoded path of the project
+ # https://docs.gitlab.com/ee/api/README.html#namespaced-path-encoding
+ url_encoded_path = repo.sub('https://gitlab.com/', '').sub('.git', '').gsub('/', '%2F')
+
+ `curl https://gitlab.com/api/v4/projects/#{url_encoded_path} | jq --raw-output .default_branch`.tr("\n", '')
end