summaryrefslogtreecommitdiff
path: root/app/presenters
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-02-14 15:25:10 +0900
committerShinya Maeda <shinya@gitlab.com>2019-02-25 13:40:15 +0900
commit7ba89e4ac40afb4ed16865b0c3ac286217c2d64c (patch)
tree7a222f0b1904c43e96f21b36c05d843855aea27b /app/presenters
parent9428db8ec834ada489c921ba1025b16af97e827f (diff)
downloadgitlab-ce-7ba89e4ac40afb4ed16865b0c3ac286217c2d64c.tar.gz
Expose refspec and depth to runner
fix fix and fix Allow full ref specification for pipeline creation Add spec Support backward compatibility Use ref path Runner feature flag Simplify the things Support fork workflow (Public only) Expose ref spec Use refspec Glooming Decouple unrelated changes Add changelog Revert unrelated file Decouple unnecessary Add spec Use refspecs Fix changelog Simplify Fix coding offence Fix a ok ok ok ok ok a a Fix Add workaround for ignore_column Fix git depth Fix coding offence Fix spec Simplify more Do not set ignored column Fix tests Fix pipeline Fix spec fix fixture yes Revert nonsense fix Revert more ok Decouple mr pipelines fix spev Remove unrelated changes
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/ci/build_runner_presenter.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb
index 300f85e1e9d..d60281c8a0b 100644
--- a/app/presenters/ci/build_runner_presenter.rb
+++ b/app/presenters/ci/build_runner_presenter.rb
@@ -2,6 +2,11 @@
module Ci
class BuildRunnerPresenter < SimpleDelegator
+ include Gitlab::Utils::StrongMemoize
+
+ RUNNER_REMOTE_TAG_PREFIX = 'refs/tags/'.freeze
+ RUNNER_REMOTE_BRANCH_PREFIX = 'refs/remotes/origin/'.freeze
+
def artifacts
return unless options[:artifacts]
@@ -11,6 +16,35 @@ module Ci
list.flatten.compact
end
+ def ref_type
+ if tag
+ 'tag'
+ else
+ 'branch'
+ end
+ end
+
+ def git_depth
+ strong_memoize(:git_depth) do
+ git_depth = variables&.find { |variable| variable[:key] == 'GIT_DEPTH' }&.dig(:value)
+ git_depth.to_i
+ end
+ end
+
+ def refspecs
+ specs = []
+
+ if git_depth > 0
+ specs << refspec_for_branch(ref) if branch? || merge_request?
+ specs << refspec_for_tag(ref) if tag?
+ else
+ specs << refspec_for_branch
+ specs << refspec_for_tag
+ end
+
+ specs
+ end
+
private
def create_archive(artifacts)
@@ -41,5 +75,13 @@ module Ci
}
end
end
+
+ def refspec_for_branch(ref = '*')
+ "+#{Gitlab::Git::BRANCH_REF_PREFIX}#{ref}:#{RUNNER_REMOTE_BRANCH_PREFIX}#{ref}"
+ end
+
+ def refspec_for_tag(ref = '*')
+ "+#{Gitlab::Git::TAG_REF_PREFIX}#{ref}:#{RUNNER_REMOTE_TAG_PREFIX}#{ref}"
+ end
end
end