Commit 007ac501 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use current_head to avoid missing branch.

See:
https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/79125195
parent 7dbdc0ab
......@@ -193,8 +193,9 @@ module EESpecificCheck
end
def with_detached_head(target_head)
# So that we could switch back
head = current_branch
# So that we could switch back. CI sometimes doesn't have the branch,
# so we don't use current_branch here
head = current_head
# Use detached HEAD so that we don't update HEAD
run_git_command("checkout -f #{target_head}")
......@@ -263,6 +264,10 @@ module EESpecificCheck
@ce_repo_url ||= ENV.fetch('CI_REPOSITORY_URL', 'https://gitlab.com/gitlab-org/gitlab-ce.git').sub('gitlab-ee', 'gitlab-ce')
end
def current_head
@current_head ||= ENV.fetch('CI_COMMIT_SHA', current_branch)
end
def current_branch
@current_branch ||= ENV.fetch('CI_COMMIT_REF_NAME', `git rev-parse --abbrev-ref HEAD`).strip
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment