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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b0b5924e
Commit
b0b5924e
authored
Nov 15, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use nil instead of raising AmbiguousRef
parent
855e7c32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
app/models/project.rb
app/models/project.rb
+3
-2
lib/gitlab/ci/pipeline/chain/validate/repository.rb
lib/gitlab/ci/pipeline/chain/validate/repository.rb
+1
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+10
-2
No files found.
app/models/project.rb
View file @
b0b5924e
...
@@ -36,7 +36,6 @@ class Project < ActiveRecord::Base
...
@@ -36,7 +36,6 @@ class Project < ActiveRecord::Base
extend
Gitlab
::
ConfigHelper
extend
Gitlab
::
ConfigHelper
BoardLimitExceeded
=
Class
.
new
(
StandardError
)
BoardLimitExceeded
=
Class
.
new
(
StandardError
)
AmbiguousRef
=
Class
.
new
(
StandardError
)
STATISTICS_ATTRIBUTE
=
'repositories_count'
.
freeze
STATISTICS_ATTRIBUTE
=
'repositories_count'
.
freeze
NUMBER_OF_PERMITTED_BOARDS
=
1
NUMBER_OF_PERMITTED_BOARDS
=
1
...
@@ -1166,7 +1165,7 @@ class Project < ActiveRecord::Base
...
@@ -1166,7 +1165,7 @@ class Project < ActiveRecord::Base
branch_exists
=
repository
.
branch_exists?
(
ref
)
branch_exists
=
repository
.
branch_exists?
(
ref
)
if
tag_exists
&&
branch_exists
if
tag_exists
&&
branch_exists
raise
AmbiguousRef
nil
elsif
tag_exists
elsif
tag_exists
repository
.
find_tag
(
ref
)
repository
.
find_tag
(
ref
)
elsif
branch_exists
elsif
branch_exists
...
@@ -1754,6 +1753,8 @@ class Project < ActiveRecord::Base
...
@@ -1754,6 +1753,8 @@ class Project < ActiveRecord::Base
def
protected_for?
(
ref
)
def
protected_for?
(
ref
)
resolved_ref
=
resolve_ref
(
ref
)
resolved_ref
=
resolve_ref
(
ref
)
return
false
unless
resolved_ref
full_ref
=
resolved_ref
.
full_ref
full_ref
=
resolved_ref
.
full_ref
ref_name
=
resolved_ref
.
name
ref_name
=
resolved_ref
.
name
...
...
lib/gitlab/ci/pipeline/chain/validate/repository.rb
View file @
b0b5924e
...
@@ -17,9 +17,7 @@ module Gitlab
...
@@ -17,9 +17,7 @@ module Gitlab
return
error
(
'Commit not found'
)
return
error
(
'Commit not found'
)
end
end
begin
unless
@command
.
project
.
resolve_ref
(
@command
.
origin_ref
)
@command
.
project
.
resolve_ref
(
@command
.
origin_ref
)
rescue
Project
::
AmbiguousRef
return
error
(
'Ref is ambiguous'
)
return
error
(
'Ref is ambiguous'
)
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
b0b5924e
...
@@ -2571,6 +2571,14 @@ describe Project do
...
@@ -2571,6 +2571,14 @@ describe Project do
allow
(
project
).
to
receive
(
:resolve_ref
).
and_return
(
ref
)
allow
(
project
).
to
receive
(
:resolve_ref
).
and_return
(
ref
)
end
end
context
'when ref is ambiguous'
do
let
(
:ref
)
{
nil
}
it
'returns false'
do
is_expected
.
to
be_falsey
end
end
context
'when the ref is not protected'
do
context
'when the ref is not protected'
do
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
...
@@ -2820,8 +2828,8 @@ describe Project do
...
@@ -2820,8 +2828,8 @@ describe Project do
project
.
repository
.
add_branch
(
project
.
creator
,
ref
,
'master'
)
project
.
repository
.
add_branch
(
project
.
creator
,
ref
,
'master'
)
end
end
it
'r
aises an error
'
do
it
'r
eturns nil
'
do
expect
{
subject
}.
to
raise_error
(
described_class
::
AmbiguousRef
)
is_expected
.
to
eq
(
nil
)
end
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