summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-04-24 09:03:54 +0700
committerShinya Maeda <shinya@gitlab.com>2019-04-24 09:03:54 +0700
commit48c5303012e826100fefcf5521fb0385647499f9 (patch)
tree5c8858c4b466ccc43cd65df3b14e6866bd4f7075
parent7a742a2098aee90eb5398235c6e27c525b07432a (diff)
downloadgitlab-ce-introcude-generic-ref-name-for-variables.tar.gz
Generic ref name for pipeline variablesintrocude-generic-ref-name-for-variables
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/concerns/has_ref.rb10
-rw-r--r--app/models/deployment.rb3
4 files changed, 13 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e5236051118..286f47532f6 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -50,7 +50,7 @@ module Ci
delegate :gitlab_deploy_token, to: :project
delegate :trigger_short_token, to: :trigger_request, allow_nil: true
delegate :merge_request_event?, :merge_request_ref?,
- :legacy_detached_merge_request_pipeline?, to: :pipeline
+ :legacy_detached_merge_request_pipeline?, :generic_ref_name, to: :pipeline
##
# Since Gitlab 11.5, deployments records started being created right after
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index b8edaf82c3d..7d8e078ee67 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -797,7 +797,7 @@ module Ci
# In order to do that, we have to update GitLab-Runner's source pulling
# logic.
# See https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/1092
- Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s
+ Gitlab::Git::BRANCH_REF_PREFIX + generic_ref_name.to_s
else
super
end
diff --git a/app/models/concerns/has_ref.rb b/app/models/concerns/has_ref.rb
index 413cd36dcaa..c17219f3fe0 100644
--- a/app/models/concerns/has_ref.rb
+++ b/app/models/concerns/has_ref.rb
@@ -23,6 +23,14 @@ module HasRef
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def ref_slug
- Gitlab::Utils.slugify(ref.to_s)
+ Gitlab::Utils.slugify(generic_ref_name.to_s)
+ end
+
+ def generic_ref_name
+ if merge_request_ref?
+ merge_request.source_branch
+ else
+ ref
+ end
end
end
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index d847a0a11e4..588b0b61ff0 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -4,6 +4,7 @@ class Deployment < ApplicationRecord
include AtomicInternalId
include IidRoutes
include AfterCommitQueue
+ include HasRef
belongs_to :project, required: true
belongs_to :environment, required: true
@@ -87,7 +88,7 @@ class Deployment < ApplicationRecord
end
def create_ref
- project.repository.create_ref(ref, ref_path)
+ project.repository.create_ref(generic_ref_name, ref_path)
end
def invalidate_cache