X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwCoderepo.pm;h=01ed562b6fd35f8dedabcedc15aa175d781eca62;hb=2bc26fececd03705c68c1968f95a2d199bafec29;hp=e0fc90459d209b1a7299a550f09235723880d360;hpb=87e742835126e37d8f09c35321f9dd07f233dd45;p=public-inbox.git diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm index e0fc9045..01ed562b 100644 --- a/lib/PublicInbox/WwwCoderepo.pm +++ b/lib/PublicInbox/WwwCoderepo.pm @@ -12,6 +12,7 @@ use PublicInbox::Git; use PublicInbox::GitAsyncCat; use PublicInbox::WwwStream; use PublicInbox::Hval qw(ascii_html); +use PublicInbox::RepoSnapshot; my $EACH_REF = "git for-each-ref --sort=-creatordate --format='%(HEAD)%00". join('%00', map { "%($_)" } @@ -23,9 +24,9 @@ sub prepare_coderepos { my $pi_cfg = $self->{pi_cfg}; # TODO: support gitweb and other repository viewers? - if (defined(my $cgitrc = $pi_cfg->{-cgitrc_unparsed})) { - $pi_cfg->parse_cgitrc($cgitrc, 0); - } + defined($pi_cfg->{'publicinbox.cgitrc'}) and + $pi_cfg->parse_cgitrc(undef, 0); + my $code_repos = $pi_cfg->{-code_repos}; for my $k (grep(/\Acoderepo\.(?:.+)\.dir\z/, keys %$pi_cfg)) { $k = substr($k, length('coderepo.'), -length('.dir')); @@ -40,6 +41,11 @@ sub new { my ($cls, $pi_cfg) = @_; my $self = bless { pi_cfg => $pi_cfg }, $cls; prepare_coderepos($self); + $self->{snapshots} = do { + my $s = $pi_cfg->{'coderepo.snapshots'} // ''; + $s eq 'all' ? \%PublicInbox::RepoSnapshot::FMT_TYPES : + +{ map { $_ => 1 } split(/\s+/, $s) }; + }; $self->{$_} = 10 for qw(summary_branches summary_tags); $self->{$_} = 10 for qw(summary_log); $self; @@ -55,8 +61,16 @@ sub summary_finish { # git log my @r = split(/\n/s, pop(@x) // ''); my $last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_log}; - print $zfh '
$ '.
-		"git log --pretty=format:'%h %s (%cs)%d'\n";
+	print $zfh <
+about heads tags
+
+\$ git log --pretty=format:'%h %s (%cs)%d'
+EOM
 	for (@r) {
 		my $d; # decorations
 		s/^ \(([^\)]+)\)// and $d = $1;
@@ -103,13 +117,28 @@ sub summary_finish {
 		"%(refname:short) %(subject) (%(creatordate:short))'\n";
 	@r = split(/^/sm, shift(@x) // '');
 	$last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_tags};
+	my @s = sort keys %{$ctx->{wcr}->{snapshots}};
+	my $n;
+	if (@s) {
+		$n = $ctx->{git}->local_nick // die "BUG: $ctx->{git_dir} nick";
+		$n =~ s/\.git\z/-/;
+		($n) = ($n =~ m!([^/]+)\z!);
+		$n = ascii_html($n);
+	}
 	for (@r) {
 		my (undef, $oid, $ref, $s, $cd) = split(/\0/);
 		utf8::decode($_) for ($ref, $s);
 		chomp $cd;
 		my $align = length($ref) < 12 ? ' ' x (12 - length($ref)) : '';
 		print $zfh "", ascii_html($ref),
-			"$align ", ascii_html($s), " ($cd)\n";
+			"$align ", ascii_html($s), " ($cd)";
+		if (@s) {
+			my $v = $ref;
+			$v =~ s/\A[vV]//;
+			print $zfh "\t",  join(' ', map {
+				qq{$_} } @s);
+		}
+		print $zfh "\n";
 	}
 	print $zfh "# no tags yet...\n" if !@r;
 	print $zfh "...\n" if $last;
@@ -175,6 +204,14 @@ sub srv { # endpoint called by PublicInbox::WWW
 			($ctx->{git} = $self->{"\0$1"}) and
 		return PublicInbox::ViewVCS::show($ctx, $2);
 
+	# snapshots:
+	if ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and
+			($ctx->{git} = $self->{"\0$1"})) {
+		$ctx->{wcr} = $self;
+		return PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404);
+	}
+
+	# enforce trailing slash:
 	if ($path_info =~ m!\A/(.+?)\z! and ($git = $self->{"\0$1"})) {
 		my $qs = $ctx->{env}->{QUERY_STRING};
 		my $url = $git->base_url($ctx->{env});