diff options
author | Robert Speicher <robert@gitlab.com> | 2016-02-29 17:50:40 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-02-29 17:50:40 +0000 |
commit | edf5e9eb05ce4a3aa68740f5139dc333a4f887d4 (patch) | |
tree | 6bddeb7ad0aee9d95000165cedd2fbfc0798fb45 | |
parent | 6f85eb38516ae23969c34eab3d31f85bb5df9177 (diff) | |
parent | 3ac202c30f3fdabc5189d411dfe5e7871b948070 (diff) | |
download | gitlab-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
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/api/internal.rb | 13 | ||||
-rw-r--r-- | spec/requests/api/internal_spec.rb | 12 |
3 files changed, 23 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index 9e897644af0..d3e28dcfc76 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.6.0 (unreleased) - Improve the formatting for the user page bio (Connor Shea) + - Fix issue when pushing to projects ending in .wiki - Fix avatar stretching by providing a cropping feature (Johann Pardanaud) - Strip leading and trailing spaces in URL validator (evuez) - Update documentation to reflect Guest role not being enforced on internal projects 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) diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 8d0ae1475c2..22802dd0e05 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -54,6 +54,18 @@ describe API::API, api: true do project.team << [user, :developer] end + context "git push with project.wiki" do + it 'responds with success' do + project_wiki = create(:project, name: 'my.wiki', path: 'my.wiki') + project_wiki.team << [user, :developer] + + push(key, project_wiki) + + expect(response.status).to eq(200) + expect(json_response["status"]).to be_truthy + end + end + context "git pull" do it do pull(key, project) |