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
14909330
Commit
14909330
authored
Oct 02, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose paths modified by a push from a pipeline class
parent
1c4187e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+28
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+51
-0
No files found.
app/models/ci/pipeline.rb
View file @
14909330
...
@@ -627,6 +627,18 @@ module Ci
...
@@ -627,6 +627,18 @@ module Ci
end
end
end
end
def
branch_updated?
strong_memoize
(
:branch_updated
)
do
push_details
.
branch_updated?
end
end
def
modified_paths
strong_memoize
(
:changes
)
do
push_details
.
modified_paths
end
end
private
private
def
ci_yaml_from_repo
def
ci_yaml_from_repo
...
@@ -650,6 +662,22 @@ module Ci
...
@@ -650,6 +662,22 @@ module Ci
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
self
)
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
self
)
end
end
def
push_details
strong_memoize
(
:push_details
)
do
Gitlab
::
Git
::
Push
.
new
(
project
,
before_sha
,
sha
,
push_ref
)
end
end
def
push_ref
if
branch?
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
.
to_s
elsif
tag?
Gitlab
::
Git
::
TAG_REF_PREFIX
+
ref
.
to_s
else
raise
ArgumentError
,
'Invalid pipeline type!'
end
end
def
latest_builds_status
def
latest_builds_status
return
'failed'
unless
yaml_errors
.
blank?
return
'failed'
unless
yaml_errors
.
blank?
...
...
spec/models/ci/pipeline_spec.rb
View file @
14909330
...
@@ -825,6 +825,57 @@ describe Ci::Pipeline, :mailer do
...
@@ -825,6 +825,57 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
describe
'#branch_updated?'
do
context
'when pipeline has before SHA'
do
before
do
pipeline
.
update_column
(
:before_sha
,
'a1b2c3d4'
)
end
it
'runs on a branch update push'
do
expect
(
pipeline
.
before_sha
).
not_to
be
Gitlab
::
Git
::
BLANK_SHA
expect
(
pipeline
.
branch_updated?
).
to
be
true
end
end
context
'when pipeline does not have before SHA'
do
before
do
pipeline
.
update_column
(
:before_sha
,
Gitlab
::
Git
::
BLANK_SHA
)
end
it
'does not run on a branch updating push'
do
expect
(
pipeline
.
branch_updated?
).
to
be
false
end
end
end
describe
'#modified_paths'
do
context
'when old and new revisions are set'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
pipeline
.
update
(
before_sha:
'1234abcd'
,
sha:
'2345bcde'
)
end
it
'fetches stats for changes between commits'
do
expect
(
project
.
repository
)
.
to
receive
(
:diff_stats
).
with
(
'1234abcd'
,
'2345bcde'
)
.
and_call_original
pipeline
.
modified_paths
end
end
context
'when either old or new revision is missing'
do
before
do
pipeline
.
update_column
(
:before_sha
,
Gitlab
::
Git
::
BLANK_SHA
)
end
it
'raises an error'
do
expect
{
pipeline
.
modified_paths
}.
to
raise_error
(
ArgumentError
)
end
end
end
describe
'#has_kubernetes_active?'
do
describe
'#has_kubernetes_active?'
do
context
'when kubernetes is active'
do
context
'when kubernetes is active'
do
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
shared_examples
'same behavior between KubernetesService and Platform::Kubernetes'
do
...
...
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