line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-PluginBundle-Git-CheckFor |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2012 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch; |
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RSRCHBOY'; |
12
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch::VERSION = '0.013'; |
13
|
|
|
|
|
|
|
# ABSTRACT: Check that you're on the correct branch before release |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
279699
|
use Moose; |
|
1
|
|
|
|
|
121604
|
|
|
1
|
|
|
|
|
8
|
|
16
|
1
|
|
|
1
|
|
6396
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1171
|
|
|
1
|
|
|
|
|
8
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with |
19
|
|
|
|
|
|
|
'Dist::Zilla::Role::BeforeRelease', |
20
|
|
|
|
|
|
|
'Dist::Zilla::Role::Git::Repo::More', |
21
|
|
|
|
|
|
|
; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
0
|
2487882
|
sub mvp_multivalue_args { qw(release_branch) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has release_branch => ( |
26
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
27
|
|
|
|
|
|
|
traits => ['Array'], |
28
|
|
|
|
|
|
|
handles => { release_branch => 'elements' }, |
29
|
|
|
|
|
|
|
default => sub { [ 'master' ] }, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub current_branch { |
33
|
4
|
|
|
4
|
0
|
9
|
my $self = shift @_; |
34
|
|
|
|
|
|
|
|
35
|
4
|
100
|
|
|
|
196
|
my ($branch) = map { /^\*\s+(.+)/ ? $1 : () } $self->_repo->branch; |
|
8
|
|
|
|
|
29466
|
|
36
|
4
|
|
|
|
|
24
|
return $branch; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub before_release { |
40
|
4
|
|
|
4
|
0
|
371349
|
my $self = shift @_; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
27
|
my $cbranch = $self->current_branch; |
43
|
4
|
|
|
|
|
521
|
my @rbranch = $self->release_branch; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
45
|
my $fatal_msg |
46
|
|
|
|
|
|
|
= !$cbranch ? 'Cannot determine current branch!' |
47
|
|
|
|
|
|
|
: $cbranch eq '(no branch)' ? 'You do not appear to be on any branch. This is almost certainly an error.' |
48
|
4
|
100
|
|
|
|
38
|
: (!grep { $cbranch eq $_ } @rbranch) ? "Your current branch ($cbranch) is not the release branch (". join(', ', @rbranch). ")" |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
49
|
|
|
|
|
|
|
: undef |
50
|
|
|
|
|
|
|
; |
51
|
|
|
|
|
|
|
|
52
|
4
|
100
|
|
|
|
30
|
$self->log_fatal($fatal_msg) if $fatal_msg; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# if we're here, we're good |
55
|
2
|
|
|
|
|
36
|
$self->log("Current branch ($cbranch) and release branch match (" . join(', ', @rbranch) .')'); |
56
|
2
|
|
|
|
|
1090
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
!!42; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=for :stopwords Chris Weyl Christian Doherty Etheridge Karen Mengué Mike Olivier Walde |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=for :stopwords Wishlist flattr flattr'ed gittip gittip'ed |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch - Check that you're on the correct branch before release |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VERSION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This document describes version 0.013 of Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch - released March 10, 2015 as part of Dist-Zilla-PluginBundle-Git-CheckFor. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
; in dist.ini |
84
|
|
|
|
|
|
|
[Git::CheckFor::CorrectBranch] |
85
|
|
|
|
|
|
|
; release_branch defaults to 'master' |
86
|
|
|
|
|
|
|
release_branch = master |
87
|
|
|
|
|
|
|
release_branch = stable |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# on branch topic/geewhiz... |
90
|
|
|
|
|
|
|
$ dzil release # ABENDs! |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# ...and on branch master |
93
|
|
|
|
|
|
|
$ dzil release # succeeds |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# ...and on branch stable |
96
|
|
|
|
|
|
|
$ dzil release # succeeds |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is a simple L<Dist::Zilla> plugin to check that you are on the correct |
101
|
|
|
|
|
|
|
branch before allowing a release... Its reason for existance is to prevent |
102
|
|
|
|
|
|
|
accidental releases being cut from topic branches: which are in general not |
103
|
|
|
|
|
|
|
unrecoverable, but annoying, messy, and (sometimes) embarrassing. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=for Pod::Coverage current_branch before_release mvp_multivalue_args |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 OPTIONS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 release_branch |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is the name of the branch it is legal to release from: it defaults to |
112
|
|
|
|
|
|
|
'master'. Multiple branches may be specified; you may want to allow 'master' |
113
|
|
|
|
|
|
|
and 'stable'. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SEE ALSO |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Git::CheckFor|Dist::Zilla::PluginBundle::Git::CheckFor> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L<Dist::Zilla> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::Git> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SOURCE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The development version is on github at L<http://https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor> |
138
|
|
|
|
|
|
|
and may be cloned from L<git://https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor.git> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 BUGS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
143
|
|
|
|
|
|
|
https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor/issues |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
146
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
147
|
|
|
|
|
|
|
feature. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 I'm a material boy in a material world |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=begin html |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
<a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a> |
158
|
|
|
|
|
|
|
<a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a> |
159
|
|
|
|
|
|
|
<a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fdist-zilla-pluginbundle-git-checkfor&title=RsrchBoy's%20CPAN%20Dist-Zilla-PluginBundle-Git-CheckFor&tags=%22RsrchBoy's%20Dist-Zilla-PluginBundle-Git-CheckFor%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=end html |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Please note B<I do not expect to be gittip'ed or flattr'ed for this work>, |
164
|
|
|
|
|
|
|
rather B<it is simply a very pleasant surprise>. I largely create and release |
165
|
|
|
|
|
|
|
works like this because I need them or I find it enjoyable; however, don't let |
166
|
|
|
|
|
|
|
that stop you if you feel like it ;) |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<Flattr this|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fdist-zilla-pluginbundle-git-checkfor&title=RsrchBoy's%20CPAN%20Dist-Zilla-PluginBundle-Git-CheckFor&tags=%22RsrchBoy's%20Dist-Zilla-PluginBundle-Git-CheckFor%20in%20the%20CPAN%22>, |
169
|
|
|
|
|
|
|
L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my |
170
|
|
|
|
|
|
|
L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Chris Weyl. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software, licensed under: |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |