Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
634a03bf
Commit
634a03bf
authored
Jul 24, 2019
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect project.wiki.git to project wiki home
https://gitlab.com/gitlab-org/gitlab-ce/issues/19186
parent
513daf3d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
0 deletions
+45
-0
changelogs/unreleased/19186-redirect-wiki-git-route-to-wiki.yml
...logs/unreleased/19186-redirect-wiki-git-route-to-wiki.yml
+5
-0
config/routes/git_http.rb
config/routes/git_http.rb
+12
-0
lib/gitlab/path_regex.rb
lib/gitlab/path_regex.rb
+4
-0
spec/routing/git_http_routing_spec.rb
spec/routing/git_http_routing_spec.rb
+24
-0
No files found.
changelogs/unreleased/19186-redirect-wiki-git-route-to-wiki.yml
0 → 100644
View file @
634a03bf
---
title
:
Redirect from a project wiki git route to the project wiki home
merge_request
:
31085
author
:
type
:
added
config/routes/git_http.rb
View file @
634a03bf
...
...
@@ -34,6 +34,18 @@ scope(path: '*namespace_id/:project_id',
end
end
# Redirect /group/project.wiki.git to the project wiki
scope
(
format:
true
,
constraints:
{
project_id:
Gitlab
::
PathRegex
.
project_wiki_git_route_regex
,
format: :git
})
do
wiki_redirect
=
redirect
do
|
params
,
request
|
project_id
=
params
[
:project_id
].
delete_suffix
(
'.wiki'
)
path
=
[
params
[
:namespace_id
],
project_id
,
'wikis'
].
join
(
'/'
)
path
<<
"?
#{
request
.
query_string
}
"
unless
request
.
query_string
.
blank?
path
end
get
'/'
,
to:
wiki_redirect
end
# Redirect /group/project/info/refs to /group/project.git/info/refs
scope
(
constraints:
{
project_id:
Gitlab
::
PathRegex
.
project_route_regex
})
do
# Allow /info/refs, /info/refs?service=git-upload-pack, and
...
...
lib/gitlab/path_regex.rb
View file @
634a03bf
...
...
@@ -175,6 +175,10 @@ module Gitlab
@project_git_route_regex
||=
/
#{
project_route_regex
}
\.git/
.
freeze
end
def
project_wiki_git_route_regex
@project_wiki_git_route_regex
||=
/
#{
PATH_REGEX_STR
}
\.wiki/
.
freeze
end
def
full_namespace_path_regex
@full_namespace_path_regex
||=
%r{
\A
#{
full_namespace_route_regex
}
/
\z
}
end
...
...
spec/routing/git_http_routing_spec.rb
0 → 100644
View file @
634a03bf
# frozen_string_literal: true
require
'spec_helper'
describe
'git_http routing'
do
include
RSpec
::
Rails
::
RequestExampleGroup
describe
'wiki.git routing'
,
'routing'
do
let
(
:wiki_path
)
{
'/gitlab/gitlabhq/wikis'
}
it
'redirects namespace/project.wiki.git to the project wiki'
do
expect
(
get
(
'/gitlab/gitlabhq.wiki.git'
)).
to
redirect_to
(
wiki_path
)
end
it
'preserves query parameters'
do
expect
(
get
(
'/gitlab/gitlabhq.wiki.git?foo=bar&baz=qux'
)).
to
redirect_to
(
"
#{
wiki_path
}
?foo=bar&baz=qux"
)
end
it
'only redirects when the format is .git'
do
expect
(
get
(
'/gitlab/gitlabhq.wiki'
)).
not_to
redirect_to
(
wiki_path
)
expect
(
get
(
'/gitlab/gitlabhq.wiki.json'
)).
not_to
redirect_to
(
wiki_path
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment