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
b6c8d3ac
Commit
b6c8d3ac
authored
Nov 15, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reintroduce Command#protected_ref?
parent
b0b5924e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
10 deletions
+36
-10
lib/gitlab/ci/pipeline/chain/build.rb
lib/gitlab/ci/pipeline/chain/build.rb
+1
-0
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+6
-0
lib/gitlab/ci/pipeline/chain/populate.rb
lib/gitlab/ci/pipeline/chain/populate.rb
+0
-5
lib/gitlab/ci/pipeline/chain/validate/abilities.rb
lib/gitlab/ci/pipeline/chain/validate/abilities.rb
+1
-1
lib/gitlab/git.rb
lib/gitlab/git.rb
+2
-2
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+22
-0
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+2
-1
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+2
-1
No files found.
lib/gitlab/ci/pipeline/chain/build.rb
View file @
b6c8d3ac
...
...
@@ -17,6 +17,7 @@ module Gitlab
user:
@command
.
current_user
,
pipeline_schedule:
@command
.
schedule
,
merge_request:
@command
.
merge_request
,
protected:
@command
.
protected_ref?
,
variables_attributes:
Array
(
@command
.
variables_attributes
)
)
...
...
lib/gitlab/ci/pipeline/chain/command.rb
View file @
b6c8d3ac
...
...
@@ -51,6 +51,12 @@ module Gitlab
def
before_sha
self
[
:before_sha
]
||
checkout_sha
||
Gitlab
::
Git
::
BLANK_SHA
end
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
origin_ref
)
end
end
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/populate.rb
View file @
b6c8d3ac
...
...
@@ -18,11 +18,6 @@ module Gitlab
#
@command
.
seeds_block
&
.
call
(
pipeline
)
##
# Populate pipeline protected status
#
pipeline
.
protected
=
@command
.
project
.
protected_for?
(
@command
.
origin_ref
)
##
# Populate pipeline with all stages, and stages with builds.
#
...
...
lib/gitlab/ci/pipeline/chain/validate/abilities.rb
View file @
b6c8d3ac
...
...
@@ -31,7 +31,7 @@ module Gitlab
if
current_user
allowed_to_create?
else
# legacy triggers don't have a corresponding user
!
@command
.
pro
ject
.
protected_for?
(
@command
.
origin_ref
)
!
@command
.
pro
tected_ref?
end
end
...
...
lib/gitlab/git.rb
View file @
b6c8d3ac
...
...
@@ -54,11 +54,11 @@ module Gitlab
end
def
tag_ref?
(
ref
)
ref
.
start_with?
(
TAG_REF_PREFIX
)
ref
=~
%r{
#{
TAG_REF_PREFIX
}
\w
+}
end
def
branch_ref?
(
ref
)
ref
.
start_with?
(
BRANCH_REF_PREFIX
)
ref
=~
%r{
#{
BRANCH_REF_PREFIX
}
\w
+}
end
def
blank_ref?
(
ref
)
...
...
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
View file @
b6c8d3ac
...
...
@@ -160,4 +160,26 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
end
end
end
describe
'#protected_ref?'
do
let
(
:command
)
{
described_class
.
new
(
project:
project
,
origin_ref:
'my-branch'
)
}
subject
{
command
.
protected_ref?
}
context
'when a ref is protected'
do
before
do
expect_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
with
(
'my-branch'
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when a ref is unprotected'
do
before
do
expect_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
with
(
'my-branch'
).
and_return
(
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
end
end
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
View file @
b6c8d3ac
require
'spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Build
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:attributes
)
do
{
name:
'rspec'
,
...
...
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
View file @
b6c8d3ac
require
'spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:attributes
)
do
{
name:
'test'
,
...
...
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