diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-03-21 16:08:32 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-03-29 09:58:45 +0300 |
commit | bf639fd504c84929ff8542eef81578a6745bf428 (patch) | |
tree | b7eb20a2ef25de759ed3d8a2ef9a063c77564c03 /lib | |
parent | 3a477fec8f1fe6cf1da70a8ae0a8473ab26235bc (diff) |
Create detached merge request pipelines
By using `refs/merge-requests/:iid/head`
ok
ok
Improve naming nicely
Add nice tests
add nice tests
fix some more
revert
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/command.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/validate/abilities.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/validate/repository.rb | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/command.rb b/lib/gitlab/ci/pipeline/chain/command.rb index bf9f03f6134..03af99ba9a5 100644 --- a/lib/gitlab/ci/pipeline/chain/command.rb +++ b/lib/gitlab/ci/pipeline/chain/command.rb @@ -33,6 +33,13 @@ module Gitlab end end + def merge_request_ref_exists? + strong_memoize(:merge_request_ref_exists) do + MergeRequest.merge_request_ref?(origin_ref) && + project.repository.ref_exists?(origin_ref) + end + end + def ref strong_memoize(:ref) do Gitlab::Git.ref_name(origin_ref) diff --git a/lib/gitlab/ci/pipeline/chain/validate/abilities.rb b/lib/gitlab/ci/pipeline/chain/validate/abilities.rb index ebd7e6e8289..aaa3daddcc5 100644 --- a/lib/gitlab/ci/pipeline/chain/validate/abilities.rb +++ b/lib/gitlab/ci/pipeline/chain/validate/abilities.rb @@ -44,6 +44,8 @@ module Gitlab access.can_update_branch?(@command.ref) elsif @command.tag_exists? access.can_create_tag?(@command.ref) + elsif @command.merge_request_ref_exists? + access.can_update_branch?(@command.merge_request.source_branch) else true # Allow it for now and we'll reject when we check ref existence end diff --git a/lib/gitlab/ci/pipeline/chain/validate/repository.rb b/lib/gitlab/ci/pipeline/chain/validate/repository.rb index 9c6c2bc8e25..8f5445850d7 100644 --- a/lib/gitlab/ci/pipeline/chain/validate/repository.rb +++ b/lib/gitlab/ci/pipeline/chain/validate/repository.rb @@ -9,7 +9,7 @@ module Gitlab include Chain::Helpers def perform! - unless @command.branch_exists? || @command.tag_exists? + unless @command.branch_exists? || @command.tag_exists? || @command.merge_request_ref_exists? return error('Reference not found') end |