put: phrase the mistake guards as proper sentences

The guards warned in lowercase fragments with no level marker, reading
like debris in the terminal. Capitalized sentences throughout; the
no-bug warning follows the suggested wording and allows for the entry
legitimately fixing no bug; a declined question stops with its own
message instead of repeating the reason just warned above it.
This commit is contained in:
vhaudiquet committed 2026-11-17 12:46:16 +01:00
1 parent 05fed64629
commit d29894046e
2 files changed
+43 -34

No files matched your search

+28 -28
View File
@@ -68,15 +68,17 @@ fn apply(verdict: Verdict, prompter: &dyn Prompter) -> Result<(), Box<dyn std::e
if prompter.confirm(&question, false)? { if prompter.confirm(&question, false)? {
Ok(()) Ok(())
} else { } else {
Err(refusal(reason)) // The reason was warned right above the question; the
// refusal only adds what happened and the way out
Err("Upload stopped. Pass --force to upload anyway.".into())
} }
} }
} }
} }
/// The error for a guard that said no: the reason plus the way out. /// The error for a refused upload: the reason plus the way out.
fn refusal(reason: String) -> Box<dyn std::error::Error> { fn refusal(reason: String) -> Box<dyn std::error::Error> {
format!("{reason} (pass --force to upload anyway)").into() format!("{reason} Pass --force to upload anyway.").into()
} }
/// Stop uploads whose `Changed-By` is a `ubuntu@` or `root@` address: /// Stop uploads whose `Changed-By` is a `ubuntu@` or `root@` address:
@@ -89,11 +91,11 @@ fn bad_author(changes: &ChangesFile) -> Verdict {
}; };
if author.contains("ubuntu@") || author.contains("root@") { if author.contains("ubuntu@") || author.contains("root@") {
Verdict::Refuse(format!( Verdict::Refuse(format!(
"Changed-By '{author}' carries an ubuntu@ or root@ address, \ "The Changed-By field '{author}' carries an ubuntu@ or root@ \
usually a container or VM default identity leaked into the \ address, usually a container or VM default identity leaked \
changelog: set your real identity (DEBEMAIL/DEBFULLNAME or \ into the changelog. Set your real identity (DEBEMAIL/\
'git config user.email'), fix debian/changelog and rebuild \ DEBFULLNAME or 'git config user.email'), fix debian/changelog \
with `pkh build`" and rebuild with 'pkh build'."
)) ))
} else { } else {
Verdict::Proceed Verdict::Proceed
@@ -112,8 +114,8 @@ fn no_bug(changes: &ChangesFile) -> Verdict {
return Verdict::Proceed; return Verdict::Proceed;
} }
Verdict::Ask { Verdict::Ask {
reason: "the upload references no Launchpad bug: add 'LP: #NNN' to \ reason: "The upload does not reference any Launchpad bug. Add \
the changelog entry for the bug it fixes" 'LP: #NNN' to the changelog entry if it fixes a bug."
.to_string(), .to_string(),
question: "Upload without Launchpad bug references?".to_string(), question: "Upload without Launchpad bug references?".to_string(),
} }
@@ -136,7 +138,7 @@ fn placeholder_bug(changes: &ChangesFile) -> Verdict {
} }
Verdict::Ask { Verdict::Ask {
reason: format!( reason: format!(
"Launchpad bug reference(s) {} look like placeholder numbers", "The Launchpad bug references {} look like placeholder numbers.",
flagged.join(", ") flagged.join(", ")
), ),
question: "Upload with placeholder bug references?".to_string(), question: "Upload with placeholder bug references?".to_string(),
@@ -179,8 +181,8 @@ fn release_mismatch(changes: &ChangesFile, target: Option<&(String, String)>) ->
} }
Verdict::Ask { Verdict::Ask {
reason: format!( reason: format!(
"the version {} carries {} but the target series {} is {}: a \ "The version {} carries {} as a backport suffix, but the target \
backport suffix does not match the series it uploads to", series {} is {}.",
changes.version, changes.version,
mismatched.join(", "), mismatched.join(", "),
codename, codename,
@@ -239,10 +241,10 @@ fn update_maintainer(changes: &ChangesFile) -> Verdict {
} }
Verdict::Ask { Verdict::Ask {
reason: format!( reason: format!(
"the version {} carries Ubuntu changes but the Maintainer \ "The version {} carries Ubuntu changes, but the Maintainer \
'{maintainer}' is not an ubuntu.com address: run \ '{maintainer}' is not an ubuntu.com address. Run \
'update-maintainer' (ubuntu-dev-tools) and rebuild, so Ubuntu \ 'update-maintainer' (ubuntu-dev-tools) and rebuild, so Ubuntu \
modifications are owned by an Ubuntu maintainer", modifications are owned by an Ubuntu maintainer.",
changes.version changes.version
), ),
question: "Upload without an ubuntu.com maintainer?".to_string(), question: "Upload without an ubuntu.com maintainer?".to_string(),
@@ -289,10 +291,10 @@ fn patches_in_native(changes: &ChangesFile, tree: Option<&Path>) -> Verdict {
return Verdict::Proceed; return Verdict::Proceed;
} }
Verdict::Refuse( Verdict::Refuse(
"the package is native but debian/patches/series exists: quilt \ "The package is native but debian/patches/series exists. Quilt \
patches are never applied in a native package, so the fixes they \ patches are never applied in a native package, so the fixes they \
carry would silently miss the build. Fold the patches into the \ carry would silently miss the build. Fold the patches into the \
source or switch debian/source/format to '3.0 (quilt)'" source or switch debian/source/format to '3.0 (quilt)'."
.to_string(), .to_string(),
) )
} }
@@ -344,11 +346,11 @@ mod tests {
assert_eq!( assert_eq!(
bad_author(&changes("1.0-1", Some("root <root@localhost>"), None)), bad_author(&changes("1.0-1", Some("root <root@localhost>"), None)),
Verdict::Refuse( Verdict::Refuse(
"Changed-By 'root <root@localhost>' carries an ubuntu@ or \ "The Changed-By field 'root <root@localhost>' carries an \
root@ address, usually a container or VM default identity \ ubuntu@ or root@ address, usually a container or VM \
leaked into the changelog: set your real identity \ default identity leaked into the changelog. Set your real \
(DEBEMAIL/DEBFULLNAME or 'git config user.email'), fix \ identity (DEBEMAIL/DEBFULLNAME or 'git config user.email'), \
debian/changelog and rebuild with `pkh build`" fix debian/changelog and rebuild with 'pkh build'."
.to_string() .to_string()
) )
); );
@@ -608,16 +610,14 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn run_refuses_without_confirmation() { async fn run_refuses_without_confirmation() {
// The Quiet prompter answers with the default (no): the reason was
// warned before the question, the refusal names the outcome
let changes = changes("1.0-1", Some("A B <a@b.c>"), Some("A B <a@b.c>")); let changes = changes("1.0-1", Some("A B <a@b.c>"), Some("A B <a@b.c>"));
let error = run(&changes, None, &crate::report::Quiet) let error = run(&changes, None, &crate::report::Quiet)
.await .await
.unwrap_err() .unwrap_err()
.to_string(); .to_string();
assert!( assert_eq!(error, "Upload stopped. Pass --force to upload anyway.");
error.contains("references no Launchpad bug"),
"unexpected: {error}"
);
assert!(error.contains("--force"), "unexpected: {error}");
} }
#[tokio::test] #[tokio::test]
+15 -6
View File
@@ -127,21 +127,30 @@ async fn put_impl(opts: &PutOptions<'_>) -> Result<(), Box<dyn std::error::Error
match tree { match tree {
SectionCheckTarget::Dir(dir) => check_control_section(&dir, "ubuntu")?, SectionCheckTarget::Dir(dir) => check_control_section(&dir, "ubuntu")?,
SectionCheckTarget::Skip => log::warn!( SectionCheckTarget::Skip => log::warn!(
"cannot check the Section: '{}' has no debian/control next to \ "Skipping the Section check: '{}' has no debian/control next to \
it, skipping the pre-flight (the archive still rejects uploads \ it (the archive still rejects uploads with unknown sections).",
with unknown sections)",
changes_path.display() changes_path.display()
), ),
} }
opts.view opts.view
.message(&format!("Checking {} on Launchpad...", target.label)); .message(&format!("Checking {} on Launchpad...", target.label));
launchpad::ppa_info(&opts.ppa).await?; // The three pre-flights are independent requests, sent together: each
launchpad::check_ppa_series(&changes.distribution).await?; // Launchpad round trip costs a few hundred milliseconds, and the
// sequential walk was the slowest phase before the connection comes
// up. Results are checked in the order above, so a missing PPA still
// reports the PPA error rather than the superseded check's.
let (ppa, series, published) = tokio::join!(
launchpad::ppa_info(&opts.ppa),
launchpad::check_ppa_series(&changes.distribution),
launchpad::published_versions(&opts.ppa, &changes.source),
);
ppa?;
series?;
// Last pre-flight check: a version the PPA already publishes at or // Last pre-flight check: a version the PPA already publishes at or
// above the changes' one would supersede (or reject) this upload // above the changes' one would supersede (or reject) this upload
let published = launchpad::published_versions(&opts.ppa, &changes.source).await?; let published = published?;
check_not_superseded(&target, &changes, &published, opts.force)?; check_not_superseded(&target, &changes, &published, opts.force)?;
let record = upload_record(&target, &changes_path)?; let record = upload_record(&target, &changes_path)?;