From 53ac5b18f6f124fe33bf6736aac0b8c85a0d0d1b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Jan 2019 08:22:41 +0000 Subject: solver: initial Perl implementation This will lookup git blobs from associated git source code repositories. If the blobs can't be found, an attempt to "solve" them via patch application will be performed. Eventually, this may become the basis of a type-agnostic frontend similar to "git show" --- lib/PublicInbox/Git.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 90b9214a..9676086f 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -40,6 +40,7 @@ sub new { my ($class, $git_dir) = @_; my @st; $st[7] = $st[10] = 0; + # may contain {-wt} field (working-tree (File::Temp::Dir)) bless { git_dir => $git_dir, st => \@st }, $class } @@ -201,6 +202,21 @@ sub packed_bytes { sub DESTROY { cleanup(@_) } +# show the blob URL for cgit/gitweb/whatever +sub src_blob_url { + my ($self, $oid) = @_; + # blob_fmt = "https://example.com/foo.git/blob/%s" + if (my $bfu = $self->{blob_fmt_url}) { + return sprintf($bfu, $oid); + } + + # don't show full FS path, basename should be OK: + if ($self->{git_dir} =~ m!/([^/]+)\z!) { + return "/path/to/$1"; + } + '???'; +} + 1; __END__ =pod -- cgit v1.2.3-24-ge0c7