line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
2
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
3
|
|
|
|
|
|
|
package Git::Open::Util; |
4
|
2
|
|
|
2
|
|
8
|
use Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has remote_url => ( |
7
|
|
|
|
|
|
|
is => 'ro', |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
default => sub { |
10
|
|
|
|
|
|
|
for (`git ls-remote --get-url`) { |
11
|
|
|
|
|
|
|
chomp; |
12
|
|
|
|
|
|
|
if (/^git@/) { # Change protocal to http if git |
13
|
|
|
|
|
|
|
s/:/\//; # Change : to / |
14
|
|
|
|
|
|
|
s/^git@/https:\/\//; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
s/\.git$//; # Remove .git at the end |
17
|
|
|
|
|
|
|
return $_; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has current_branch => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
default => sub { |
26
|
|
|
|
|
|
|
my $current_branch = `git symbolic-ref --short HEAD`; |
27
|
|
|
|
|
|
|
chomp $current_branch; |
28
|
|
|
|
|
|
|
return $current_branch; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has service => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
default => sub { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
$self->remote_url =~ m|//([a-z]+)\.|; |
38
|
|
|
|
|
|
|
return $1; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub generate_url { |
43
|
6
|
|
|
6
|
0
|
55
|
my $self = shift; |
44
|
6
|
|
|
|
|
9
|
my $args = shift; |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
8
|
my $suffix = ''; |
47
|
6
|
100
|
|
|
|
22
|
if( defined $args->{compare} ) { |
|
|
100
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
6
|
if( $args->{compare} eq '' ) { |
49
|
2
|
|
|
|
|
4
|
$suffix = 'compare'; |
50
|
|
|
|
|
|
|
}else { |
51
|
0
|
|
|
|
|
0
|
my @branches = split( /-/, $args->{compare} ); |
52
|
0
|
|
|
|
|
0
|
$suffix = $self->_url_pattern( 'compare' ); |
53
|
0
|
|
|
|
|
0
|
foreach my $i ( 0..1 ) { |
54
|
0
|
|
|
|
|
0
|
$suffix =~ s/_$i/$branches[$i]/; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
}elsif ( defined $args->{branch} ) { |
58
|
2
|
|
33
|
|
|
51
|
my $branch = $args->{branch} || $self->current_branch; |
59
|
2
|
|
|
|
|
8
|
$suffix = $self->_url_pattern( 'branch' ); |
60
|
2
|
|
|
|
|
7
|
$suffix =~ s/_0/$branch/; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
120
|
return $self->remote_url.'/'.$suffix; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _url_pattern { |
67
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
68
|
2
|
|
|
|
|
4
|
my $view = shift; |
69
|
2
|
|
|
|
|
11
|
my $mapping_pattern = { |
70
|
|
|
|
|
|
|
github => { |
71
|
|
|
|
|
|
|
compare => 'compare/_0..._1', |
72
|
|
|
|
|
|
|
branch => 'tree/_0' |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
bitbucket => { |
75
|
|
|
|
|
|
|
compare => 'compare/_0.._1', |
76
|
|
|
|
|
|
|
branch => 'src?at=_0' |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
43
|
return $mapping_pattern->{$self->service}->{$view}; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding UTF-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Git::Open::Util |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 0.1.12 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Pattarawat Chormai <pat.chormai@gmail.com> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Pattarawat Chormai. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |