summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-02-29 17:50:40 +0000
committerRobert Speicher <robert@gitlab.com>2016-02-29 17:50:40 +0000
commitedf5e9eb05ce4a3aa68740f5139dc333a4f887d4 (patch)
tree6bddeb7ad0aee9d95000165cedd2fbfc0798fb45 /lib
parent6f85eb38516ae23969c34eab3d31f85bb5df9177 (diff)
parent3ac202c30f3fdabc5189d411dfe5e7871b948070 (diff)
downloadgitlab-ce-edf5e9eb05ce4a3aa68740f5139dc333a4f887d4.tar.gz
Merge branch 'fix/project-wiki-ending' into 'master'
Fix for project paths ending in .wiki This prevents `Git operation was rejected by pre-receive hook` when an actual project ending with .wiki is thought to be a wiki by the `Internal` API. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/13742 See merge request !2960
Diffstat (limited to 'lib')
-rw-r--r--lib/api/internal.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index e38736fc28b..2200208b946 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -14,6 +14,14 @@ module API
# ref - branch name
# forced_push - forced_push
#
+
+ helpers do
+ def wiki?
+ @wiki ||= params[:project].end_with?('.wiki') &&
+ !Project.find_with_namespace(params[:project])
+ end
+ end
+
post "/allowed" do
status 200
@@ -30,13 +38,12 @@ module API
# Strip out the .wiki from the pathname before finding the
# project. This applies the correct project permissions to
# the wiki repository as well.
- wiki = project_path.end_with?('.wiki')
- project_path.chomp!('.wiki') if wiki
+ project_path.chomp!('.wiki') if wiki?
project = Project.find_with_namespace(project_path)
access =
- if wiki
+ if wiki?
Gitlab::GitAccessWiki.new(actor, project)
else
Gitlab::GitAccess.new(actor, project)