diff options
author | Eric Wong <e@80x24.org> | 2019-01-15 08:22:41 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-19 03:34:54 +0000 |
commit | 53ac5b18f6f124fe33bf6736aac0b8c85a0d0d1b (patch) | |
tree | 3ffa99bd583cccf1c4d3ee0b8a9f88a01111a273 /lib/PublicInbox/Git.pm | |
parent | ecacd5d9c9604bf2fe235f2ff4a79e9668fd5010 (diff) | |
download | public-inbox-53ac5b18f6f124fe33bf6736aac0b8c85a0d0d1b.tar.gz |
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"
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r-- | lib/PublicInbox/Git.pm | 16 |
1 files changed, 16 insertions, 0 deletions
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 |