summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-11-16 13:20:52 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-12-08 19:28:55 +0100
commit38348aa1215daa2393b7d488c1ca8926d67dc09e (patch)
tree6514a61b774ffd4a150e605853b50275cb7aa88e
parent2b4883e05e59eff08088e378bf3061d9d8da13dd (diff)
downloadgitlab-ce-38348aa1215daa2393b7d488c1ca8926d67dc09e.tar.gz
Remove Gitlab::Git::Ref#full_ref
-rw-r--r--app/models/project.rb12
-rw-r--r--lib/gitlab/git.rb4
-rw-r--r--lib/gitlab/git/branch.rb4
-rw-r--r--lib/gitlab/git/ref.rb4
-rw-r--r--lib/gitlab/git/tag.rb4
-rw-r--r--spec/lib/gitlab/git/branch_spec.rb12
-rw-r--r--spec/lib/gitlab/git/tag_spec.rb13
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