BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e0f596c9
Commit
e0f596c9
authored
Sep 19, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show all pipelines from all merge_request_diffs:
This way we could also show pipelines from commits which were discarded due to a force push.
parent
fe084819
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
9 deletions
+44
-9
merge_request.rb
app/models/merge_request.rb
+11
-3
merge_request_diff.rb
app/models/merge_request_diff.rb
+8
-0
merge_request_spec.rb
spec/models/merge_request_spec.rb
+25
-6
No files found.
app/models/merge_request.rb
View file @
e0f596c9
...
...
@@ -745,10 +745,18 @@ class MergeRequest < ActiveRecord::Base
end
def
all_pipelines
@all_pipelines
||=
if
diff_head_sha
&&
source_project
source_project
.
pipelines
.
order
(
id: :desc
).
where
(
sha:
commits_sha
,
ref:
source_branch
)
return
unless
source_project
@all_pipelines
||=
begin
if
persisted?
sha
=
merge_request_diffs
.
flat_map
(
&
:commits_sha
).
uniq
else
sha
=
diff_head_sha
end
source_project
.
pipelines
.
order
(
id: :desc
).
where
(
sha:
sha
,
ref:
source_branch
)
end
end
def
merge_commit
...
...
app/models/merge_request_diff.rb
View file @
e0f596c9
...
...
@@ -117,6 +117,14 @@ class MergeRequestDiff < ActiveRecord::Base
project
.
commit
(
head_commit_sha
)
end
def
commits_sha
if
@commits
commits
.
map
(
&
:sha
)
else
st_commits
.
map
{
|
commit
|
commit
[
:id
]
}
end
end
def
diff_refs
return
unless
start_commit_sha
||
base_commit_sha
...
...
spec/models/merge_request_spec.rb
View file @
e0f596c9
...
...
@@ -495,15 +495,34 @@ describe MergeRequest, models: true do
end
describe
'#all_pipelines'
do
let!
(
:pipelines
)
do
subject
.
merge_request_diff
.
commits
.
map
do
|
commit
|
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
sha:
commit
.
id
,
ref:
subject
.
source_branch
)
shared_examples
'returning pipelines with proper ordering'
do
let!
(
:pipelines
)
do
subject
.
merge_request_diffs
.
flat_map
do
|
diff
|
diff
.
commits
.
map
do
|
commit
|
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
sha:
commit
.
id
,
ref:
subject
.
source_branch
)
end
end
end
it
'returns all pipelines'
do
expect
(
subject
.
all_pipelines
).
not_to
be_empty
expect
(
subject
.
all_pipelines
).
to
eq
(
pipelines
.
reverse
)
end
end
it
'returns a pipelines from source projects with proper ordering'
do
expect
(
subject
.
all_pipelines
).
not_to
be_empty
expect
(
subject
.
all_pipelines
).
to
eq
(
pipelines
.
reverse
)
context
'with single merge_request_diffs'
do
it_behaves_like
'returning pipelines with proper ordering'
end
context
'with multiple irrelevant merge_request_diffs'
do
before
do
subject
.
update
(
target_branch:
'markdown'
)
end
it_behaves_like
'returning pipelines with proper ordering'
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