diff options
-rw-r--r-- | bdep/publish.cxx | 34 | ||||
-rw-r--r-- | tests/publish.testscript | 70 |
2 files changed, 96 insertions, 8 deletions
diff --git a/bdep/publish.cxx b/bdep/publish.cxx index 9bc7c8c..257b355 100644 --- a/bdep/publish.cxx +++ b/bdep/publish.cxx @@ -209,12 +209,34 @@ namespace bdep dr << info << "use --force=snapshot to publish anyway"; } - // Per semver we treat zero major versions as alpha. - // - s = o.section_specified () ? o.section () : - v.alpha () || v.major () == 0 ? "alpha" : - v.beta () ? "beta" : - "stable" ; + if (o.section_specified ()) + s = o.section (); + else if (v.alpha ()) + s = "alpha"; + else if (v.beta ()) + s = "beta"; + else + { + // Per semver we treat zero major versions as alpha. + // + // Note, however, that a package may not subscribe to the semver + // semantics while using the three-component version. Thus, for the + // zero major version, unless this is a pre-release, we confirm with + // the user if the alpha section is appropriate for the package. + // + if (v.major () == 0) + { + text << "package " << n << ' ' << v << " has 0 major version " + << "component and should be published to alpha section if " + << "this version is semver"; + + s = yn_prompt ("publish to alpha as opposed to stable [y/n]") + ? "alpha" + : "stable"; + } + else + s = "stable"; + } } else { diff --git a/tests/publish.testscript b/tests/publish.testscript index b8b9541..9c0f7e2 100644 --- a/tests/publish.testscript +++ b/tests/publish.testscript @@ -31,9 +31,9 @@ g = [cmdline] git -C prj >! 2>! # Note that using the same package name and version for tests may result in # duplicate submissions. We will use unique version for each test, -# incrementing the patch version for 1.0.X. +# incrementing the patch version for *.*.X. # -# Next version to use: 1.0.27 +# Next version to use: *.*.29 # # Normally we disable the progress indication that complicates stderr output @@ -129,6 +129,72 @@ g = [cmdline] git -C prj >! 2>! EOE } + : zero-major-version + : + { + : alpha + : + { + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 0.1.27/' prj/manifest; + + # Suppress the --yes option. + # + test.arguments = $regex.apply($test.arguments, '^--yes$', ''); + + $* <<EOI 2>>~%EOE% + y + y + EOI + %.* + package prj 0.1.27 has 0 major version component and should be published to alpha section if this version is semver + publish to alpha as opposed to stable [y/n] publishing: + %.* + package: prj + version: 0.1.27 + project: prj + section: alpha + %.* + continue? [y/n] submitting prj-0.1.27.tar.gz + %.* + %package submission is queued.+% + %reference: .{12}% + EOE + } + + : stable + : + { + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 0.1.28/' prj/manifest; + + # Suppress the --yes option. + # + test.arguments = $regex.apply($test.arguments, '^--yes$', ''); + + $* <<EOI 2>>~%EOE% + n + y + EOI + %.* + package prj 0.1.28 has 0 major version component and should be published to alpha section if this version is semver + publish to alpha as opposed to stable [y/n] publishing: + %.* + package: prj + version: 0.1.28 + project: prj + section: stable + %.* + continue? [y/n] submitting prj-0.1.28.tar.gz + %.* + %package submission is queued.+% + %reference: .{12}% + EOE + } + } + : non-standard-version : : Test publishing a package with the non-standard version from a |