aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-09-09 20:19:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-09-10 09:32:16 +0300
commit9771466fc4f95df639e76c8bd511856c4300af02 (patch)
tree5c678fbeaba2a91680d5b87ae86bed365a46f511
parentdf19364adef814237b8afd156d3bd1a33d16b318 (diff)
Allow using package names in bdep-releaseHEADmaster
-rw-r--r--bdep/release.cli4
-rw-r--r--bdep/release.cxx59
-rw-r--r--tests/release.testscript101
3 files changed, 149 insertions, 15 deletions
diff --git a/bdep/release.cli b/bdep/release.cli
index 4e69283..64d2d37 100644
--- a/bdep/release.cli
+++ b/bdep/release.cli
@@ -15,14 +15,14 @@ namespace bdep
{
"<options>
<prj-spec> <prj-dir>
- <pkg-spec> <pkg-dir>",
+ <pkg-spec> <pkg> <pkg-dir>",
"\h|SYNOPSIS|
\c{\b{bdep release} [<options>] [<prj-spec>]}
\c{<prj-spec> = \b{--directory}|\b{-d} <prj-dir> | <pkg-spec>\n
- <pkg-spec> = (\b{--directory}|\b{-d} <pkg-dir>)...}
+ <pkg-spec> = (<pkg> | (\b{--directory}|\b{-d} <pkg-dir>))...}
\h|DESCRIPTION|
diff --git a/bdep/release.cxx b/bdep/release.cxx
index 80a97e1..0e72c13 100644
--- a/bdep/release.cxx
+++ b/bdep/release.cxx
@@ -480,8 +480,14 @@ namespace bdep
}
int
- cmd_release (const cmd_release_options& o, cli::scanner&)
+ cmd_release (const cmd_release_options& o, cli::scanner& args)
{
+ // Save the package names.
+ //
+ strings ns;
+ while (args.more ())
+ ns.emplace_back (args.next ());
+
// Detect options incompatibility going through the groups of mutually
// exclusive options. Also make sure that options make sense for the
// current mode (releasing, revising, etc.) by pre-setting an incompatible
@@ -739,27 +745,56 @@ namespace bdep
//
project prj;
{
- // We release all the packages in the project. We could have required a
- // configuration and verified that they are all initialized, similar to
- // publish. But seeing that we don't need the configuration (unlike
- // publish), this feels like an unnecessary complication. We also don't
- // pre-sync for the same reasons.
+ // If no project directory nor package directory/name is specified, then
+ // we release the entire project. Otherwise, we only release the
+ // specified packages.
+ //
+ // We could have required a configuration and verified that all the
+ // being released packages are initialized, similar to publish. But
+ // seeing that we don't need the configuration (unlike publish), this
+ // feels like an unnecessary complication. We also don't pre-sync for
+ // the same reasons.
//
// Seeing that we are tagging the entire repository, force the
// collection of all the packages even if the current working directory
- // is a package. But allow explicit package directory specification as
- // the "I know what I am doing" mode (e.g., to sidestep the same version
- // restriction).
+ // is a package. But allow explicit package directory/name specification
+ // as the "I know what I am doing" mode (e.g., to sidestep the same
+ // version restriction).
//
package_locations pls;
- if (o.directory_specified ())
+ if (o.directory_specified () || !ns.empty ())
{
project_packages pp (
find_project_packages (o.directory (),
- false /* ignore_packages */,
- true /* load_packages */));
+ false /* ignore_packages */,
+ ns.empty () /* load_packages */));
prj.path = move (pp.project);
+
+ if (!ns.empty ())
+ pp.append (find_project_packages (prj.path, ns).first.packages);
+
+ // Issue a warning if some project packages are not being released.
+ //
+ for (package_location& pl: load_packages (prj.path))
+ {
+ if (find_if (pp.packages.begin (), pp.packages.end (),
+ [&pl] (const package_location& l)
+ {
+ return l.path == pl.path;
+ }) == pp.packages.end ())
+ pls.push_back (move (pl));
+ }
+
+ if (!pls.empty ())
+ {
+ diag_record dr (warn);
+ dr << "following project packages not being released:";
+
+ for (const package_location& pl: pls)
+ dr << ' ' << pl.name;
+ }
+
pls = move (pp.packages);
}
else
diff --git a/tests/release.testscript b/tests/release.testscript
index 2b86964..3b9731b 100644
--- a/tests/release.testscript
+++ b/tests/release.testscript
@@ -1122,6 +1122,101 @@ new += --vcs git,branch=master 2>-
test.options += -q
+ : pkg-spec
+ :
+ {
+ +$clone_repos
+
+ test.arguments += --no-open --push --yes
+
+ : dir
+ :
+ {
+ $clone_repos;
+
+ # Release the single libprj package rather than the whole prj project.
+ #
+ test.arguments = $regex.apply($test.arguments, '^(-d|prj)$', '');
+
+ $* -d prj/libprj 2>>EOE;
+ warning: following project packages not being released: prj
+ EOE
+
+ $clone2;
+
+ cat prj2/libprj/manifest >>~%EOO%;
+ %.*
+ name: libprj
+ version: 0.1.0
+ %.*
+ EOO
+
+ cat prj2/prj/manifest >>~%EOO%
+ %.*
+ name: prj
+ version: 0.1.0-a.0.z
+ %.*
+ EOO
+ }
+
+ : name
+ :
+ {
+ $clone_repos;
+
+ # Release the single libprj package rather than the whole prj project.
+ #
+ $* libprj 2>>EOE;
+ warning: following project packages not being released: prj
+ EOE
+
+ $clone2;
+
+ cat prj2/libprj/manifest >>~%EOO%;
+ %.*
+ name: libprj
+ version: 0.1.0
+ %.*
+ EOO
+
+ cat prj2/prj/manifest >>~%EOO%
+ %.*
+ name: prj
+ version: 0.1.0-a.0.z
+ %.*
+ EOO
+ }
+
+ : no-pkg-prj-spec
+ :
+ {
+ $clone_repos;
+
+ # Release the whole project, but deduce the project directory from the
+ # current working directory which is a package directory.
+ #
+ test.arguments = $regex.apply($test.arguments, '^(-d|prj)$', '');
+
+ env -c prj/libprj -- $*;
+
+ $clone2;
+
+ cat prj2/libprj/manifest >>~%EOO%;
+ %.*
+ name: libprj
+ version: 0.1.0
+ %.*
+ EOO
+
+ cat prj2/prj/manifest >>~%EOO%
+ %.*
+ name: prj
+ version: 0.1.0
+ %.*
+ EOO
+ }
+ }
+
: patch
:
{
@@ -1164,7 +1259,11 @@ new += --vcs git,branch=master 2>-
echo '' >+ prj/prj/manifest;
$gp add prj/manifest;
- $release --revision --current-tag=update -q --yes --no-edit -d prj/prj;
+ $release --revision --current-tag=update -q --yes --no-edit -d prj/prj 2>>~%EOE%;
+ %.*
+ warning: following project packages not being released: libprj
+ %.*
+ EOE
echo '' >+ prj/prj/manifest;
$gp add prj/manifest;