summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-07-18 11:22:25 +0000
committerDouwe Maan <douwe@gitlab.com>2018-07-18 11:22:25 +0000
commit1ba47de5fef7a86a453e97a574741d3dba85c521 (patch)
tree76e4175ac67372c6343e190d5e89df00f122f297 /lib
parentc35089d6658d19efe0b7a700d63dcce7866093bf (diff)
parent65e5cf0ace9cb57b474656633d2bee8bbebc940f (diff)
downloadgitlab-ce-1ba47de5fef7a86a453e97a574741d3dba85c521.tar.gz
Merge branch '27456-improve-feedback-when-dev-cannot-push-to-empty-repo' into 'master'
Improve feedback when a developer cannot push in an empty repository Closes #27456 See merge request gitlab-org/gitlab-ce!20519
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/checks/change_access.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index f76a6fb5f17..7a4224e5bbe 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -93,7 +93,7 @@ module Gitlab
end
else
unless user_access.can_push_to_branch?(branch_name)
- raise GitAccess::UnauthorizedError, ERROR_MESSAGES[:push_protected_branch]
+ raise GitAccess::UnauthorizedError, push_to_protected_branch_rejected_message
end
end
end
@@ -140,6 +140,29 @@ module Gitlab
private
+ def push_to_protected_branch_rejected_message
+ if project.empty_repo?
+ empty_project_push_message
+ else
+ ERROR_MESSAGES[:push_protected_branch]
+ end
+ end
+
+ def empty_project_push_message
+ <<~MESSAGE
+
+ A default branch (e.g. master) does not yet exist for #{project.full_path}
+ Ask a project Owner or Maintainer to create a default branch:
+
+ #{project_members_url}
+
+ MESSAGE
+ end
+
+ def project_members_url
+ Gitlab::Routing.url_helpers.project_project_members_url(project)
+ end
+
def should_run_commit_validations?
commit_check.validate_lfs_file_locks?
end