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 ++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) (limited to 'bdep') 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 ( -- cgit v1.1