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
dfe7f57e
Commit
dfe7f57e
authored
Nov 28, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Repository#resolve_ref to expand_ref
parent
63da5190
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
app/models/project.rb
app/models/project.rb
+7
-6
app/models/repository.rb
app/models/repository.rb
+1
-3
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+5
-5
No files found.
app/models/project.rb
View file @
dfe7f57e
...
...
@@ -1739,12 +1739,13 @@ class Project < ActiveRecord::Base
def
protected_for?
(
ref
)
return
false
if
ref
.
nil?
||
repository
.
ambiguous_ref?
(
ref
)
resolved_ref
=
repository
.
resolve_ref
(
ref
)
ref_name
=
if
resolved_ref
==
ref
Gitlab
::
Git
.
ref_name
(
resolved_ref
)
else
ref
end
if
Gitlab
::
Git
.
branch_ref?
(
ref
)
||
Gitlab
::
Git
.
tag_ref?
(
ref
)
resolved_ref
=
ref
ref_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
else
resolved_ref
=
repository
.
expand_ref
(
ref
)
ref_name
=
ref
end
if
Gitlab
::
Git
.
branch_ref?
(
resolved_ref
)
ProtectedBranch
.
protected?
(
self
,
ref_name
)
...
...
app/models/repository.rb
View file @
dfe7f57e
...
...
@@ -186,13 +186,11 @@ class Repository
tag_exists?
(
ref
)
&&
branch_exists?
(
ref
)
end
def
resolve
_ref
(
ref
)
def
expand
_ref
(
ref
)
if
tag_exists?
(
ref
)
Gitlab
::
Git
::
TAG_REF_PREFIX
+
ref
elsif
branch_exists?
(
ref
)
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
elsif
Gitlab
::
Git
.
tag_ref?
(
ref
)
||
Gitlab
::
Git
.
branch_ref?
(
ref
)
ref
end
end
...
...
spec/models/repository_spec.rb
View file @
dfe7f57e
...
...
@@ -1032,16 +1032,16 @@ describe Repository do
end
end
describe
'#
resolve
_ref'
do
describe
'#
expand
_ref'
do
let
(
:ref
)
{
'ref'
}
subject
{
repository
.
resolve
_ref
(
ref
)
}
subject
{
repository
.
expand
_ref
(
ref
)
}
context
'when ref is
full ref
'
do
context
'when ref is
not tag or branch name
'
do
let
(
:ref
)
{
'refs/heads/master'
}
it
'returns
the ref
'
do
is_expected
.
to
eq
(
ref
)
it
'returns
nil
'
do
is_expected
.
to
eq
(
nil
)
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