Skip to content

Commit 652e305

Browse files
authored
Merge pull request #110 from ruby/cgit-ref-redirect
Redirect cgit ref browsing and range diffs to GitHub
2 parents 9170912 + 24bbddd commit 652e305

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

recipes/files/etc/apache2/sites-available/git.ruby-lang.org.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,21 @@
4141
RewriteRule ^/ruby\.git/tree/(.*)$ https://github.com/ruby/ruby/tree/%1/$1 [R=302,L,NE,QSD]
4242
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{7,40})
4343
RewriteRule ^/ruby\.git/plain/(.*)$ https://github.com/ruby/ruby/raw/%1/$1 [R=302,L,NE,QSD]
44+
45+
# Range diffs (id2= without id=) are the heaviest cgit operation.
46+
RewriteCond %{QUERY_STRING} (?:^|&)id2=([0-9a-fA-F]{7,40})
47+
RewriteRule ^/ruby\.git/(?:diff|patch)(?:/.*)?$ https://github.com/ruby/ruby/compare/%1...master [R=302,L,NE,QSD]
48+
49+
# Browse by ref (h=) -> GitHub, except branches under active
50+
# development which we still want to browse on cgit.
51+
RewriteCond %{QUERY_STRING} (?:^|&)h=(?!(?:master|ruby_3_[345]|ruby_4_0)(?:&|$))([^&]+)
52+
RewriteRule ^/ruby\.git/log(?:/.*)?$ https://github.com/ruby/ruby/commits/%1 [R=302,L,NE,QSD]
53+
RewriteCond %{QUERY_STRING} (?:^|&)h=(?!(?:master|ruby_3_[345]|ruby_4_0)(?:&|$))([^&]+)
54+
RewriteRule ^/ruby\.git/(?:commit|diff|patch)(?:/.*)?$ https://github.com/ruby/ruby/commit/%1 [R=302,L,NE,QSD]
55+
RewriteCond %{QUERY_STRING} (?:^|&)h=(?!(?:master|ruby_3_[345]|ruby_4_0)(?:&|$))([^&]+)
56+
RewriteRule ^/ruby\.git/tree/(.*)$ https://github.com/ruby/ruby/tree/%1/$1 [R=302,L,NE,QSD]
57+
RewriteCond %{QUERY_STRING} (?:^|&)h=(?!(?:master|ruby_3_[345]|ruby_4_0)(?:&|$))([^&]+)
58+
RewriteRule ^/ruby\.git/plain/(.*)$ https://github.com/ruby/ruby/raw/%1/$1 [R=302,L,NE,QSD]
59+
RewriteCond %{QUERY_STRING} !(?:^|&)h=
4460
RewriteRule ^/ruby\.git/plain/(.*)$ https://github.com/ruby/ruby/raw/master/$1 [R=302,L,NE,QSD]
4561
</VirtualHost>

0 commit comments

Comments
 (0)