aboutsummaryrefslogtreecommitdiffstats
path: root/stattrans.pl
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2018-05-31 10:10:41 +0100
committerSteve McIntyre <steve@einval.com>2018-05-31 10:10:41 +0100
commite0c5859f85967520d65a8361a066e1e3f84ace6e (patch)
treee14fb836e9f3129527fdcd2c3c2c32d31dce09e6 /stattrans.pl
parent6d46b2dad858368a60bc52f193b70d968bee2b74 (diff)
Add more useful links for git/salsa diffs
Gitlab doesn't give us an interface for direct diffs on a per-file basis. Instead, add a link to the commit diff and a git command line that people can use for the direct per-file diff.
Diffstat (limited to 'stattrans.pl')
-rwxr-xr-xstattrans.pl69
1 files changed, 51 insertions, 18 deletions
diff --git a/stattrans.pl b/stattrans.pl
index 2e56506bae3..7e8a7b30ac0 100755
--- a/stattrans.pl
+++ b/stattrans.pl
@@ -396,7 +396,7 @@ if ($config{'difftype'} eq 'u') {
}
sub vcs_log_url {
- my ($path) = @_;
+ my ($path, $rev) = @_;
if ($VCSHOST =~ m/alioth/) {
return "$VCSBASE/$path#rev$rev";
@@ -443,6 +443,16 @@ sub vcs_raw_url {
}
}
+# Return a shortened version string to make things less unwieldy
+sub short {
+ my $in = shift;
+ if ($VCSHOST =~ m/salsa/) {
+ return substr $in, 0, 12; # 12 is a common length people use for git
+ } else {
+ return $in;
+ }
+}
+
print "Creating files: " if ($config{'verbose'});
foreach $lang (@search_in) {
my @processed_langs = ($langs{$lang});
@@ -489,26 +499,45 @@ foreach $lang (@search_in) {
} else {
if (defined $status_db{$lang}) {
if ($transversion{"$lang/$file"} ne ''){
- $o_body .= sprintf '<td><a title=\'<gettext domain="stats">Unified diff</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
- vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, 'u' ),
- $transversion{"$lang/$file"}, $version{"$orig/$file"};
- $o_body .= sprintf '<a title=\'<gettext domain="stats">Colored diff</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
- vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, 'h' ),
- $transversion{"$lang/$file"}, $version{"$orig/$file"};
- $o_body .= "$statspan</td>";
+ if ($VCSHOST =~ m/alioth/) {
+ $o_body .= sprintf '<td><a title=\'<gettext domain="stats">Unified diff</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
+ vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, 'u' ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ $o_body .= sprintf '<a title=\'<gettext domain="stats">Colored diff</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
+ vcs_diff_url( "$orig/$file", short($transversion{"$lang/$file"}), short($version{"$orig/$file"}), 'h' ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ $o_body .= "$statspan</td>";
+ } else {
+ $o_body .= sprintf '<td><a title=\'<gettext domain="stats">Commit diff</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
+ vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, 'u' ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ # FIXME - this is clearly wrong, but no idea what's meant to go here!
+ $o_body .= sprintf '<a title=\'<gettext domain="stats">Git command line</gettext>\' href="%s">%s&nbsp;→&nbsp;%s</a> ',
+ vcs_diff_url( "$orig/$file", short($transversion{"$lang/$file"}), short($version{"$orig/$file"}), 'h' ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ $o_body .= "$statspan</td>";
+ }
} else {
$o_body .= sprintf "<td>%d (%.2f&nbsp;&permil;)</td>", $sizes{$file}, $sizes{$file}/$nsize * 1000;
}
} else {
- $o_body .= sprintf "<td><a href=\"%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
- vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, $firstdifftype ),
- $transversion{"$lang/$file"}, $version{"$orig/$file"};
- $o_body .= sprintf "<td><a href=\"%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
- vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, $seconddifftype ),
- $transversion{"$lang/$file"}, $version{"$orig/$file"};
+ if ($VCSHOST =~ m/alioth/) {
+ $o_body .= sprintf "<td><a href=\"%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
+ vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, $firstdifftype ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ $o_body .= sprintf "<td><a href=\"%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
+ vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, $seconddifftype ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ } else {
+ $o_body .= sprintf "<td><a href=\"%s\">%s\&nbsp;->\&nbsp;%s</a></td>",
+ vcs_diff_url( "$orig/$file", $transversion{"$lang/$file"}, $version{"$orig/$file"}, $firstdifftype ),
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"});
+ $o_body .= sprintf "<td>git diff %s..%s -- %s</td>",
+ short($transversion{"$lang/$file"}), short($version{"$orig/$file"}), "$orig/$file";
+ }
}
}
- $o_body .= sprintf "<td><a title=\"%s\" href=\"%s#rev%s\">[L]</a></td>", $msg, vcs_log_url("$orig/$file"), $version{"$orig/$file"};
+ $o_body .= sprintf "<td><a title=\"%s\" href=\"%s\">[L]</a></td>", $msg, vcs_log_url("$orig/$file", $version{"$orig/$file"});
$o_body .= sprintf "<td><a href=\"%s\">[V]</a>\&nbsp;", vcs_view_url("$lang/$file");
$o_body .= sprintf "<a href=\"%s\">[F]</a></td>", vcs_raw_url("$lang/$file");
$o_body .= sprintf "<td align=center>%s</td>", $maintainer{"$lang/$file"} || "";
@@ -633,9 +662,13 @@ foreach $lang (@search_in) {
} else {
print HTML '<th><gettext domain="stats">Comment</gettext></th>'."\n";
print HTML '<th><gettext domain="stats">Diffstat</gettext></th>'."\n";
- if ($opt_d eq "u") { print HTML '<th><gettext domain="stats">Unified diff</gettext></th><th><gettext domain="stats">Colored diff</gettext></th>'; }
- elsif ($opt_d eq "h") { print HTML '<th><gettext domain="stats">Colored diff</gettext></th><th><gettext domain="stats">Unified diff</gettext></th>'; }
- else { print HTML '<th><gettext domain="stats">Diff</gettext></th>'; }
+ if ($VCSHOST =~ m/alioth/) {
+ if ($opt_d eq "u") { print HTML '<th><gettext domain="stats">Unified diff</gettext></th><th><gettext domain="stats">Colored diff</gettext></th>'; }
+ elsif ($opt_d eq "h") { print HTML '<th><gettext domain="stats">Colored diff</gettext></th><th><gettext domain="stats">Unified diff</gettext></th>'; }
+ else { print HTML '<th><gettext domain="stats">Diff</gettext></th>'; }
+ } else {
+ print HTML '<th><gettext domain="stats">Commit diff</gettext></th><th><gettext domain="stats">Git command line</gettext></th>';
+ }
}
print HTML '<th><gettext domain="stats">Log</gettext></th>';
print HTML '<th><gettext domain="stats">Translation</gettext></th>';

© 2014-2024 Faster IT GmbH | imprint | privacy policy