Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Ibrahim <aliibrahim@gmail.com>2016-08-14 20:49:08 +0300
committerAli Ibrahim <aliibrahim@gmail.com>2016-08-17 18:11:08 +0300
commit2b73aaa15ad9f651f51f8c71de461da6664a4fbb (patch)
tree0704849e63b0d396ab367056348c1eb90646b884 /lib/gitlab/git_access.rb
parentd1da2e8180d92e5f4a8b5ebb36b0f4e4d0618bf8 (diff)
Allow to add deploy keys with write-access
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 1882eb8d050..f208df3cdce 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -50,10 +50,13 @@ module Gitlab
end
def push_access_check(changes)
+ unless project.repository.exists?
+ return build_status_object(false, "A repository for this project does not exist yet.")
+ end
if user
user_push_access_check(changes)
elsif deploy_key
- build_status_object(false, "Deploy keys are not allowed to push code.")
+ deploy_key_push_access_check(changes)
else
raise 'Wrong actor'
end
@@ -72,10 +75,6 @@ module Gitlab
return build_status_object(true)
end
- unless project.repository.exists?
- return build_status_object(false, "A repository for this project does not exist yet.")
- end
-
changes_list = Gitlab::ChangesList.new(changes)
# Iterate over all changes to find if user allowed all of them to be applied
@@ -90,6 +89,14 @@ module Gitlab
build_status_object(true)
end
+ def deploy_key_push_access_check(changes)
+ if actor.can_push?
+ build_status_object(true)
+ else
+ build_status_object(false, "The deploy key does not have write access to the project.")
+ end
+ end
+
def change_access_check(change)
Checks::ChangeAccess.new(change, user_access: user_access, project: project).exec
end