Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
96a0a8cf
Commit
96a0a8cf
authored
Nov 16, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use strings instead of Gitlab::Git::Ref
parent
35b3392e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
36 deletions
+19
-36
app/models/project.rb
app/models/project.rb
+9
-8
spec/models/project_spec.rb
spec/models/project_spec.rb
+10
-28
No files found.
app/models/project.rb
View file @
96a0a8cf
...
...
@@ -1167,11 +1167,11 @@ class Project < ActiveRecord::Base
if
tag_exists
&&
branch_exists
nil
elsif
tag_exists
repository
.
find_tag
(
ref
)
Gitlab
::
Git
::
TAG_REF_PREFIX
+
ref
elsif
branch_exists
repository
.
find_branch
(
ref
)
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
else
re
pository
.
find_ref
(
ref
)
re
f
end
end
...
...
@@ -1755,11 +1755,12 @@ class Project < ActiveRecord::Base
resolved_ref
=
resolve_ref
(
ref
)
return
false
unless
resolved_ref
case
resolved_ref
when
Gitlab
::
Git
::
Branch
ProtectedBranch
.
protected?
(
self
,
resolved_ref
.
name
)
when
Gitlab
::
Git
::
Tag
ProtectedTag
.
protected?
(
self
,
resolved_ref
.
name
)
ref_name
=
Gitlab
::
Git
.
ref_name
(
resolved_ref
)
if
Gitlab
::
Git
.
branch_ref?
(
resolved_ref
)
ProtectedBranch
.
protected?
(
self
,
ref_name
)
elsif
Gitlab
::
Git
.
tag_ref?
(
resolved_ref
)
ProtectedTag
.
protected?
(
self
,
ref_name
)
end
end
...
...
spec/models/project_spec.rb
View file @
96a0a8cf
...
...
@@ -2580,7 +2580,7 @@ describe Project do
end
context
'when the ref is not protected'
do
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:ref
)
{
'refs/heads/master'
}
before
do
stub_application_setting
(
...
...
@@ -2593,7 +2593,7 @@ describe Project do
end
context
'when the ref is a protected branch'
do
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:ref
)
{
'refs/heads/master'
}
before
do
create
(
:protected_branch
,
name:
'master'
,
project:
project
)
...
...
@@ -2605,7 +2605,7 @@ describe Project do
end
context
'when the ref is a protected tag'
do
let
(
:ref
)
{
project
.
repository
.
find_tag
(
'v1.0.0'
)
}
let
(
:ref
)
{
'refs/tags/v1.0.0'
}
before
do
create
(
:protected_tag
,
name:
'v1.0.0'
,
project:
project
)
...
...
@@ -2802,20 +2802,10 @@ describe Project do
subject
{
project
.
resolve_ref
(
ref
)
}
context
'when ref is full ref'
do
context
'when ref exists'
do
let
(
:ref
)
{
'refs/heads/master'
}
let
(
:ref
)
{
'refs/heads/master'
}
it
'returns a ref'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Ref
)
end
end
context
'when ref does not exist'
do
let
(
:ref
)
{
'refs/tags/doesnotexist'
}
it
'returns nil'
do
is_expected
.
to
eq
(
nil
)
end
it
'returns the ref'
do
is_expected
.
to
eq
(
ref
)
end
end
...
...
@@ -2838,12 +2828,8 @@ describe Project do
project
.
repository
.
add_tag
(
project
.
creator
,
ref
,
'master'
)
end
it
'returns a tag'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Tag
)
end
it
'returns the correct tag'
do
expect
(
subject
.
name
).
to
eq
(
ref
)
it
'returns the tag ref'
do
is_expected
.
to
eq
(
"refs/tags/
#{
ref
}
"
)
end
end
...
...
@@ -2852,12 +2838,8 @@ describe Project do
project
.
repository
.
add_branch
(
project
.
creator
,
ref
,
'master'
)
end
it
'returns a branch'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Branch
)
end
it
'returns the correct branch'
do
expect
(
subject
.
name
).
to
eq
(
ref
)
it
'returns the branch ref'
do
is_expected
.
to
eq
(
"refs/heads/
#{
ref
}
"
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment