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
a04e1d5e
Commit
a04e1d5e
authored
Apr 02, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport EE change
This is for merge request pipelines
parent
ba23d637
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
50 deletions
+17
-50
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+0
-8
app/serializers/merge_request_widget_entity.rb
app/serializers/merge_request_widget_entity.rb
+1
-0
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+2
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+0
-42
spec/serializers/merge_request_widget_entity_spec.rb
spec/serializers/merge_request_widget_entity_spec.rb
+4
-0
spec/serializers/pipeline_entity_spec.rb
spec/serializers/pipeline_entity_spec.rb
+10
-0
No files found.
app/models/ci/pipeline.rb
View file @
a04e1d5e
...
@@ -206,10 +206,6 @@ module Ci
...
@@ -206,10 +206,6 @@ module Ci
triggered_by_merge_request
(
merge_request
).
for_source_sha
(
source_sha
)
triggered_by_merge_request
(
merge_request
).
for_source_sha
(
source_sha
)
end
end
scope
:mergeable_merge_request_pipelines
,
->
(
merge_request
)
do
triggered_by_merge_request
(
merge_request
).
where
(
target_sha:
merge_request
.
target_branch_sha
)
end
scope
:triggered_for_branch
,
->
(
ref
)
do
scope
:triggered_for_branch
,
->
(
ref
)
do
where
(
source:
branch_pipeline_sources
).
where
(
ref:
ref
,
tag:
false
)
where
(
source:
branch_pipeline_sources
).
where
(
ref:
ref
,
tag:
false
)
end
end
...
@@ -746,10 +742,6 @@ module Ci
...
@@ -746,10 +742,6 @@ module Ci
triggered_by_merge_request?
&&
target_sha
.
present?
triggered_by_merge_request?
&&
target_sha
.
present?
end
end
def
mergeable_merge_request_pipeline?
triggered_by_merge_request?
&&
target_sha
==
merge_request
.
target_branch_sha
end
def
merge_request_ref?
def
merge_request_ref?
MergeRequest
.
merge_request_ref?
(
ref
)
MergeRequest
.
merge_request_ref?
(
ref
)
end
end
...
...
app/serializers/merge_request_widget_entity.rb
View file @
a04e1d5e
...
@@ -20,6 +20,7 @@ class MergeRequestWidgetEntity < IssuableEntity
...
@@ -20,6 +20,7 @@ class MergeRequestWidgetEntity < IssuableEntity
end
end
expose
:squash
expose
:squash
expose
:target_branch
expose
:target_branch
expose
:target_branch_sha
expose
:target_project_id
expose
:target_project_id
expose
:target_project_full_path
do
|
merge_request
|
expose
:target_project_full_path
do
|
merge_request
|
merge_request
.
project
&
.
full_path
merge_request
.
project
&
.
full_path
...
...
app/serializers/pipeline_entity.rb
View file @
a04e1d5e
...
@@ -59,6 +59,8 @@ class PipelineEntity < Grape::Entity
...
@@ -59,6 +59,8 @@ class PipelineEntity < Grape::Entity
end
end
expose
:commit
,
using:
CommitEntity
expose
:commit
,
using:
CommitEntity
expose
:source_sha
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
merge_request_pipeline?
}
expose
:target_sha
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
merge_request_pipeline?
}
expose
:yaml_errors
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
has_yaml_errors?
}
expose
:yaml_errors
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
has_yaml_errors?
}
expose
:failure_reason
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
failure_reason?
}
do
|
pipeline
|
expose
:failure_reason
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
failure_reason?
}
do
|
pipeline
|
...
...
spec/models/ci/pipeline_spec.rb
View file @
a04e1d5e
...
@@ -322,48 +322,6 @@ describe Ci::Pipeline, :mailer do
...
@@ -322,48 +322,6 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
describe
'.mergeable_merge_request_pipelines'
do
subject
{
described_class
.
mergeable_merge_request_pipelines
(
merge_request
)
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:target_sha
)
{
merge_request
.
target_branch_sha
}
it
'returns mergeable merge pipelines'
do
is_expected
.
to
eq
([
pipeline
])
end
context
'when target sha does not point the head of the target branch'
do
let
(
:target_sha
)
{
merge_request
.
diff_head_sha
}
it
'returns empty array'
do
is_expected
.
to
be_empty
end
end
end
describe
'#mergeable_merge_request_pipeline?'
do
subject
{
pipeline
.
mergeable_merge_request_pipeline?
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :merge_request_event
,
merge_request:
merge_request
,
target_sha:
target_sha
)
end
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:target_sha
)
{
merge_request
.
target_branch_sha
}
it
{
is_expected
.
to
be_truthy
}
context
'when target sha does not point the head of the target branch'
do
let
(
:target_sha
)
{
merge_request
.
diff_head_sha
}
it
{
is_expected
.
to
be_falsy
}
end
end
describe
'#merge_request_ref?'
do
describe
'#merge_request_ref?'
do
subject
{
pipeline
.
merge_request_ref?
}
subject
{
pipeline
.
merge_request_ref?
}
...
...
spec/serializers/merge_request_widget_entity_spec.rb
View file @
a04e1d5e
...
@@ -13,6 +13,10 @@ describe MergeRequestWidgetEntity do
...
@@ -13,6 +13,10 @@ describe MergeRequestWidgetEntity do
described_class
.
new
(
resource
,
request:
request
).
as_json
described_class
.
new
(
resource
,
request:
request
).
as_json
end
end
it
'has the latest sha of the target branch'
do
is_expected
.
to
include
(
:target_branch_sha
)
end
describe
'source_project_full_path'
do
describe
'source_project_full_path'
do
it
'includes the full path of the source project'
do
it
'includes the full path of the source project'
do
expect
(
subject
[
:source_project_full_path
]).
to
be_present
expect
(
subject
[
:source_project_full_path
]).
to
be_present
...
...
spec/serializers/pipeline_entity_spec.rb
View file @
a04e1d5e
...
@@ -143,6 +143,11 @@ describe PipelineEntity do
...
@@ -143,6 +143,11 @@ describe PipelineEntity do
expect
(
subject
[
:flags
][
:detached_merge_request_pipeline
]).
to
be_truthy
expect
(
subject
[
:flags
][
:detached_merge_request_pipeline
]).
to
be_truthy
end
end
it
'does not expose source sha and target sha'
do
expect
(
subject
[
:source_sha
]).
to
be_nil
expect
(
subject
[
:target_sha
]).
to
be_nil
end
context
'when user is a developer'
do
context
'when user is a developer'
do
before
do
before
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
...
@@ -189,6 +194,11 @@ describe PipelineEntity do
...
@@ -189,6 +194,11 @@ describe PipelineEntity do
it
'makes atached flag true'
do
it
'makes atached flag true'
do
expect
(
subject
[
:flags
][
:merge_request_pipeline
]).
to
be_truthy
expect
(
subject
[
:flags
][
:merge_request_pipeline
]).
to
be_truthy
end
end
it
'exposes source sha and target sha'
do
expect
(
subject
[
:source_sha
]).
to
be_present
expect
(
subject
[
:target_sha
]).
to
be_present
end
end
end
end
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