diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-03-11 22:56:51 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-03-12 12:50:02 +0300 |
commit | 74d010e9ca446f7a736f9215a961f6728f6047be (patch) | |
tree | fe4630b7af1563decba7442432eee1524aca1c29 | |
parent | 9e75650b59e4cd580c07e2ff50788019108cd194 (diff) |
Add --edit and --no-edit options to bdep-release
-rw-r--r-- | bdep/release.cli | 16 | ||||
-rw-r--r-- | bdep/release.cxx | 21 | ||||
-rw-r--r-- | tests/release.testscript | 7 |
3 files changed, 35 insertions, 9 deletions
diff --git a/bdep/release.cli b/bdep/release.cli index dd919fa..2dadb7f 100644 --- a/bdep/release.cli +++ b/bdep/release.cli @@ -57,6 +57,12 @@ namespace bdep the remote as well as \cb{--open} which performs the opening of the next development cycle as described above. + In all the modes that perform a commit, if the project's repository index + already contains other changes, then the commit message is automatically + opened for editing unless \cb{--no-edit} is specified. The editing of the + commit message in the absence of other changes can be requested with the + \cb{--edit} option. + Normally, \cb{release} operates on all the packages in a project. If no project directory is specified, then the current working directory is assumed and all the packages are released, even if the current directory @@ -173,6 +179,16 @@ namespace bdep \c{\i{major}\b{.}\i{minor}\b{.}\i{patch}\b{-a.0.z}}." } + bool --edit + { + "Open the commit message for editing." + } + + bool --no-edit + { + "Don't open the commit message for editing." + } + std::set<string> --force { "<check>", diff --git a/bdep/release.cxx b/bdep/release.cxx index cb74957..c6eef28 100644 --- a/bdep/release.cxx +++ b/bdep/release.cxx @@ -493,11 +493,13 @@ namespace bdep gopt = o.revision () ? nullptr : mopt; verify ("--no-tag", o.no_tag ()); - // The following option is only meaningful for the releasing, revising, - // and opening modes. + // The following (mutually exclusive) options are only meaningful for + // the releasing, revising, and opening modes. // gopt = o.revision () || o.open () ? nullptr : mopt; verify ("--no-commit", o.no_commit ()); + verify ("--edit", o.edit ()); + verify ("--no-edit", o.no_edit ()); // The following (mutually exclusive) options are only meaningful for // the releasing and opening modes. @@ -772,9 +774,11 @@ namespace bdep return 1; } - // Stage and commit the project changes. + // Stage and commit the project changes. Open the commit message in the + // editor if requested and --no-edit is not specified or if --edit is + // specified. // - auto commit_project = [&prj] (const string& msg) + auto commit_project = [&o, &prj] (const string& msg, bool edit) { // We shouldn't have any untracked files or unstaged changes other than // our modifications, so -a is good enough. @@ -784,6 +788,7 @@ namespace bdep "commit", verb < 1 ? "-q" : verb >= 2 ? "-v" : nullptr, "-a", + (edit && !o.no_edit ()) || o.edit () ? "-e" : nullptr, "-m", msg); }; @@ -858,7 +863,11 @@ namespace bdep else m = "Release version " + pkg.release_version->string (); - commit_project (m); + commit_project (m, st.staged); + + // The (possibly) staged changes are now committed. + // + st.staged = false; } // Tag. @@ -923,7 +932,7 @@ namespace bdep // Commit the manifest rewrites. // - commit_project ("Change version to " + ov); + commit_project ("Change version to " + ov, st.staged); } if (push) diff --git a/tests/release.testscript b/tests/release.testscript index 2ab961b..2f63265 100644 --- a/tests/release.testscript +++ b/tests/release.testscript @@ -529,7 +529,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"' : changes-staged : { - test.arguments += --push + test.arguments += --push --no-edit +$clone_repos @@ -803,7 +803,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"' echo '' >+ prj/prj/manifest; $gp add prj/manifest; - $release --revision -q --yes -d prj/prj; + $release --revision -q --yes --no-edit -d prj/prj; echo '' >+ prj/prj/manifest; $gp add prj/manifest; @@ -811,7 +811,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"' echo '' >+ prj/libprj/manifest; $gp add libprj/manifest; - $* --revision 2>>~%EOE%; + $* --revision --no-edit 2>>~%EOE%; %Updated tag 'v0.1.0' \(was \.*\)%d EOE @@ -1014,6 +1014,7 @@ log2 = $gp2 log '--pretty=format:"%d %s"' $* --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; + $* --edit --no-commit 2>'error: both --no-commit and --edit specified' != 0; $* --open-base 1.2.3 --open-beta 2>'error: both --open-beta and --open-base specified' != 0 } |