summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2015-06-15 10:23:24 -0700
committerH. Peter Anvin <hpa@zytor.com>2015-06-15 10:23:24 -0700
commit1c5915b1030036708e8431c4896250b3ad789b74 (patch)
tree595a118ce8945149a2500115b3a096d8db42bb92
parent2a028ebcb928473473888c506071c7bd097ae752 (diff)
downloadgitweb2cgit-1c5915b1030036708e8431c4896250b3ad789b74.tar.gz
gitweb2cgit-1c5915b1030036708e8431c4896250b3ad789b74.tar.xz
gitweb2cgit-1c5915b1030036708e8431c4896250b3ad789b74.zip
Better handling of tags and snapshots
Better mangling of tags and snapshots, which are our biggest issues, it seems...
-rwxr-xr-xgitweb2cgit.cgi31
1 files changed, 26 insertions, 5 deletions
diff --git a/gitweb2cgit.cgi b/gitweb2cgit.cgi
index 5b4d482..6b7461c 100755
--- a/gitweb2cgit.cgi
+++ b/gitweb2cgit.cgi
@@ -96,6 +96,7 @@ my %actions = (
'rss' => '/atom/',
'atom' => '/atom/',
'heads' => '/refs/heads/',
+ 'tags' => '/refs/tags/',
'snapshot' => '/snapshot/',
);
my $a = $parm{'a'};
@@ -112,6 +113,13 @@ my $hb = $parm{'hb'};
$parm{'id2'} = $hb if (defined($hb));
delete $parm{'hb'};
+# Tag actions which require special handling
+if ($a eq 'shortlog' || $a eq 'log') {
+ if ($h =~ m:^refs/tags/:) {
+ $action = 'tag';
+ }
+}
+
# File
my $f = $parm{'f'};
delete $parm{'f'};
@@ -126,7 +134,7 @@ my $s = $sorts{$parm{'o'}};
$parm{'s'} = $s if (defined($s));
delete $parm{'o'};
-# Tags handling
+# Tags special handling
if ($a eq 'tag') {
$parm{'id'} =~ s:^refs/tags/::; # Drop leading refs/tags
}
@@ -148,12 +156,25 @@ if ($a eq 'snapshot') {
$sf = '.tar.gz' unless ( $sf =~ /^\./ );
delete $parm{'sf'};
- $f = $h;
- if ($h =~ /^([0-9a-f]{40}|HEAD|master)$/ &&
- $p =~ m:^(|.*/)([^/]+)\.git$: ) {
- $f = $2.'-'.$h;
+ # Heuristic to get the short repository name
+ my $r;
+ if ( $p =~ m:^(|.*/)([^/]+)\.git$: ) {
+ $r = $2.'-';
+ } elsif ( $p =~ m:^(|.*/)([^/]+)$: ) {
+ $r = $2.'-';
+ } else {
+ $r = '';
}
+
+ # Don't create names like syslinux-syslinux-blah.tar.gz
+ if (substr($h, 0, length($r)) eq $r) {
+ $f = $h;
+ } else {
+ $f = $r.$h;
+ }
+
$f .= $sf;
+ delete $parm{'id'}; # Already included in the pathname
}
# Build a new URI