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
a1be5809
Commit
a1be5809
authored
Nov 26, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Command#ambiguous_ref?
parent
9f6d228d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+6
-0
lib/gitlab/ci/pipeline/chain/validate/repository.rb
lib/gitlab/ci/pipeline/chain/validate/repository.rb
+1
-1
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+20
-0
No files found.
lib/gitlab/ci/pipeline/chain/command.rb
View file @
a1be5809
...
...
@@ -57,6 +57,12 @@ module Gitlab
project
.
protected_for?
(
origin_ref
)
end
end
def
ambiguous_ref?
strong_memoize
(
:ambiguous_ref
)
do
project
.
repository
.
ambiguous_ref?
(
origin_ref
)
end
end
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/validate/repository.rb
View file @
a1be5809
...
...
@@ -17,7 +17,7 @@ module Gitlab
return
error
(
'Commit not found'
)
end
if
@command
.
project
.
repository
.
ambiguous_ref?
(
@command
.
origin_ref
)
if
@command
.
ambiguous_ref?
return
error
(
'Ref is ambiguous'
)
end
end
...
...
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
View file @
a1be5809
...
...
@@ -182,4 +182,24 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
it
{
is_expected
.
to
eq
(
false
)
}
end
end
describe
'#ambiguous_ref'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:command
)
{
described_class
.
new
(
project:
project
,
origin_ref:
'ref'
)
}
subject
{
command
.
ambiguous_ref?
}
context
'when ref is not ambiguous'
do
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when ref is ambiguous'
do
before
do
project
.
repository
.
add_tag
(
project
.
creator
,
'ref'
,
'master'
)
project
.
repository
.
add_branch
(
project
.
creator
,
'ref'
,
'master'
)
end
it
{
is_expected
.
to
eq
(
true
)
}
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