From d78f3fa8f39541937f4212c65030295205e140ce Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 27 Feb 2020 09:48:58 +1100 Subject: [PATCH] static: fix git raw file redirect When converting this from a htaccess file to run in the virtualhost context, one instance of '^cgit' -> '^/cgit' was missed. Fix it, and add a coverage test for it to testinfra. Change-Id: Icc1dae6dce232e69c5cd1cf98b594f562c60d3f2 --- playbooks/roles/static/templates/git-redirects.conf.j2 | 2 +- testinfra/test_static.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playbooks/roles/static/templates/git-redirects.conf.j2 b/playbooks/roles/static/templates/git-redirects.conf.j2 index 9dda0b47d5..fbed8fa430 100644 --- a/playbooks/roles/static/templates/git-redirects.conf.j2 +++ b/playbooks/roles/static/templates/git-redirects.conf.j2 @@ -103,7 +103,7 @@ RewriteCond %{QUERY_STRING} h=([\w/]+) RewriteRule "^/cgit/(.*?)/(.*?)/plain/?(.*)" "https://opendev.org/$1/$2/raw/branch/%1/$3" [L,QSD] # if there's no args: -RewriteRule "^cgit/(.*?)/(.*?)/plain/?(.*)" "https://opendev.org/$1/$2/raw/branch/master/$3" [L,QSD] +RewriteRule "^/cgit/(.*?)/(.*?)/plain/?(.*)" "https://opendev.org/$1/$2/raw/branch/master/$3" [L,QSD] ###################### # commit tab (with file) -> commit screen (without file) diff --git a/testinfra/test_static.py b/testinfra/test_static.py index f6f08946a8..aa0bb9b1aa 100644 --- a/testinfra/test_static.py +++ b/testinfra/test_static.py @@ -138,7 +138,9 @@ git_redirects = ( 'https://opendev.org/openstack/tripleo-ansible/commit/a6f9b1551baf5f680c05f4fa69ac926f8a0a3f81'), ('git.starlingx.io/stx-tools', 'https://opendev.org/openstack/stx-tools'), ('git.zuul-ci.org/zuul', 'https://opendev.org/openstack-infra/zuul'), - ('git.airshipit.org/airship-in-a-bottle', 'https://opendev.org/openstack/airship-in-a-bottle') + ('git.airshipit.org/airship-in-a-bottle', 'https://opendev.org/openstack/airship-in-a-bottle'), + ('git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt', + 'https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt') ) @pytest.mark.parametrize("url,target", git_redirects)