diff options
author | Ali Ibrahim <aliibrahim@gmail.com> | 2016-08-14 13:49:08 -0400 |
---|---|---|
committer | Ali Ibrahim <aliibrahim@gmail.com> | 2016-08-17 11:11:08 -0400 |
commit | 2b73aaa15ad9f651f51f8c71de461da6664a4fbb (patch) | |
tree | 0704849e63b0d396ab367056348c1eb90646b884 /lib/gitlab/git_access.rb | |
parent | d1da2e8180d92e5f4a8b5ebb36b0f4e4d0618bf8 (diff) | |
download | gitlab-ce-2b73aaa15ad9f651f51f8c71de461da6664a4fbb.tar.gz |
Allow to add deploy keys with write-access
Diffstat (limited to 'lib/gitlab/git_access.rb')
-rw-r--r-- | lib/gitlab/git_access.rb | 17 |
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 |