diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-01-25 11:54:14 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-26 15:38:54 +0300 |
commit | 670a3115c1dd5a285d273d39bd38f466f06dde7c (patch) | |
tree | cb8994b3d13ea04c7a3a2a50a4fad6666fe4d45f /bdep | |
parent | 698bbc675764f3aec648aa242a99e89859065454 (diff) |
Add --open-base option to bdep-release
Diffstat (limited to 'bdep')
-rw-r--r-- | bdep/release.cli | 13 | ||||
-rw-r--r-- | bdep/release.cxx | 34 |
2 files changed, 43 insertions, 4 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 + { + "<version>", + "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<string> --force { "<check>", 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 ( |