From 9869b64641f5197bd495a5e62cdbb3f985adbeee Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 18 Feb 2010 21:40:40 -0800 Subject: [PATCH] put gitweb links into diagnostics --- build-pspp | 30 ++++++++++++++++--------- results2html | 63 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/build-pspp b/build-pspp index be84459c48..2fff2c853e 100755 --- a/build-pspp +++ b/build-pspp @@ -115,18 +115,26 @@ sub save_result_if_exists { } } +sub ref_to_commit { + my ($ref) = @_; + my $commit = `$GIT rev-parse $ref`; + chomp $commit; + return $commit; +} + my $GIT = "git --git-dir=$topdir/.git"; if (@ARGV == 2) { my ($repo, $branch) = @ARGV; - # Fetch branch - start_step ("Fetch $repo, branch $branch"); + start_step ("Fetch branch from Git"); + set_var ("git_repo", $repo); + set_var ("git_branch", $branch); run ("$GIT fetch $repo +$branch:refs/builds/$build_number/pspp"); # Get revision number. - my $revision = `$GIT rev-parse refs/builds/$build_number/pspp`; - chomp $revision; + set_var ("pspp_ref", "refs/builds/$build_number/pspp"); + my $revision = ref_to_commit ("refs/builds/$build_number/pspp"); set_var ("pspp_commit", $revision); my $abbrev_commit = substr ($revision, 0, 6); @@ -153,7 +161,7 @@ if (@ARGV == 2) { } } close (MAKEFILE_AM); - set_var ("am_mode", $am_mode); + print LOG "Automake mode is $am_mode\n"; # Generate version number for build. # We want to append -g012345, but if we're in Gnits mode and the @@ -227,12 +235,13 @@ EOF or die "rename $fullname.new to $fullname failed: $!\n"; # If we don't already have that Gnulib commit, update Gnulib. - system ("$GIT rev-parse --verify --quiet $gnulib_commit"); + system ("$GIT rev-parse --verify --quiet $gnulib_commit > /dev/null"); if ($? != 0) { start_step ("Updating Gnulib to obtain commit"); run ("$GIT fetch gnulib"); } run ("$GIT update-ref refs/builds/$build_number/gnulib $gnulib_commit"); + set_var ("gnulib_ref", "refs/builds/$build_number/gnulib"); # Extract gnulib source. start_step ("Extract Gnulib source"); @@ -267,16 +276,15 @@ EOF start_step ("Build developers guide"); run ("cd pspp && GENDOCS_TEMPLATE_DIR=$topdir $topdir/gendocs.sh -s doc/pspp-dev.texinfo -o $resultsdir/dev-guide --email bug-gnu-pspp\@gnu.org pspp-dev \"GNU PSPP Developers Guide\"", "dev-guide"); saved_result ("Developers Guide", "dev-guide"); +} else { + $tarball = saved_result ("source distribution", $tarball); } if ($build_binary) { start_step ("Save tarball to Git"); run ("GIT_DIR=$topdir/.git $topdir/git-import-tar $tarball refs/builds/$build_number/dist", "git-dist"); - - start_step ("Determining $tarball target directory"); - my $sample_filename = `zcat $tarball | tar tf - | head -1`; - my ($tarball_dir) = $sample_filename =~ m%^(?:[./])*([^/]+)/%; - set_var ("dist_dir", $tarball_dir); + set_var ("dist_ref", "refs/builds/$build_number/dist"); + set_var ("dist_commit", ref_to_commit ("refs/builds/$build_number/dist")); start_step ("Extracting source tarball"); run ("zcat $tarball | (cd $builddir && tar xf -)"); diff --git a/results2html b/results2html index 4bf398d35c..4e3224fca3 100755 --- a/results2html +++ b/results2html @@ -5,6 +5,9 @@ use warnings; use File::Spec; use HTML::Entities; +use URI::Escape; + +my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]'; open (LOG, '<', "LOG"); open (LOG_HTML, '>', "log.html"); @@ -37,6 +40,8 @@ my (@products); my (@steps); my ($new_page) = 0; my ($result) = "failure"; +my (%dist_files); +my ($dist_dir); my @dirstack; while () { my $ln = $.; @@ -59,7 +64,7 @@ while () { if ($new_page) { $new_page = 0; $log_class = "step"; - if (my ($name, $product) = /^Saving(?:([^:]*):)?\s+(.*)$/) { + if (my ($name, $product) = /^Saving(?:\s+([^:]*):)?\s+(.*)$/) { my $href = "$product/index.html"; $href = $product if ! -e $href; @@ -70,6 +75,19 @@ while () { $p{LN} = $ln; push (@products, \%p); push (@{$steps[$#steps]{CHILDREN}}, \%p); + + if (defined ($name) && $name eq 'source distribution') { + open (DIST, '-|', "zcat $product | tar tf -"); + while (my $line = ) { + chomp $line; + $line =~ s%^([./])*%%; # Trim leading ./ + $dist_files{$line} = 1; + if (!defined ($dist_dir)) { + $dist_dir = (split ('/', $line))[0]; + } + } + close (DIST); + } } else { my (%s); $s{TITLE} = $_; @@ -84,19 +102,30 @@ while () { $d{MESSAGE} = $_; $d{LN} = $ln; - if (@dirstack && (my ($file, $line) = /^([^\s:]+):(\d+):\s/)) { + if (@dirstack && defined ($dist_dir) + && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) { $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]); my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file)); - for (my $i = 0; $i < $#path; ) { - if ($path[$i + 1] eq '..') { - splice (@path, $i, 2); + for (my $i = 1; $i <= $#path; ) { + if ($path[$i] eq '..') { + splice (@path, $i - 1, 2); + $i-- if $i > 1; } else { $i++; } } - $d{LINE} = $line; - $d{FILE} = join ('/', @path); + for (my $i = $#path; $i >= 0; $i--) { + if ($path[$i] eq $dist_dir) { + my $dist_file = join ('/', @path[$i..$#path]); + if (exists ($dist_files{$dist_file})) { + $d{MATCH} = length ($match); + $d{LINE} = $line; + $d{FILE} = $dist_file; + } + last; + } + } } push (@{$steps[$#steps]{CHILDREN}}, \%d); @@ -158,12 +187,22 @@ foreach my $s (@steps) { foreach my $c (@{$s->{CHILDREN}}) { if (defined ($c->{DIAGNOSTIC})) { print INDEX "

{DIAGNOSTIC}\">"; - print INDEX "{LN}\">"; - print INDEX encode_entities ($c->{MESSAGE}); - print INDEX ""; - if (exists $c->{FILE}) { - print INDEX " in $c->{FILE}"; + if (defined ($c->{MATCH})) { + my $href = $gitweb_url; + $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge; + $href =~ s/\[LINE\]/$c->{LINE}/g; + $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e; + + print INDEX ''; + print INDEX encode_entities (substr ($c->{MESSAGE}, + 0, $c->{MATCH})); + print INDEX ''; + print INDEX encode_entities (substr ($c->{MESSAGE}, + $c->{MATCH})); + } else { + print INDEX encode_entities ($c->{MESSAGE}); } + print INDEX " ", log_link ($c->{LN}); print INDEX "

\n"; } else { print INDEX "

{HREF}), "\">"; -- 2.30.2