| 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; |