From 670a3115c1dd5a285d273d39bd38f466f06dde7c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Jan 2019 11:54:14 +0200 Subject: Add --open-base option to bdep-release --- bdep/release.cli | 13 +++++++++++++ bdep/release.cxx | 34 ++++++++++++++++++++++++++++++---- tests/release.testscript | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/bdep/release.cli b/bdep/release.cli index 12210d1..dd919fa 100644 --- a/bdep/release.cli +++ b/bdep/release.cli @@ -160,6 +160,19 @@ namespace bdep "Open the development cycle with the next major version." } + // We are using string instead of standard_version because its constructor + // is too loose for our needs which means we have to do extra validations + // anyway (pre-release, etc). + // + string --open-base + { + "", + "Open the development cycle with the specified version. The base version + should be in the \c{\i{major}\b{.}\i{minor}\c{.}\i{patch}} form with + the opened version becoming + \c{\i{major}\b{.}\i{minor}\b{.}\i{patch}\b{-a.0.z}}." + } + std::set --force { "", diff --git a/bdep/release.cxx b/bdep/release.cxx index 232df64..cf9438d 100644 --- a/bdep/release.cxx +++ b/bdep/release.cxx @@ -189,6 +189,31 @@ namespace bdep fail << "current version " << cv << " is a snapshot"; } + else if (o.open_base_specified ()) + { + const string& vs (o.open_base ()); + + try + { + standard_version v (vs); + + if (!v.release ()) + throw invalid_argument ("pre-release"); + + if (v.revision != 0) + throw invalid_argument ("contains revision"); + + if (v <= cv) + fail << "base version " << vs << " is less than or equal to " + << "current version " << cv; + + ov = make_snapshot (v.major (), v.minor (), v.patch ()); + } + catch (const invalid_argument& e) + { + fail << "invalid base version '" << vs << "': " << e; + } + } else if (cv.alpha ()) { if (const char* n = (o.open_patch () ? "--open-patch" : @@ -482,7 +507,8 @@ namespace bdep verify ("--open-patch", o.open_patch ()); verify ("--open-minor", o.open_minor ()); verify ("--open-major", o.open_major ()); - verify ("--no-open", o.no_open ()); // Releasing only (see above). + verify ("--open-base", o.open_base_specified ()); + verify ("--no-open", o.no_open ()); // Releasing only (see above). // There is no sense to push without committing the version change first. // Meaningful for all modes. @@ -601,10 +627,10 @@ namespace bdep v = standard_version (vv.value, f); } - catch (const invalid_argument&) + catch (const invalid_argument& e) { - fail << "current package " << n << " version " << vv.value - << " is not standard"; + fail << "current package " << n << " version '" << vv.value + << "' is not standard: " << e; } prj.packages.push_back ( diff --git a/tests/release.testscript b/tests/release.testscript index fe32b85..1e6d5f3 100644 --- a/tests/release.testscript +++ b/tests/release.testscript @@ -290,6 +290,40 @@ log2 = $gp2 log '--pretty=format:"%d %s"' Create EOO } + + : base + : + { + $clone_root_repos; + + $* --open-base 1.0 2>>EOE != 0; + error: invalid base version '1.0': '.' expected after minor version + EOE + + $* --open-base 1.0.0-a.1 2>>EOE != 0; + error: invalid base version '1.0.0-a.1': pre-release + EOE + + $* --open-base 1.2.3 2>>~%EOE%; + %.+ + pushing branch master, tag v0.1.0 + EOE + + $clone2; + $log2 >>:~%EOO%; + % \(HEAD -> master, \.*\) Change version to 1.2.3-a.0.z%d + (tag: v0.1.0) Release version 0.1.0 + Create + EOO + + $* --open-base 1.2.2 2>>EOE != 0; + error: base version 1.2.2 is less than or equal to current version 1.2.3 + EOE + + $* --open-base 1.2.3 2>>EOE != 0 + error: base version 1.2.3 is less than or equal to current version 1.2.3 + EOE + } } : no @@ -974,5 +1008,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"' $* --open --no-tag 2>'error: both --open and --no-tag specified' != 0; $* --tag --no-commit 2>'error: both --tag and --no-commit specified' != 0; $* --push --no-commit 2>'error: both --push and --no-commit specified' != 0; - $* --push --show-push 2>'error: both --push and --show-push specified' != 0 + $* --push --show-push 2>'error: both --push and --show-push specified' != 0; + + $* --open-base 1.2.3 --open-beta 2>'error: both --open-beta and --open-base specified' != 0 } -- cgit v1.1