From 38348aa1215daa2393b7d488c1ca8926d67dc09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 16 Nov 2018 13:20:52 +0100 Subject: Remove Gitlab::Git::Ref#full_ref --- app/models/project.rb | 12 +++++------- lib/gitlab/git.rb | 4 ++-- lib/gitlab/git/branch.rb | 4 ---- lib/gitlab/git/ref.rb | 4 ---- lib/gitlab/git/tag.rb | 4 ---- spec/lib/gitlab/git/branch_spec.rb | 12 ------------ spec/lib/gitlab/git/tag_spec.rb | 13 ------------- 7 files changed, 7 insertions(+), 46 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index e1acfbe7770..22ce916a36c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1755,13 +1755,11 @@ class Project < ActiveRecord::Base resolved_ref = resolve_ref(ref) return false unless resolved_ref - full_ref = resolved_ref.full_ref - ref_name = resolved_ref.name - - if Gitlab::Git.branch_ref?(full_ref) - ProtectedBranch.protected?(self, ref_name) - elsif Gitlab::Git.tag_ref?(full_ref) - ProtectedTag.protected?(self, ref_name) + case resolved_ref + when Gitlab::Git::Branch + ProtectedBranch.protected?(self, resolved_ref.name) + when Gitlab::Git::Tag + ProtectedTag.protected?(self, resolved_ref.name) end end diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb index 2d950bb151c..f22ac800479 100644 --- a/lib/gitlab/git.rb +++ b/lib/gitlab/git.rb @@ -54,11 +54,11 @@ module Gitlab end def tag_ref?(ref) - ref =~ %r{#{TAG_REF_PREFIX}\w+} + ref =~ /#{TAG_REF_PREFIX}\w+/ end def branch_ref?(ref) - ref =~ %r{#{BRANCH_REF_PREFIX}\w+} + ref =~ /#{BRANCH_REF_PREFIX}\w+/ end def blank_ref?(ref) diff --git a/lib/gitlab/git/branch.rb b/lib/gitlab/git/branch.rb index d25eebd5f47..9447cfa0fb6 100644 --- a/lib/gitlab/git/branch.rb +++ b/lib/gitlab/git/branch.rb @@ -28,10 +28,6 @@ module Gitlab def state active? ? :active : :stale end - - def full_ref - Gitlab::Git::BRANCH_REF_PREFIX + name - end end end end diff --git a/lib/gitlab/git/ref.rb b/lib/gitlab/git/ref.rb index b9c8b7c08e9..eec91194949 100644 --- a/lib/gitlab/git/ref.rb +++ b/lib/gitlab/git/ref.rb @@ -39,10 +39,6 @@ module Gitlab nil end end - - def full_ref - raise NotImplementedError - end end end end diff --git a/lib/gitlab/git/tag.rb b/lib/gitlab/git/tag.rb index ec89bc4f7e6..23d989ff258 100644 --- a/lib/gitlab/git/tag.rb +++ b/lib/gitlab/git/tag.rb @@ -62,10 +62,6 @@ module Gitlab encode! @message end - def full_ref - Gitlab::Git::TAG_REF_PREFIX + name - end - private def message_from_gitaly_tag diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 1b26b5ef7fd..0df282d0ae3 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -124,18 +124,6 @@ describe Gitlab::Git::Branch, :seed_helper do it { expect(repository.branches.size).to eq(SeedRepo::Repo::BRANCHES.size) } - describe '#full_ref' do - subject do - described_class.new(repository, 'master', - repository.commit.sha, - repository.commit).full_ref - end - - it 'returns the full ref' do - is_expected.to eq('refs/heads/master') - end - end - def create_commit params[:message].delete!("\r") Rugged::Commit.create(rugged, params.merge(committer: committer.merge(time: Time.now))) diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb index f5d0b6af6f0..b51e3879f49 100644 --- a/spec/lib/gitlab/git/tag_spec.rb +++ b/spec/lib/gitlab/git/tag_spec.rb @@ -69,17 +69,4 @@ describe Gitlab::Git::Tag, :seed_helper do end end end - - describe '#full_ref' do - subject do - described_class.new(repository, { name: 'master', - target: repository.commit.sha, - target_commit: repository.commit }) - .full_ref - end - - it 'returns the full ref' do - is_expected.to eq('refs/tags/master') - end - end end -- cgit v1.2.1