diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-11-10 14:34:53 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-12-08 19:25:44 +0100 |
commit | 1bf580688890a3b13e7ac0468f29108dafe08f9e (patch) | |
tree | 634f058f9c005e1b15d5df88d14b0d25bacb40e4 /app/models/concerns | |
parent | b278d886ba65e2d3d438352b6243cd33b1ba4636 (diff) | |
download | gitlab-ce-1bf580688890a3b13e7ac0468f29108dafe08f9e.tar.gz |
Use full ref when possible to avoid ambiguity
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/has_ref.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/concerns/has_ref.rb b/app/models/concerns/has_ref.rb new file mode 100644 index 00000000000..79816841f7f --- /dev/null +++ b/app/models/concerns/has_ref.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module HasRef + extend ActiveSupport::Concern + + def branch? + !tag? + end + + private + + def git_ref + if branch? + Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s + elsif tag? + Gitlab::Git::TAG_REF_PREFIX + ref.to_s + else + raise ArgumentError, 'Invalid pipeline type!' + end + end +end |