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
Léo-Paul Géneau
gitlab-ce
Commits
770b2a5c
Commit
770b2a5c
authored
Dec 26, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move protected branch actions into a method.
parent
61b4214e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+20
-12
No files found.
lib/gitlab/git_access.rb
View file @
770b2a5c
...
...
@@ -79,18 +79,8 @@ module Gitlab
oldrev
,
newrev
,
ref
=
change
.
split
(
' '
)
action
=
if
project
.
protected_branch?
(
branch_name
(
ref
))
# we dont allow force push to protected branch
if
forced_push?
(
project
,
oldrev
,
newrev
)
:force_push_code_to_protected_branches
# and we dont allow remove of protected branch
elsif
newrev
==
Gitlab
::
Git
::
BLANK_SHA
:remove_protected_branches
elsif
project
.
developers_can_push_to_protected_branch?
(
branch_name
(
ref
))
:push_code
else
:push_code_to_protected_branches
end
elsif
project
.
repository
.
tag_names
.
include?
(
tag_name
(
ref
))
protected_branch_action
(
project
,
oldrev
,
newrev
,
branch_name
(
ref
))
elsif
protected_tag?
(
tag_name
(
ref
))
# Prevent any changes to existing git tag unless user has permissions
:admin_project
else
...
...
@@ -110,6 +100,24 @@ module Gitlab
private
def
protected_branch_action
(
project
,
oldrev
,
newrev
,
branch_name
)
# we dont allow force push to protected branch
if
forced_push?
(
project
,
oldrev
,
newrev
)
:force_push_code_to_protected_branches
# and we dont allow remove of protected branch
elsif
newrev
==
Gitlab
::
Git
::
BLANK_SHA
:remove_protected_branches
elsif
project
.
developers_can_push_to_protected_branch?
(
branch_name
)
:push_code
else
:push_code_to_protected_branches
end
end
def
protected_tag?
(
tag_name
)
project
.
repository
.
tag_names
.
include?
(
tag_name
)
end
def
user_allowed?
(
user
)
Gitlab
::
UserAccess
.
allowed?
(
user
)
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