From 74d010e9ca446f7a736f9215a961f6728f6047be Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 11 Mar 2019 22:56:51 +0300 Subject: Add --edit and --no-edit options to bdep-release --- bdep/release.cli | 16 ++++++++++++++++ bdep/release.cxx | 21 +++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'bdep') 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 --force { "", 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) -- cgit v1.1