public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob f0cb4b3d2c4a5da73ccda8e964b8c50b25655412 1326 bytes (raw)
$ git show repobrowse:lib/PublicInbox/Repo.pm	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
# Copyright (C) 2017 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Represents a code repository, analoguos to the PublicInbox::Inbox
# class for represpenting an inbox git repository.
package PublicInbox::Repo;
use strict;
use warnings;
use PublicInbox::Config;

sub new {
	my ($class, $opts) = @_;
	bless $opts, $class;
}

sub description {
	my ($self) = @_;
	my $desc = $self->{description};
	return $desc if defined $desc;
	return unless $self->{vcs} eq 'git'; # TODO

	$desc = PublicInbox::Config::try_cat("$self->{path}/description");
	local $/ = "\n";
	chomp $desc;
	$desc =~ s/\s+/ /smg;
	$desc = '($GIT_DIR/description missing)' if $desc eq '';
	$self->{description} = $desc;
}

sub desc_html {
	my ($self) = @_;
	$self->{desc_html} ||=
		PublicInbox::Hval->utf8($self->description)->as_html;
}

sub cloneurl {
	my ($self) = @_;
	my $url = $self->{cloneurl};
	return $url if $url;
	if ($self->{vcs} eq 'git') {
		$url = PublicInbox::Config::try_cat("$self->{path}/cloneurl");
		$url = [ split(/\s+/s, $url) ];
		local $/ = "\n";
		chomp @$url;
	}
	$self->{cloneurl} = $url;
}

sub tip {
	my ($self) = @_;
	$self->{-tip} ||= do {
		if ($self->{vcs} eq 'git') {
			my $t = $self->{git}->qx(qw(symbolic-ref --short HEAD));
			chomp $t;
			$t;
		}
	};
}

1;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git