| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# Created on: 2014-03-11 21:17:31 |
|
3
|
|
|
|
|
|
|
# Create by: Ivan Wills |
|
4
|
|
|
|
|
|
|
# $Id$ |
|
5
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
|
6
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
|
9
|
2
|
|
|
2
|
|
88538
|
use warnings; |
|
|
2
|
|
|
|
|
17
|
|
|
|
2
|
|
|
|
|
50
|
|
|
10
|
2
|
|
|
2
|
|
10
|
use version; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
47
|
|
|
11
|
2
|
|
|
2
|
|
376
|
use English qw/ -no_match_vars /; |
|
|
2
|
|
|
|
|
1919
|
|
|
|
2
|
|
|
|
|
13
|
|
|
12
|
2
|
|
|
2
|
|
549
|
use App::Git::Workflow::Pom; |
|
|
2
|
|
|
|
|
3086
|
|
|
|
2
|
|
|
|
|
10
|
|
|
13
|
2
|
|
|
2
|
|
1421
|
use App::Git::Workflow::Command qw/get_options/; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
110
|
|
|
14
|
2
|
|
|
2
|
|
470
|
|
|
|
2
|
|
|
|
|
28
|
|
|
|
2
|
|
|
|
|
1238
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = version->new(1.1.20); |
|
16
|
|
|
|
|
|
|
our $workflow = App::Git::Workflow::Pom->new; |
|
17
|
|
|
|
|
|
|
our ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs; |
|
18
|
|
|
|
|
|
|
our %option; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
%option = ( |
|
21
|
|
|
|
|
|
|
pom => $workflow->config('workflow.pom') || 'pom.xml', |
|
22
|
10
|
|
100
|
10
|
1
|
42
|
local => $workflow->config('workflow.pom-local'), |
|
23
|
|
|
|
|
|
|
fetch => 1, |
|
24
|
|
|
|
|
|
|
url => $workflow->config('jira.url'), |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
get_options( |
|
27
|
|
|
|
|
|
|
\%option, |
|
28
|
10
|
50
|
|
|
|
39
|
'tag|t=s', |
|
29
|
|
|
|
|
|
|
'branch|b=s', |
|
30
|
|
|
|
|
|
|
'local|l!', |
|
31
|
|
|
|
|
|
|
'pom|x=s', |
|
32
|
|
|
|
|
|
|
'url|u=s', |
|
33
|
|
|
|
|
|
|
'user|U=s', |
|
34
|
|
|
|
|
|
|
'pass|password|P=s', |
|
35
|
|
|
|
|
|
|
'jira|j=s', |
|
36
|
|
|
|
|
|
|
'fetch|f!', |
|
37
|
|
|
|
|
|
|
'new_pom|new-pom|n!', |
|
38
|
|
|
|
|
|
|
'push|p', |
|
39
|
|
|
|
|
|
|
) or return; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# do stuff here |
|
42
|
|
|
|
|
|
|
$workflow->{VERBOSE} = $option{verbose}; |
|
43
|
|
|
|
|
|
|
$workflow->{TEST } = $option{test}; |
|
44
|
10
|
|
|
|
|
21
|
|
|
45
|
10
|
|
|
|
|
19
|
my ($feature_branch) = @ARGV ? shift @ARGV : jira(); |
|
46
|
|
|
|
|
|
|
my ($type, $regex); |
|
47
|
10
|
100
|
|
|
|
27
|
if ($option{tag}) { |
|
48
|
8
|
|
|
|
|
13
|
$type = 'tag'; |
|
49
|
8
|
100
|
|
|
|
23
|
$regex = $option{tag}; |
|
|
|
100
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
3
|
} |
|
51
|
1
|
|
|
|
|
3
|
elsif ($option{branch}) { |
|
52
|
|
|
|
|
|
|
$type = 'branch'; |
|
53
|
|
|
|
|
|
|
$regex = $option{branch}; |
|
54
|
1
|
|
|
|
|
2
|
} |
|
55
|
1
|
|
|
|
|
3
|
else { |
|
56
|
|
|
|
|
|
|
my $default = $workflow->config('workflow.prod'); |
|
57
|
|
|
|
|
|
|
my $prod |
|
58
|
6
|
|
|
|
|
21
|
= $default ? $default |
|
59
|
|
|
|
|
|
|
: $option{local} ? 'branch=^master$' |
|
60
|
|
|
|
|
|
|
: 'branch=^origin/master$'; |
|
61
|
6
|
100
|
|
|
|
17
|
($type, $regex) = split /\s*=\s*/, $prod; |
|
|
|
100
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
6
|
|
|
|
|
30
|
|
|
64
|
|
|
|
|
|
|
$workflow->git->fetch() if $option{fetch}; |
|
65
|
|
|
|
|
|
|
my $release = $workflow->release($type, $option{local}, $regex); |
|
66
|
8
|
100
|
|
|
|
28
|
|
|
67
|
8
|
|
|
|
|
25
|
# checkout branch |
|
68
|
|
|
|
|
|
|
print "Created $feature_branch\n" if $option{verbose}; |
|
69
|
|
|
|
|
|
|
$workflow->git->checkout( '-b', $feature_branch, '--no-track', $release ); |
|
70
|
8
|
100
|
|
|
|
84
|
|
|
71
|
8
|
|
|
|
|
24
|
if ($option{new_pom}) { |
|
72
|
|
|
|
|
|
|
my $version = $workflow->next_pom_version($option{pom}); |
|
73
|
8
|
50
|
|
|
|
17
|
|
|
74
|
0
|
|
|
|
|
0
|
system(qw/mvn versions:set/, "–DnewVersion=$version"); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
0
|
|
|
77
|
|
|
|
|
|
|
# push if requested to |
|
78
|
|
|
|
|
|
|
if ($option{push}) { |
|
79
|
|
|
|
|
|
|
$workflow->git->push( qw/-u origin/, $feature_branch ); |
|
80
|
8
|
100
|
|
|
|
16
|
} |
|
81
|
1
|
|
|
|
|
4
|
|
|
82
|
|
|
|
|
|
|
return; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
8
|
|
|
|
|
20
|
|
|
85
|
|
|
|
|
|
|
die "No JIRA specified!\n" if !$option{jira}; |
|
86
|
|
|
|
|
|
|
die "No JIRA url specified!\n" if !$option{url}; |
|
87
|
|
|
|
|
|
|
require JIRA::REST; |
|
88
|
2
|
50
|
|
2
|
1
|
13
|
|
|
89
|
0
|
0
|
|
|
|
|
my $jira_rest = JIRA::REST->new($option{url}, $option{user}, $option{pass}); |
|
90
|
0
|
|
|
|
|
|
my $issue = $jira_rest->GET("/issue/$option{jira}"); |
|
91
|
|
|
|
|
|
|
my $branch = lc "$option{jira} $issue->{fields}{summary}"; |
|
92
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
# remove unsafe characters |
|
94
|
0
|
|
|
|
|
|
$branch =~ s/[&'" .:!?|\/\\-]+/_/gxms; |
|
95
|
|
|
|
|
|
|
# remove leading and trailing underscores |
|
96
|
|
|
|
|
|
|
$branch =~ s/^_+|_+$//gxms; |
|
97
|
0
|
|
|
|
|
|
# remove doubled underscores |
|
98
|
|
|
|
|
|
|
$branch =~ s/__+/_/gxms; |
|
99
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return $branch; |
|
101
|
0
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 NAME |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
git-feature - Create a feature branch from the "current release" |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 VERSION |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This documentation refers to git-feature version 1.1.20 |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
git-feature [option] branch-name |
|
117
|
|
|
|
|
|
|
git-feature [option] [--jira|-j] JIRAID |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
OPTIONS: |
|
120
|
|
|
|
|
|
|
branch-name The name of the new branch to create from the current release branch/tag |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
-j --jira[=]JIRAID |
|
123
|
|
|
|
|
|
|
Find the summary for JIRA item JIRAID and make it the |
|
124
|
|
|
|
|
|
|
branch name for the feature. |
|
125
|
|
|
|
|
|
|
-u --url[=]URL Use URL as the JIRA instance for looking up summaries. |
|
126
|
|
|
|
|
|
|
-U --user[=]str JIRA user name to use when querying JIRA |
|
127
|
|
|
|
|
|
|
-P --password[=]str |
|
128
|
|
|
|
|
|
|
JIRA password for --user |
|
129
|
|
|
|
|
|
|
-t --tag[=]str Specify a tag that any branch with newer commits must contain |
|
130
|
|
|
|
|
|
|
-b --branch[=]str Similarly a branch that other branches with newer commits must |
|
131
|
|
|
|
|
|
|
contain (Default origin/master) |
|
132
|
|
|
|
|
|
|
-l --local Shorthand for --branch '^master$' |
|
133
|
|
|
|
|
|
|
-p --push Push the new brach upstream |
|
134
|
|
|
|
|
|
|
--no-fetch Don't fetch before trying to find the remote branch |
|
135
|
|
|
|
|
|
|
-n --new-pom Set the pom.xml version to the next available version |
|
136
|
|
|
|
|
|
|
-x --pom[=]dir/pom.xml |
|
137
|
|
|
|
|
|
|
The location of the master pom.xml if it isn't in the |
|
138
|
|
|
|
|
|
|
current directory. |
|
139
|
|
|
|
|
|
|
-t --test Test, don't actually run |
|
140
|
|
|
|
|
|
|
-v --verbose Show more details |
|
141
|
|
|
|
|
|
|
--version Prints the version information |
|
142
|
|
|
|
|
|
|
--help Prints this help information |
|
143
|
|
|
|
|
|
|
--man Prints the full documentation for git-feature |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The C<git feature> command allows a simplified way to create and switch to |
|
148
|
|
|
|
|
|
|
feature branches using whatever you define as the I<current release>. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
By default I<current release> is defined as the I<origin/master> branch that |
|
151
|
|
|
|
|
|
|
can be changed either on the command line using the --tag or --branch |
|
152
|
|
|
|
|
|
|
arguments or by setting the C<workflow.prod> git config. Example of commonly |
|
153
|
|
|
|
|
|
|
used alternatives include using release version tags where you might use |
|
154
|
|
|
|
|
|
|
something like C<--tag ^v\d+[.]\d+'> to match tags like v0.1 or v1.0 etc. |
|
155
|
|
|
|
|
|
|
Other examples include different branches containing release versions of |
|
156
|
|
|
|
|
|
|
code. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The branch I<origin/master> is used over I<master> to save you from having |
|
159
|
|
|
|
|
|
|
to switch to master and pull any new changes. A C<git fetch> is called by |
|
160
|
|
|
|
|
|
|
default before branching to further ensure the latest version of code is |
|
161
|
|
|
|
|
|
|
available. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 C<run ()> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Executes the git workflow command |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 C<jira ()> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Create a branch name from the JIRA summary |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Defaults for this script can be set through C<git config> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
workflow.prod Sets how a prod release is determined |
|
180
|
|
|
|
|
|
|
eg the default equivalent is branch=^origin/master$ |
|
181
|
|
|
|
|
|
|
workflow.pom The default location for the pom.xml file (used by C<--new-pom> |
|
182
|
|
|
|
|
|
|
when updating pom.xml for the new branch) |
|
183
|
|
|
|
|
|
|
workflow.pom-local |
|
184
|
|
|
|
|
|
|
Can set default value of C<--local> |
|
185
|
|
|
|
|
|
|
jira.url Specifies the URL for the JIRA instance being used |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
You can set these values either by editing the repository local C<.git/config> |
|
188
|
|
|
|
|
|
|
file or C<~/.gitconfig> or use the C<git config> command |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# eg Setting the global value |
|
191
|
|
|
|
|
|
|
git config --global workflow.prod 'branch=^origin/master$' |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# or set a repository's local value |
|
194
|
|
|
|
|
|
|
git config workflow.prod 'tag=^release_\d{4}_\d{2}\d{2}$' |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# or setting pom.xml location to a sub directory |
|
197
|
|
|
|
|
|
|
git config workflow.pom 'somedir/pom.xml' |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
There are no known bugs in this module. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Patches are welcome. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
|
218
|
|
|
|
|
|
|
All rights reserved. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
|
221
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
|
222
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
223
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
224
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |