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
cae0fa7c
Commit
cae0fa7c
authored
Aug 12, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly select a list of Pipelines for a Merge Requests
parent
0d6d7f6e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+11
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+32
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
cae0fa7c
...
...
@@ -137,7 +137,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def
pipelines
@pipelines
=
Ci
::
Pipeline
.
where
(
ref:
@merge_request
.
source_branch
)
@pipelines
=
@merge_request
.
all_pipelines
respond_to
do
|
format
|
format
.
html
do
...
...
app/models/merge_request.rb
View file @
cae0fa7c
...
...
@@ -642,10 +642,21 @@ class MergeRequest < ActiveRecord::Base
diverged_commits_count
>
0
end
def
commits_sha
commits
.
map
(
&
:sha
)
end
def
pipeline
@pipeline
||=
source_project
.
pipeline
(
diff_head_sha
,
source_branch
)
if
diff_head_sha
&&
source_project
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
)
end
end
def
merge_commit
@merge_commit
||=
project
.
commit
(
merge_commit_sha
)
if
merge_commit_sha
end
...
...
spec/models/merge_request_spec.rb
View file @
cae0fa7c
...
...
@@ -419,6 +419,20 @@ describe MergeRequest, models: true do
subject
{
create
:merge_request
,
:simple
}
end
describe
'#commits_sha'
do
let
(
:commit0
)
{
double
(
'commit0'
,
sha:
'sha1'
)
}
let
(
:commit1
)
{
double
(
'commit1'
,
sha:
'sha2'
)
}
let
(
:commit2
)
{
double
(
'commit2'
,
sha:
'sha3'
)
}
before
do
allow
(
subject
).
to
receive
(
:commits
).
and_return
([
commit0
,
commit1
,
commit2
])
end
it
'returns sha of commits'
do
expect
(
subject
.
commits_sha
).
to
contain_exactly
(
'sha1'
,
'sha2'
,
'sha3'
)
end
end
describe
'#pipeline'
do
describe
'when the source project exists'
do
it
'returns the latest pipeline'
do
...
...
@@ -443,6 +457,24 @@ describe MergeRequest, models: true do
end
end
describe
'#all_pipelines'
do
let
(
:commit0
)
{
double
(
'commit0'
,
sha:
'sha1'
)
}
let
(
:commit1
)
{
double
(
'commit1'
,
sha:
'sha2'
)
}
let
(
:commit2
)
{
double
(
'commit2'
,
sha:
'sha3'
)
}
let!
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
sha:
'sha1'
,
ref:
subject
.
source_branch
)
}
let!
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
sha:
'sha1'
,
ref:
subject
.
source_branch
)
}
let!
(
:pipeline3
)
{
create
(
:ci_empty_pipeline
,
project:
subject
.
source_project
,
sha:
'sha2'
,
ref:
subject
.
source_branch
)
}
let!
(
:pipeline4
)
{
create
(
:ci_empty_pipeline
,
project:
subject
.
target_project
,
sha:
'sha1'
,
ref:
subject
.
target_branch
)
}
before
do
allow
(
subject
).
to
receive
(
:commits
).
and_return
([
commit0
,
commit1
,
commit2
])
end
it
'returns a pipelines from source projects'
do
expect
(
subject
.
all_pipelines
).
to
eq
([
pipeline3
,
pipeline2
,
pipeline
])
end
end
describe
'#participants'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
...
...
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