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
18889696
Commit
18889696
authored
Mar 01, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ambiguous association names in Ci::Pipeline
fix it ok Fix head pipeline
parent
7b4130d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
8 deletions
+8
-8
app/mailers/emails/pipelines.rb
app/mailers/emails/pipelines.rb
+1
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
app/workers/pipeline_metrics_worker.rb
app/workers/pipeline_metrics_worker.rb
+1
-1
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+4
-4
No files found.
app/mailers/emails/pipelines.rb
View file @
18889696
...
@@ -15,7 +15,7 @@ module Emails
...
@@ -15,7 +15,7 @@ module Emails
def
pipeline_mail
(
pipeline
,
recipients
,
status
)
def
pipeline_mail
(
pipeline
,
recipients
,
status
)
@project
=
pipeline
.
project
@project
=
pipeline
.
project
@pipeline
=
pipeline
@pipeline
=
pipeline
@merge_request
=
pipeline
.
merge_requests
.
first
@merge_request
=
pipeline
.
merge_requests
_as_head_pipeline
.
first
add_headers
add_headers
# We use bcc here because we don't want to generate this emails for a
# We use bcc here because we don't want to generate this emails for a
...
...
app/models/ci/pipeline.rb
View file @
18889696
...
@@ -39,7 +39,7 @@ module Ci
...
@@ -39,7 +39,7 @@ module Ci
# Merge requests for which the current pipeline is running against
# Merge requests for which the current pipeline is running against
# the merge request's latest commit.
# the merge request's latest commit.
has_many
:merge_requests
,
foreign_key:
"head_pipeline_id"
has_many
:merge_requests
_as_head_pipeline
,
foreign_key:
"head_pipeline_id"
,
class_name:
'MergeRequest'
has_many
:pending_builds
,
->
{
pending
},
foreign_key: :commit_id
,
class_name:
'Ci::Build'
has_many
:pending_builds
,
->
{
pending
},
foreign_key: :commit_id
,
class_name:
'Ci::Build'
has_many
:retryable_builds
,
->
{
latest
.
failed_or_canceled
.
includes
(
:project
)
},
foreign_key: :commit_id
,
class_name:
'Ci::Build'
has_many
:retryable_builds
,
->
{
latest
.
failed_or_canceled
.
includes
(
:project
)
},
foreign_key: :commit_id
,
class_name:
'Ci::Build'
...
...
app/workers/pipeline_metrics_worker.rb
View file @
18889696
...
@@ -30,6 +30,6 @@ class PipelineMetricsWorker
...
@@ -30,6 +30,6 @@ class PipelineMetricsWorker
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
merge_requests
(
pipeline
)
def
merge_requests
(
pipeline
)
pipeline
.
merge_requests
.
map
(
&
:id
)
pipeline
.
merge_requests
_as_head_pipeline
.
map
(
&
:id
)
end
end
end
end
spec/lib/gitlab/import_export/all_models.yml
View file @
18889696
...
@@ -127,7 +127,7 @@ ci_pipelines:
...
@@ -127,7 +127,7 @@ ci_pipelines:
-
scheduled_actions
-
scheduled_actions
-
artifacts
-
artifacts
-
pipeline_schedule
-
pipeline_schedule
-
merge_requests
-
merge_requests
_as_head_pipeline
-
merge_request
-
merge_request
-
deployments
-
deployments
-
environments
-
environments
...
...
spec/models/ci/pipeline_spec.rb
View file @
18889696
...
@@ -2252,7 +2252,7 @@ describe Ci::Pipeline, :mailer do
...
@@ -2252,7 +2252,7 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
describe
"#merge_requests"
do
describe
"#merge_requests
_as_head_pipeline
"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
'master'
,
sha:
'a288a022a53a5a944fae87bcec6efc87b7061808'
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
'master'
,
sha:
'a288a022a53a5a944fae87bcec6efc87b7061808'
)
}
...
@@ -2260,20 +2260,20 @@ describe Ci::Pipeline, :mailer do
...
@@ -2260,20 +2260,20 @@ describe Ci::Pipeline, :mailer do
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:diff_head_sha
)
{
'a288a022a53a5a944fae87bcec6efc87b7061808'
}
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:diff_head_sha
)
{
'a288a022a53a5a944fae87bcec6efc87b7061808'
}
merge_request
=
create
(
:merge_request
,
source_project:
project
,
head_pipeline:
pipeline
,
source_branch:
pipeline
.
ref
)
merge_request
=
create
(
:merge_request
,
source_project:
project
,
head_pipeline:
pipeline
,
source_branch:
pipeline
.
ref
)
expect
(
pipeline
.
merge_requests
).
to
eq
([
merge_request
])
expect
(
pipeline
.
merge_requests
_as_head_pipeline
).
to
eq
([
merge_request
])
end
end
it
"doesn't return merge requests whose source branch doesn't match the pipeline's ref"
do
it
"doesn't return merge requests whose source branch doesn't match the pipeline's ref"
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature'
,
target_branch:
'master'
)
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature'
,
target_branch:
'master'
)
expect
(
pipeline
.
merge_requests
).
to
be_empty
expect
(
pipeline
.
merge_requests
_as_head_pipeline
).
to
be_empty
end
end
it
"doesn't return merge requests whose `diff_head_sha` doesn't match the pipeline's SHA"
do
it
"doesn't return merge requests whose `diff_head_sha` doesn't match the pipeline's SHA"
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
pipeline
.
ref
)
create
(
:merge_request
,
source_project:
project
,
source_branch:
pipeline
.
ref
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:diff_head_sha
)
{
'97de212e80737a608d939f648d959671fb0a0142b'
}
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:diff_head_sha
)
{
'97de212e80737a608d939f648d959671fb0a0142b'
}
expect
(
pipeline
.
merge_requests
).
to
be_empty
expect
(
pipeline
.
merge_requests
_as_head_pipeline
).
to
be_empty
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