ShipIt/Step/FindVersion.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 49 CC 5 SCAR 29.7
CC
5
Cov
0%
run
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 19.5
1 package ShipIt::Step::FindVersion;
2 use strict;
3 use base 'ShipIt::Step';
4 use ShipIt::Util qw($term);
5  
6 # return if okay, die if problems.
7 sub run {
8 my ($self, $state) = @_;
9 my $ver = $state->pt->current_version;
10  
11 my $is_tagged = $state->vc->exists_tagged_version($ver);
12  
13 print "Current version is: $ver\n";
14 my $def = "";
15  
16 # if the current version isn't tagged, use that as the default. (they
17 # probably already ran shipit and bumped the version, but perhaps
18 # make dist or a test failed or something, so they're re-running it...)
19 $def = "[$ver] " unless $is_tagged;
20  
21 my $newver = $term ? $term->readline("Next/release version? $def") : undef;
22 $newver ||= $ver;
23  
24 # are they just compulsively running shipit? i.e., they just asked for same
25 # version as something tagged & no local diffs....
26 if ($is_tagged && $newver eq $ver && ! $state->vc->are_local_diffs($ver)) {
27 die "No local changes, and version on disk is already tagged. Nothing to do.\n";
28 }
29  
30 # check to make sure they're not releasing a version that's already tagged
31 if ($state->vc->exists_tagged_version($newver)) {
32 die "Sorry, version '$newver' is already tagged. Stopping.\n";
33 }
34  
35 $state->set_version($newver);
36 }
37  
38 1;