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
Léo-Paul Géneau
gitlab-ce
Commits
5f412e3a
Commit
5f412e3a
authored
Oct 22, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pipeline reference existence check and add specs
parent
49d7c3b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-3
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+23
-0
No files found.
app/models/ci/pipeline.rb
View file @
5f412e3a
...
@@ -269,7 +269,7 @@ module Ci
...
@@ -269,7 +269,7 @@ module Ci
end
end
def
ref_exists?
def
ref_exists?
project
.
repository
.
ref_exists?
(
self
.
ref
)
project
.
repository
.
ref_exists?
(
git_
ref
)
end
end
##
##
...
@@ -678,11 +678,11 @@ module Ci
...
@@ -678,11 +678,11 @@ module Ci
def
push_details
def
push_details
strong_memoize
(
:push_details
)
do
strong_memoize
(
:push_details
)
do
Gitlab
::
Git
::
Push
.
new
(
project
,
before_sha
,
sha
,
push
_ref
)
Gitlab
::
Git
::
Push
.
new
(
project
,
before_sha
,
sha
,
git
_ref
)
end
end
end
end
def
push
_ref
def
git
_ref
if
branch?
if
branch?
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
.
to_s
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
.
to_s
elsif
tag?
elsif
tag?
...
...
spec/models/ci/pipeline_spec.rb
View file @
5f412e3a
...
@@ -779,6 +779,29 @@ describe Ci::Pipeline, :mailer do
...
@@ -779,6 +779,29 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
describe
'ref_exists?'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:project
)
{
create
(
:project
,
:repository
)
}
where
(
:tag
,
:ref
,
:result
)
do
false
|
'master'
|
true
false
|
'non-existent-branch'
|
false
true
|
'v1.1.0'
|
true
true
|
'non-existent-tag'
|
false
end
with_them
do
let
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
tag:
tag
,
ref:
ref
)
end
it
"correctly detects ref"
do
expect
(
pipeline
.
ref_exists?
).
to
be
result
end
end
end
context
'with non-empty project'
do
context
'with non-empty project'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
...
...
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