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
Tatuya Kamada
gitlab-ce
Commits
8b35b208
Commit
8b35b208
authored
Jan 28, 2014
by
Steven Thonus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first setup to protect protected branched to force updates
parent
7f67e066
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
lib/api/internal.rb
lib/api/internal.rb
+3
-1
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+13
-8
No files found.
lib/api/internal.rb
View file @
8b35b208
...
@@ -10,6 +10,7 @@ module API
...
@@ -10,6 +10,7 @@ module API
# project - project path with namespace
# project - project path with namespace
# action - git action (git-upload-pack or git-receive-pack)
# action - git action (git-upload-pack or git-receive-pack)
# ref - branch name
# ref - branch name
# forced_push - forced_push
#
#
get
"/allowed"
do
get
"/allowed"
do
# Check for *.wiki repositories.
# Check for *.wiki repositories.
...
@@ -35,7 +36,8 @@ module API
...
@@ -35,7 +36,8 @@ module API
project
,
project
,
params
[
:ref
],
params
[
:ref
],
params
[
:oldrev
],
params
[
:oldrev
],
params
[
:newrev
]
params
[
:newrev
],
params
[
:forced_push
]
)
)
end
end
...
...
lib/gitlab/git_access.rb
View file @
8b35b208
...
@@ -5,7 +5,7 @@ module Gitlab
...
@@ -5,7 +5,7 @@ module Gitlab
attr_reader
:params
,
:project
,
:git_cmd
,
:user
attr_reader
:params
,
:project
,
:git_cmd
,
:user
def
allowed?
(
actor
,
cmd
,
project
,
ref
=
nil
,
oldrev
=
nil
,
newrev
=
nil
)
def
allowed?
(
actor
,
cmd
,
project
,
ref
=
nil
,
oldrev
=
nil
,
newrev
=
nil
,
forced_push
=
false
)
case
cmd
case
cmd
when
*
DOWNLOAD_COMMANDS
when
*
DOWNLOAD_COMMANDS
if
actor
.
is_a?
User
if
actor
.
is_a?
User
...
@@ -19,12 +19,12 @@ module Gitlab
...
@@ -19,12 +19,12 @@ module Gitlab
end
end
when
*
PUSH_COMMANDS
when
*
PUSH_COMMANDS
if
actor
.
is_a?
User
if
actor
.
is_a?
User
push_allowed?
(
actor
,
project
,
ref
,
oldrev
,
newrev
)
push_allowed?
(
actor
,
project
,
ref
,
oldrev
,
newrev
,
forced_push
)
elsif
actor
.
is_a?
DeployKey
elsif
actor
.
is_a?
DeployKey
# Deploy key not allowed to push
# Deploy key not allowed to push
return
false
return
false
elsif
actor
.
is_a?
Key
elsif
actor
.
is_a?
Key
push_allowed?
(
actor
.
user
,
project
,
ref
,
oldrev
,
newrev
)
push_allowed?
(
actor
.
user
,
project
,
ref
,
oldrev
,
newrev
,
forced_push
)
else
else
raise
'Wrong actor'
raise
'Wrong actor'
end
end
...
@@ -41,10 +41,15 @@ module Gitlab
...
@@ -41,10 +41,15 @@ module Gitlab
end
end
end
end
def
push_allowed?
(
user
,
project
,
ref
,
oldrev
,
newrev
)
def
push_allowed?
(
user
,
project
,
ref
,
oldrev
,
newrev
,
forced_push
)
if
user
&&
user_allowed?
(
user
)
if
user
&&
user_allowed?
(
user
)
action
=
if
project
.
protected_branch?
(
ref
)
action
=
if
project
.
protected_branch?
(
ref
)
if
forced_push
:force_push_code_to_protected_branches
else
:push_code_to_protected_branches
:push_code_to_protected_branches
end
else
else
:push_code
:push_code
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