From dde66ebd390ffd99589d759e7203bfd37f06cde0 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 25 Apr 2019 05:41:22 +0200 Subject: [PATCH] proxies-redirects: Add rewrite for cgit on src.fp.o (#7736) --- playbooks/include/proxies-redirects.yml | 9 +++++++++ .../redirect/templates/redirect.cgit.conf | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 roles/httpd/redirect/templates/redirect.cgit.conf diff --git a/playbooks/include/proxies-redirects.yml b/playbooks/include/proxies-redirects.yml index 795020c203..1b92cd4882 100644 --- a/playbooks/include/proxies-redirects.yml +++ b/playbooks/include/proxies-redirects.yml @@ -17,6 +17,15 @@ - role: packages3/bugz.fp.o website: bugz.fedoraproject.org + # A special rewrite for cgit + - role: httpd/redirect + shortname: cgit + website: src.fedoraproject.org + # Staging-only for now, due to F30 final freeze + # XXX deploy to production after freeze ends + when: env == "staging" + tags: + - cgit # Various app redirects - role: httpd/redirect diff --git a/roles/httpd/redirect/templates/redirect.cgit.conf b/roles/httpd/redirect/templates/redirect.cgit.conf new file mode 100644 index 0000000000..88002f0405 --- /dev/null +++ b/roles/httpd/redirect/templates/redirect.cgit.conf @@ -0,0 +1,19 @@ +RewriteEngine on + +# commit ID +RewriteCond %{QUERY_STRING} (^|&)id=([^&]+)($|&) +RewriteRule ^/cgit/([-._+a-zA-Z0-9/]+)\.git/commit/?$ /$1/c/%2? [R,L] + +# plain file at commit ID +RewriteCond %{QUERY_STRING} (^|&)id=([^&]+)($|&) +RewriteRule ^/cgit/([-._+a-zA-Z0-9/]+)\.git/plain/(.*) /$1/raw/%2/f/$2? [R,L] + +# plain file at ref +RewriteCond %{QUERY_STRING} (^|&)h=([^&]+)($|&) +RewriteRule ^/cgit/([-._+a-zA-Z0-9/]+)\.git/plain/(.*) /$1/raw/%2/f/$2? [R,L] + +# plain file at HEAD +RewriteRule ^/cgit/([-._+a-zA-Z0-9/]+)\.git/plain/(.*) /$1/raw/HEAD/f/$2? [R,L] + +# main project page +RewriteRule ^/cgit/([-._+a-zA-Z0-9/]+)\.git/?$ /$1? [R,L]