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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config.rb')
-rw-r--r--lib/gitlab/ci/config.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb
index dbb48a81030..d3f030c3b36 100644
--- a/lib/gitlab/ci/config.rb
+++ b/lib/gitlab/ci/config.rb
@@ -99,10 +99,18 @@ module Gitlab
initial_config
end
+ def find_sha(project)
+ branches = project&.repository&.branches || []
+
+ unless branches.empty?
+ project.repository.root_ref_sha
+ end
+ end
+
def build_context(project:, sha:, user:, parent_pipeline:)
Config::External::Context.new(
project: project,
- sha: sha || project&.repository&.root_ref_sha,
+ sha: sha || find_sha(project),
user: user,
parent_pipeline: parent_pipeline,
variables: project&.predefined_variables&.to_runner_variables)