| 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.014'; |
|
13
|
|
|
|
|
|
|
# ABSTRACT: Check that you're on the correct branch before release |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
267892
|
use Moose; |
|
|
1
|
|
|
|
|
106565
|
|
|
|
1
|
|
|
|
|
7
|
|
|
16
|
1
|
|
|
1
|
|
5371
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
5642
|
|
|
|
1
|
|
|
|
|
3
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with |
|
19
|
|
|
|
|
|
|
'Dist::Zilla::Role::BeforeRelease', |
|
20
|
|
|
|
|
|
|
'Dist::Zilla::Role::Git::Repo::More', |
|
21
|
|
|
|
|
|
|
; |
|
22
|
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
0
|
3313538
|
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
|
|
|
|
179
|
my ($branch) = map { /^\*\s+(.+)/ ? $1 : () } $self->_repo->branch; |
|
|
8
|
|
|
|
|
19212
|
|
|
36
|
4
|
|
|
|
|
22
|
return $branch; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub before_release { |
|
40
|
4
|
|
|
4
|
0
|
320370
|
my $self = shift @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
22
|
my $cbranch = $self->current_branch; |
|
43
|
4
|
|
|
|
|
268
|
my @rbranch = $self->release_branch; |
|
44
|
|
|
|
|
|
|
|
|
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
|
|
|
|
22
|
: (!grep { $cbranch eq $_ } @rbranch) ? "Your current branch ($cbranch) is not the release branch (". join(', ', @rbranch). ")" |
|
|
5
|
50
|
|
|
|
35
|
|
|
|
|
50
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
: undef |
|
50
|
|
|
|
|
|
|
; |
|
51
|
|
|
|
|
|
|
|
|
52
|
4
|
100
|
|
|
|
23
|
$self->log_fatal($fatal_msg) if $fatal_msg; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# if we're here, we're good |
|
55
|
2
|
|
|
|
|
30
|
$self->log("Current branch ($cbranch) and release branch match (" . join(', ', @rbranch) .')'); |
|
56
|
2
|
|
|
|
|
868
|
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.014 of Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch - released October 10, 2016 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 BUGS |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
138
|
|
|
|
|
|
|
L<https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor/issues> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
141
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
142
|
|
|
|
|
|
|
feature. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 I'm a material boy in a material world |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=begin html |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
<a href="https://gratipay.com/RsrchBoy/"><img src="http://img.shields.io/gratipay/RsrchBoy.svg" /></a> |
|
153
|
|
|
|
|
|
|
<a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a> |
|
154
|
|
|
|
|
|
|
<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> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=end html |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Please note B<I do not expect to be gittip'ed or flattr'ed for this work>, |
|
159
|
|
|
|
|
|
|
rather B<it is simply a very pleasant surprise>. I largely create and release |
|
160
|
|
|
|
|
|
|
works like this because I need them or I find it enjoyable; however, don't let |
|
161
|
|
|
|
|
|
|
that stop you if you feel like it ;) |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<Flattr|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>, |
|
164
|
|
|
|
|
|
|
L<Gratipay|https://gratipay.com/RsrchBoy/>, or indulge my |
|
165
|
|
|
|
|
|
|
L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If and *only* if you so desire. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Chris Weyl. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is free software, licensed under: |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |