Last active
August 29, 2015 14:10
-
-
Save mricon/345d28f6b68872ec1bd6 to your computer and use it in GitHub Desktop.
Gitweb to CGit rewrites used at git.kernel.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Legacy redirects for /linus/ and /tip/ | |
rewrite ^/linus/(\w+)$ /cgit/linux/kernel/git/torvalds/linux.git/commit/?id=$1? permanent; | |
rewrite ^/linus/.*h=(\w+)$ /cgit/linux/kernel/git/torvalds/linux.git/commit/?id=$1? permanent; | |
rewrite ^/linus/$ /cgit/linux/kernel/git/torvalds/linux.git? permanent; | |
rewrite ^/tip/(\w+)$ /cgit/linux/kernel/git/tip/tip.git/commit/?id=$1? permanent; | |
rewrite ^/tip/.*h=(\w+)$ /cgit/linux/kernel/git/tip/tip.git/commit/?id=$1? permanent; | |
rewrite ^/tip/$ /cgit/linux/kernel/git/tip/tip.git? permanent; | |
if ($request_uri ~ "^/cgit") { | |
break; | |
} | |
if ($args = "") { | |
rewrite ^/$ https://git.kernel.org/cgit/? permanent; | |
rewrite ^$ https://git.kernel.org/cgit/? permanent; | |
} | |
if ($args !~ "p=") { | |
break; | |
} | |
if ($args ~ "p=([^;]*)") { | |
set $projectpath /cgit/$1; | |
} | |
if ($projectpath = "/cgit/linux/kernel/git/torvalds/linux-2.6.git") { | |
set $projectpath /cgit/linux/kernel/git/torvalds/linux.git; | |
} | |
if ($args !~ "a=") { | |
rewrite ^ $projectpath? permanent; | |
} | |
if ($args ~ "a=summary") { | |
rewrite ^ $projectpath? permanent; | |
} | |
set $id ""; | |
if ($args ~ "h=([^;]*)") { | |
set $id id=$1; | |
set $h $1; | |
} | |
if ($args ~ "a=commit;") { | |
rewrite ^ $projectpath/commit/?$id? permanent; | |
} | |
if ($args ~ "a=tag") { | |
# tags don't map directly | |
rewrite ^ $projectpath/commit/?$id? permanent; | |
} | |
# shortlog and log go to the same place | |
if ($args ~ "a=shortlog") { | |
rewrite ^ $projectpath/log/?$id? permanent; | |
} | |
if ($args ~ "a=log") { | |
rewrite ^ $projectpath/log/?$id? permanent; | |
} | |
# We don't support snapshots, so just redirect to viewing that commit | |
if ($args ~ "a=snapshot") { | |
rewrite ^ $projectpath/commit/?$id? permanent; | |
} | |
set $rssref "h=master"; | |
if ($args ~ "h=refs/heads/([^;]+)") { | |
set $rssref "h=$1"; | |
} | |
if ($args ~ "a=atom") { | |
rewrite ^ $projectpath/atom/?$rssref? permanent; | |
} | |
if ($args ~ "a=rss") { | |
rewrite ^ $projectpath/atom/?$rssref? permanent; | |
} | |
# Generics below | |
if ($args ~ "hb=([^;]*)") { | |
set $hb $1; | |
} | |
if ($args ~ "hp=([^;]*)") { | |
set $hp $1; | |
} | |
if ($args ~ "hpb=([^;]*)") { | |
set $hpb $1; | |
} | |
if ($args ~ "f=([^;]*)") { | |
set $filepath $1; | |
} | |
# | |
# Nginx notoriously doesn't support nested IF/ELSE expressions. | |
# So, don't blame me if what you see below is incomprehensible. | |
# | |
# common combinations of "f=, h=, hb=" | |
set $test ""; | |
if ($args ~ "f=") { | |
set $test "${test}:f"; | |
} | |
if ($args ~ "h=") { | |
set $test "${test}:h"; | |
} | |
if ($args ~ "hp=") { | |
set $test "${test}:hp"; | |
} | |
if ($args ~ "hb=") { | |
set $test "${test}:hb"; | |
} | |
if ($args ~ "hpb=") { | |
set $test "${test}:hpb"; | |
} | |
set $component "tree"; | |
if ($args ~ "a=blob_plain") { | |
set $component "plain"; | |
} | |
if ($args ~ "a=history") { | |
set $component "log"; | |
} | |
if ($args ~ "a=commitdiff") { | |
set $component "commit"; | |
} | |
if ($args ~ "a=commitdiff_plain") { | |
set $component "patch"; | |
} | |
if ($args ~ "a=patch") { | |
set $component "patch"; | |
} | |
if ($args ~ "a=blobdiff") { | |
set $component "diff"; | |
} | |
if ($test = "") { | |
rewrite ^ $projectpath/$component/? permanent; | |
} | |
if ($test = ":f") { | |
rewrite ^ $projectpath/$component/$filepath? permanent; | |
} | |
if ($test = ":h") { | |
rewrite ^ $projectpath/$component/?id=$h? permanent; | |
} | |
if ($test = ":hb") { | |
rewrite ^ $projectpath/$component/?id=$hb? permanent; | |
} | |
if ($test = ":h:hb") { | |
rewrite ^ $projectpath/$component/?id=$hb? permanent; | |
} | |
if ($test = ":f:h") { | |
rewrite ^ $projectpath/$component/$filepath?id=$h? permanent; | |
} | |
if ($test = ":f:hb") { | |
rewrite ^ $projectpath/$component/$filepath?id=$hb? permanent; | |
} | |
if ($test = ":f:h:hb") { | |
rewrite ^ $projectpath/$component/$filepath?id=$hb? permanent; | |
} | |
# diff-specific | |
if ($test ~ ":f.*:hb:hpb") { | |
rewrite ^ $projectpath/$component/$filepath?id=$hb&id2=$hpb? permanent; | |
} | |
if ($test ~ ":f:h:hp") { | |
rewrite ^ $projectpath/$component/$filepath?id=$h&id2=$hp? permanent; | |
} | |
if ($test ~ ":hb:hpb") { | |
rewrite ^ $projectpath/$component/?id=$hb&id2=$hpb? permanent; | |
} | |
if ($test ~ ":h:hp") { | |
rewrite ^ $projectpath/$component/?id=$h&id2=$hp? permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment