diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-12-05 18:17:51 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-12-05 18:17:51 +0200 |
commit | 4491a3d12b414a52f32175e328df8dc48987d0fd (patch) | |
tree | bc2b3a93a5e40596d1d4d4a68a0df53133758ddf | |
parent | 7cefd9c6ef4fbbd8eb297ac03e2fa3e43c44f1a1 (diff) | |
download | gitlab-ce-4491a3d12b414a52f32175e328df8dc48987d0fd.tar.gz |
Decline push if repository does not exist
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | lib/gitlab/git_access.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 8b4729896b5..875f8d8b3a3 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -49,8 +49,17 @@ module Gitlab end def push_access_check(user, project, changes) - return build_status_object(false, "You don't have access") unless user && user_allowed?(user) - return build_status_object(true) if changes.blank? + unless user && user_allowed?(user) + return build_status_object(false, "You don't have access") + end + + if changes.blank? + return build_status_object(true) + end + + unless project.repository.exists? + return build_status_object(false, "Repository does not exist") + end changes = changes.lines if changes.kind_of?(String) @@ -79,7 +88,7 @@ module Gitlab else :push_code_to_protected_branches end - elsif project.repository && project.repository.tag_names.include?(tag_name(ref)) + elsif project.repository.tag_names.include?(tag_name(ref)) # Prevent any changes to existing git tag unless user has permissions :admin_project else |