Ryan Lane has submitted this change and it was merged.
Change subject: Rewrite gerrit gitweb URLs to new gitblit
......................................................................
Rewrite gerrit gitweb URLs to new gitblit
This replaces the rewrite rule for message URLs with something more
general that handles p=project and p=project;f=file URLs.
It works on my local Apache instance.
Bug: 41961
Change-Id: If02ce0fe0ddd8a9b692a0d2526bdbed27a762fc4
---
M templates/apache/sites/gerrit.wikimedia.org.erb
1 file changed, 37 insertions(+), 2 deletions(-)
Approvals:
Ryan Lane: Looks good to me, approved
jenkins-bot: Verified
diff --git a/templates/apache/sites/gerrit.wikimedia.org.erb
b/templates/apache/sites/gerrit.wikimedia.org.erb
index 9356191..1b6f25d 100644
--- a/templates/apache/sites/gerrit.wikimedia.org.erb
+++ b/templates/apache/sites/gerrit.wikimedia.org.erb
@@ -89,8 +89,43 @@
AllowEncodedSlashes On
RewriteEngine On
- RewriteCond %{QUERY_STRING}
^p=mediawiki/core\.git;a=blob_plain;f=languages/messages/([a-zA-Z_]+)\.php;hb=HEAD$
- RewriteRule ^/r/gitweb$
https://git.wikimedia.org/raw/mediawiki\%2Fcore.git/HEAD/languages\%2Fmessages\%2F%1.php
[R=301,L,NE]
+
+ # Rewrite old gerrit gitweb URLs to redirect to new gitblit server.
+ # Here are some sample URLs that should continue to work
+ #
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Agora.git;hb=HEAD;
+ #
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob_plain;f=languages/messages/MessagesEn.php;hb=HEAD
+ #
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/examples.git;hb=HEAD;f=BoilerPlate/README;
+ #
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/ArticleFeedback.git;hb=HEAD;f=modules/jquery.articleFeedback/images/star-new-down.png;a=raw;
+ #
+ # Notes
+ # 1. gitblit requires URL-encoding (%2F) of the slashes in the matched
+ # paths to project and file. The [B] option together with
+ # 'AllowEncodedSlashes NoDecode' does this; it also converts '.' in
+ # .git and .php to "%2e" , gitblit accepts this. (If this causes
+ # problems with other URLs you could use
+ # RewriteMap esc int:escape
+ # and ${esc:%1} for the paths, and probably have to add [noescape]
option).
+ # 2. Append an empty query string (which mod_rewrite is smart enough to
+ # drop), otherwise the original query string is appended -- mod_rewrite
+ # lacks a DiscardQueryString option.
+ # 3. You can't have separate RewriteCond for p= and f= because the
+ # RewriteRule can only reference matches from the last RewriteCond.
+ # (You could use [N] to re-run the rewriting process after rewriting
+ # for each parameter ... agggh.)
+ # 4. To avoid complicated "p= at start or preceded with ;", stick ';'
on front.
+ # 5. The semicolon-separated parameters p and f can be in any order, so
look
+ # for p anywhere and add it back at the front.
+ # 6. gitweb parameters not handled: a=<some other action>, hb=<some
+ # commit>, and #l123 line number fragment.
+ #
+ # Rewrite a gitweb project link (no file).
+ RewriteCond ;%{QUERY_STRING} !;f=
+ RewriteCond ;%{QUERY_STRING} ;p=([^;]*)
+ RewriteRule ^/r/gitweb$ https://git.wikimedia.org/summary/%1/HEAD?
[R=301,L,B]
+ # Rewrite a gitweb file link (project and file, in any order).
+ RewriteCond ;%{QUERY_STRING} ;p=([^;]*)
+ RewriteCond ;p=%1;%{QUERY_STRING} ^;p=([^;]*).*;f=([^;]*)
+ RewriteRule ^/r/gitweb$ https://git.wikimedia.org/raw/%1/HEAD/%2?
[R=301,L,B]
ProxyPass /r/ http://127.0.0.1:8080/r/ retry=0 nocanon
--
To view, visit https://gerrit.wikimedia.org/r/70370
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If02ce0fe0ddd8a9b692a0d2526bdbed27a762fc4
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Spage <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Lcarr <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits