aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-09-02 17:11:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-09-04 13:16:51 +0300
commitf9df0e96ad414c70e87bc2d554095585b3b20721 (patch)
tree8b91c42b84f0b3044689561aa99bba57a6b1a0bf
parent1ac2b1310851b3da03318797231f3832f4804c79 (diff)
By default publish all project packages (GH issue #410)
-rw-r--r--bdep/publish.cli16
-rw-r--r--bdep/publish.cxx49
-rw-r--r--tests/publish.testscript22
3 files changed, 73 insertions, 14 deletions
diff --git a/bdep/publish.cli b/bdep/publish.cli
index 89a8e4d..36818c0 100644
--- a/bdep/publish.cli
+++ b/bdep/publish.cli
@@ -30,12 +30,16 @@ namespace bdep
The \cb{publish} command publishes the project packages to an
archive-based repository.
- If no project or package directory is specified, then the current working
- directory is assumed. If no configuration is specified, then the default
- configurations are used to prepare the package distributions. If the
- specified directory is a project directory, then all the packages in the
- project are published. See \l{bdep-projects-configs(1)} for details on
- specifying projects and configurations.
+ Normally, \cb{publish} operates on all the packages in a project. If no
+ project directory nor package directory/name is specified, then the
+ current working directory is assumed and all the packages are published,
+ even if the current directory is a package directory. If, however, one or
+ more packages are specified explicitly with \c{\b{--directory}|\b{-d}} or
+ as <pkg> names, then \cb{publish} assumes you know what you are doing and
+ only publishes these packages. If no configuration is specified, then the
+ default configurations are used to prepare the package distributions. See
+ \l{bdep-projects-configs(1)} for details on specifying projects and
+ configurations.
For each specified package the \cb{publish} command prepares a package
archive and sends it as part of the package submission request to an
diff --git a/bdep/publish.cxx b/bdep/publish.cxx
index 9a5f417..9bc7c8c 100644
--- a/bdep/publish.cxx
+++ b/bdep/publish.cxx
@@ -881,6 +881,10 @@ namespace bdep
while (args.more ())
ns.emplace_back (args.next ());
+ // If no project directory nor package directory/name is specified, then
+ // we publish the entire project. Otherwise, we only publish the specified
+ // packages.
+ //
// If we are publishing the entire project, then we have two choices: we
// can publish all the packages in the project or we can only do so for
// packages that were initialized in the configuration that we are going
@@ -889,15 +893,46 @@ namespace bdep
// mistake than the desired behavior. So we will assume it's all the
// packages and verify they are all initialized in the configuration.
//
- project_packages pp (
- find_project_packages (o,
- false /* ignore_packages */,
- ns.empty () /* load_packages */));
+ project_packages pp;
+ dir_path& prj (pp.project);
+
+ if (o.directory_specified () || !ns.empty ())
+ {
+ pp = find_project_packages (o,
+ false /* ignore_packages */,
+ ns.empty () /* load_packages */);
+
+ if (!ns.empty ())
+ pp.append (find_project_packages (prj, ns).first.packages);
- const dir_path& prj (pp.project);
+ // Issue a warning if some project packages are not being published.
+ //
+ package_locations pls;
+
+ for (package_location& pl: load_packages (prj))
+ {
+ 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 (!ns.empty ())
- pp.append (find_project_packages (prj, ns).first.packages);
+ if (!pls.empty ())
+ {
+ diag_record dr (warn);
+ dr << "following project packages not being published:";
+
+ for (const package_location& pl: pls)
+ dr << ' ' << pl.name;
+ }
+ }
+ else
+ {
+ prj = find_project (o.directory ());
+ pp.packages = load_packages (prj);
+ }
package_locations& pkgs (pp.packages);
diff --git a/tests/publish.testscript b/tests/publish.testscript
index 688859d..b8b9541 100644
--- a/tests/publish.testscript
+++ b/tests/publish.testscript
@@ -33,7 +33,7 @@ g = [cmdline] git -C prj >! 2>!
# duplicate submissions. We will use unique version for each test,
# incrementing the patch version for 1.0.X.
#
-# Next version to use: 1.0.25
+# Next version to use: 1.0.27
#
# Normally we disable the progress indication that complicates stderr output
@@ -213,6 +213,7 @@ g = [cmdline] git -C prj >! 2>!
test.arguments = $regex.apply($test.arguments, '^--yes$', '');
$* libprj <'y' 2>>~"%EOE%"
+ warning: following project packages not being published: prj
publishing:
% to: $repository%
as: user <user@example.com>
@@ -274,11 +275,30 @@ g = [cmdline] git -C prj >! 2>!
test.arguments = $regex.apply($test.arguments, '^(prj)$', '\1/libprj');
$* 2>>~%EOE%
+ warning: following project packages not being published: prj
%package submission is queued(: \.*prj/1.0.3)?%d
%reference: .{12}%
EOE
}
+ : all
+ :
+ {
+ $clone_prj;
+ sed -i -e 's/^(version:) .*$/\1 1.0.25/' prj/prj/manifest;
+ sed -i -e 's/^(version:) .*$/\1 1.0.26/' prj/libprj/manifest;
+ $init -C @cfg &prj-cfg/***;
+
+ test.arguments = $regex.apply($test.arguments, '^(-d|prj)$', '');
+
+ env -c prj/libprj -- $* 2>>~%EOE%
+ %package submission is queued(: \.*libprj/1.0.26)?%d
+ %reference: .{12}%
+ %package submission is queued(: \.*prj/1.0.25)?%d
+ %reference: .{12}%
+ EOE
+ }
+
: prompt
:
{