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
5ae5d51c
Commit
5ae5d51c
authored
May 13, 2021
by
Furkan Ayhan
Committed by
Fabio Pitino
May 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the problem of pipelines changes with external PRs [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent
70f764e9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
1 deletion
+58
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+6
-0
app/models/external_pull_request.rb
app/models/external_pull_request.rb
+4
-0
config/feature_flags/development/ci_modified_paths_of_external_prs.yml
...e_flags/development/ci_modified_paths_of_external_prs.yml
+8
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+24
-0
spec/models/external_pull_request_spec.rb
spec/models/external_pull_request_spec.rb
+16
-1
No files found.
app/models/ci/pipeline.rb
View file @
5ae5d51c
...
@@ -1093,6 +1093,8 @@ module Ci
...
@@ -1093,6 +1093,8 @@ module Ci
merge_request
.
modified_paths
merge_request
.
modified_paths
elsif
branch_updated?
elsif
branch_updated?
push_details
.
modified_paths
push_details
.
modified_paths
elsif
external_pull_request?
&&
::
Feature
.
enabled?
(
:ci_modified_paths_of_external_prs
,
project
,
default_enabled: :yaml
)
external_pull_request
.
modified_paths
end
end
end
end
end
end
...
@@ -1117,6 +1119,10 @@ module Ci
...
@@ -1117,6 +1119,10 @@ module Ci
merge_request_id
.
present?
merge_request_id
.
present?
end
end
def
external_pull_request?
external_pull_request_id
.
present?
end
def
detached_merge_request_pipeline?
def
detached_merge_request_pipeline?
merge_request?
&&
target_sha
.
nil?
merge_request?
&&
target_sha
.
nil?
end
end
...
...
app/models/external_pull_request.rb
View file @
5ae5d51c
...
@@ -72,6 +72,10 @@ class ExternalPullRequest < ApplicationRecord
...
@@ -72,6 +72,10 @@ class ExternalPullRequest < ApplicationRecord
end
end
end
end
def
modified_paths
project
.
repository
.
diff_stats
(
target_sha
,
source_sha
).
paths
end
private
private
def
actual_source_branch_sha
def
actual_source_branch_sha
...
...
config/feature_flags/development/ci_modified_paths_of_external_prs.yml
0 → 100644
View file @
5ae5d51c
---
name
:
ci_modified_paths_of_external_prs
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60736
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/330605
milestone
:
'
13.12'
type
:
development
group
:
group::pipeline authoring
default_enabled
:
false
spec/models/ci/pipeline_spec.rb
View file @
5ae5d51c
...
@@ -1939,6 +1939,30 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
...
@@ -1939,6 +1939,30 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
expect
(
pipeline
.
modified_paths
).
to
match
(
merge_request
.
modified_paths
)
expect
(
pipeline
.
modified_paths
).
to
match
(
merge_request
.
modified_paths
)
end
end
end
end
context
'when source is an external pull request'
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
source: :external_pull_request_event
,
external_pull_request:
external_pull_request
)
end
let
(
:external_pull_request
)
do
create
(
:external_pull_request
,
project:
project
,
target_sha:
'281d3a7'
,
source_sha:
'498214d'
)
end
it
'returns external pull request modified paths'
do
expect
(
pipeline
.
modified_paths
).
to
match
(
external_pull_request
.
modified_paths
)
end
context
'when the FF ci_modified_paths_of_external_prs is disabled'
do
before
do
stub_feature_flags
(
ci_modified_paths_of_external_prs:
false
)
end
it
'returns nil'
do
expect
(
pipeline
.
modified_paths
).
to
be_nil
end
end
end
end
end
describe
'#all_worktree_paths'
do
describe
'#all_worktree_paths'
do
...
...
spec/models/external_pull_request_spec.rb
View file @
5ae5d51c
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
ExternalPullRequest
do
RSpec
.
describe
ExternalPullRequest
do
let
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:source_branch
)
{
'the-branch'
}
let
(
:source_branch
)
{
'the-branch'
}
let
(
:status
)
{
:open
}
let
(
:status
)
{
:open
}
...
@@ -217,4 +218,18 @@ RSpec.describe ExternalPullRequest do
...
@@ -217,4 +218,18 @@ RSpec.describe ExternalPullRequest do
expect
(
pull_request
).
not_to
be_from_fork
expect
(
pull_request
).
not_to
be_from_fork
end
end
end
end
describe
'#modified_paths'
do
let
(
:pull_request
)
do
build
(
:external_pull_request
,
project:
project
,
target_sha:
'281d3a7'
,
source_sha:
'498214d'
)
end
subject
(
:modified_paths
)
{
pull_request
.
modified_paths
}
it
'returns modified paths'
do
expect
(
modified_paths
).
to
eq
[
'bar/branch-test.txt'
,
'files/js/commit.coffee'
,
'with space/README.md'
]
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