line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Plugin-Git |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2009 by Jerome Quelin. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Dist::Zilla::Role::Git::Repo; |
10
|
|
|
|
|
|
|
# ABSTRACT: Provide repository information for Git plugins |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '2.048'; |
13
|
|
|
|
|
|
|
|
14
|
20
|
|
|
20
|
|
465330
|
use Moose::Role; |
|
20
|
|
|
|
|
62
|
|
|
20
|
|
|
|
|
333
|
|
15
|
20
|
|
|
20
|
|
111540
|
use Types::Standard qw(Str Maybe); |
|
20
|
|
|
|
|
53
|
|
|
20
|
|
|
|
|
241
|
|
16
|
20
|
|
|
20
|
|
18976
|
use namespace::autoclean; |
|
20
|
|
|
|
|
51
|
|
|
20
|
|
|
|
|
215
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has repo_root => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Str, |
21
|
|
|
|
|
|
|
lazy => 1, |
22
|
|
|
|
|
|
|
builder => '_build_repo_root', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_repo_root |
26
|
|
|
|
|
|
|
{ |
27
|
54
|
|
|
54
|
|
228
|
my $self = shift; |
28
|
54
|
|
|
|
|
2240
|
$self->zilla->root->stringify; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#pod =method current_git_branch |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod $branch = $plugin->current_git_branch; |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod The current branch in the repository, or C<undef> if the repository |
36
|
|
|
|
|
|
|
#pod has a detached HEAD. Note: This value is cached; it will not |
37
|
|
|
|
|
|
|
#pod be updated if the branch is changed during the run. |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod =cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has current_git_branch => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => Maybe[Str], |
44
|
|
|
|
|
|
|
lazy => 1, |
45
|
|
|
|
|
|
|
builder => '_build_current_git_branch', |
46
|
|
|
|
|
|
|
init_arg => undef, # Not configurable |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _build_current_git_branch |
50
|
|
|
|
|
|
|
{ |
51
|
2
|
|
|
2
|
|
47
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Git 1.7+ allows "rev-parse --abbrev-ref HEAD", but we want to support 1.5.4 |
54
|
2
|
|
|
|
|
23
|
my ($branch) = $self->git->RUN(qw(symbolic-ref -q HEAD)); |
55
|
|
|
|
|
|
|
|
56
|
20
|
|
|
20
|
|
4468
|
no warnings 'uninitialized'; |
|
20
|
|
|
|
|
52
|
|
|
20
|
|
|
|
|
5126
|
|
57
|
2
|
50
|
|
|
|
23300
|
undef $branch unless $branch =~ s!^refs/heads/!!; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
334
|
$branch; |
60
|
|
|
|
|
|
|
} # end _build_current_git_branch |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#pod =method git |
63
|
|
|
|
|
|
|
#pod |
64
|
|
|
|
|
|
|
#pod $git = $plugin->git; |
65
|
|
|
|
|
|
|
#pod |
66
|
|
|
|
|
|
|
#pod This method returns a Git::Wrapper object for the C<repo_root> |
67
|
|
|
|
|
|
|
#pod directory, constructing one if necessary. The object is shared |
68
|
|
|
|
|
|
|
#pod between all plugins that consume this role (if they have the same |
69
|
|
|
|
|
|
|
#pod C<repo_root>). |
70
|
|
|
|
|
|
|
#pod |
71
|
|
|
|
|
|
|
#pod =cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my %cached_wrapper; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
around dump_config => sub |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
my $orig = shift; |
78
|
|
|
|
|
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $config = $self->$orig; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
83
|
|
|
|
|
|
|
repo_root => $self->repo_root, |
84
|
|
|
|
|
|
|
git_version => $self->git->version, |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $config; |
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub git { |
91
|
147
|
|
|
147
|
1
|
7581
|
my $root = shift->repo_root; |
92
|
|
|
|
|
|
|
|
93
|
147
|
|
66
|
|
|
3673
|
$cached_wrapper{$root} ||= do { |
94
|
45
|
|
|
|
|
778
|
require Git::Wrapper; |
95
|
45
|
|
|
|
|
1387
|
Git::Wrapper->new( $root ); |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding UTF-8 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Dist::Zilla::Role::Git::Repo - Provide repository information for Git plugins |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 2.048 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 DESCRIPTION |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This role is used within the Git plugins to get information about the |
118
|
|
|
|
|
|
|
repository structure, and to create a Git::Wrapper object. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 repo_root |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The repository root, either as a full path or relative to the distribution |
125
|
|
|
|
|
|
|
root. The default is the distribution root (C<$zilla->root>). |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 METHODS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 current_git_branch |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$branch = $plugin->current_git_branch; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The current branch in the repository, or C<undef> if the repository |
134
|
|
|
|
|
|
|
has a detached HEAD. Note: This value is cached; it will not |
135
|
|
|
|
|
|
|
be updated if the branch is changed during the run. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 git |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$git = $plugin->git; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This method returns a Git::Wrapper object for the C<repo_root> |
142
|
|
|
|
|
|
|
directory, constructing one if necessary. The object is shared |
143
|
|
|
|
|
|
|
between all plugins that consume this role (if they have the same |
144
|
|
|
|
|
|
|
C<repo_root>). |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SUPPORT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Git> |
149
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-Git@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Git@rt.cpan.org>). |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
152
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
155
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Jerome Quelin |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Jerome Quelin. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
166
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |