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:
1 parent
05fed64629
commit
d29894046e
2 files changed
+43
-34
No files matched your search
+28
-28
@@ -68,15 +68,17 @@ fn apply(verdict: Verdict, prompter: &dyn Prompter) -> Result<(), Box<dyn std::e
|
||||
if prompter.confirm(&question, false)? {
|
||||
Ok(())
|
||||
} 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> {
|
||||
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:
|
||||
@@ -89,11 +91,11 @@ fn bad_author(changes: &ChangesFile) -> Verdict {
|
||||
};
|
||||
if author.contains("ubuntu@") || author.contains("root@") {
|
||||
Verdict::Refuse(format!(
|
||||
"Changed-By '{author}' carries an ubuntu@ or root@ address, \
|
||||
usually a container or VM default identity leaked into the \
|
||||
changelog: set your real identity (DEBEMAIL/DEBFULLNAME or \
|
||||
'git config user.email'), fix debian/changelog and rebuild \
|
||||
with `pkh build`"
|
||||
"The Changed-By field '{author}' carries an ubuntu@ or root@ \
|
||||
address, usually a container or VM default identity leaked \
|
||||
into the changelog. Set your real identity (DEBEMAIL/\
|
||||
DEBFULLNAME or 'git config user.email'), fix debian/changelog \
|
||||
and rebuild with 'pkh build'."
|
||||
))
|
||||
} else {
|
||||
Verdict::Proceed
|
||||
@@ -112,8 +114,8 @@ fn no_bug(changes: &ChangesFile) -> Verdict {
|
||||
return Verdict::Proceed;
|
||||
}
|
||||
Verdict::Ask {
|
||||
reason: "the upload references no Launchpad bug: add 'LP: #NNN' to \
|
||||
the changelog entry for the bug it fixes"
|
||||
reason: "The upload does not reference any Launchpad bug. Add \
|
||||
'LP: #NNN' to the changelog entry if it fixes a bug."
|
||||
.to_string(),
|
||||
question: "Upload without Launchpad bug references?".to_string(),
|
||||
}
|
||||
@@ -136,7 +138,7 @@ fn placeholder_bug(changes: &ChangesFile) -> Verdict {
|
||||
}
|
||||
Verdict::Ask {
|
||||
reason: format!(
|
||||
"Launchpad bug reference(s) {} look like placeholder numbers",
|
||||
"The Launchpad bug references {} look like placeholder numbers.",
|
||||
flagged.join(", ")
|
||||
),
|
||||
question: "Upload with placeholder bug references?".to_string(),
|
||||
@@ -179,8 +181,8 @@ fn release_mismatch(changes: &ChangesFile, target: Option<&(String, String)>) ->
|
||||
}
|
||||
Verdict::Ask {
|
||||
reason: format!(
|
||||
"the version {} carries {} but the target series {} is {}: a \
|
||||
backport suffix does not match the series it uploads to",
|
||||
"The version {} carries {} as a backport suffix, but the target \
|
||||
series {} is {}.",
|
||||
changes.version,
|
||||
mismatched.join(", "),
|
||||
codename,
|
||||
@@ -239,10 +241,10 @@ fn update_maintainer(changes: &ChangesFile) -> Verdict {
|
||||
}
|
||||
Verdict::Ask {
|
||||
reason: format!(
|
||||
"the version {} carries Ubuntu changes but the Maintainer \
|
||||
'{maintainer}' is not an ubuntu.com address: run \
|
||||
"The version {} carries Ubuntu changes, but the Maintainer \
|
||||
'{maintainer}' is not an ubuntu.com address. Run \
|
||||
'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
|
||||
),
|
||||
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;
|
||||
}
|
||||
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 \
|
||||
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(),
|
||||
)
|
||||
}
|
||||
@@ -344,11 +346,11 @@ mod tests {
|
||||
assert_eq!(
|
||||
bad_author(&changes("1.0-1", Some("root <root@localhost>"), None)),
|
||||
Verdict::Refuse(
|
||||
"Changed-By 'root <root@localhost>' carries an ubuntu@ or \
|
||||
root@ address, usually a container or VM default identity \
|
||||
leaked into the changelog: set your real identity \
|
||||
(DEBEMAIL/DEBFULLNAME or 'git config user.email'), fix \
|
||||
debian/changelog and rebuild with `pkh build`"
|
||||
"The Changed-By field 'root <root@localhost>' carries an \
|
||||
ubuntu@ or root@ address, usually a container or VM \
|
||||
default identity leaked into the changelog. Set your real \
|
||||
identity (DEBEMAIL/DEBFULLNAME or 'git config user.email'), \
|
||||
fix debian/changelog and rebuild with 'pkh build'."
|
||||
.to_string()
|
||||
)
|
||||
);
|
||||
@@ -608,16 +610,14 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
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 error = run(&changes, None, &crate::report::Quiet)
|
||||
.await
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(
|
||||
error.contains("references no Launchpad bug"),
|
||||
"unexpected: {error}"
|
||||
);
|
||||
assert!(error.contains("--force"), "unexpected: {error}");
|
||||
assert_eq!(error, "Upload stopped. Pass --force to upload anyway.");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
+15
-6
@@ -127,21 +127,30 @@ async fn put_impl(opts: &PutOptions<'_>) -> Result<(), Box<dyn std::error::Error
|
||||
match tree {
|
||||
SectionCheckTarget::Dir(dir) => check_control_section(&dir, "ubuntu")?,
|
||||
SectionCheckTarget::Skip => log::warn!(
|
||||
"cannot check the Section: '{}' has no debian/control next to \
|
||||
it, skipping the pre-flight (the archive still rejects uploads \
|
||||
with unknown sections)",
|
||||
"Skipping the Section check: '{}' has no debian/control next to \
|
||||
it (the archive still rejects uploads with unknown sections).",
|
||||
changes_path.display()
|
||||
),
|
||||
}
|
||||
|
||||
opts.view
|
||||
.message(&format!("Checking {} on Launchpad...", target.label));
|
||||
launchpad::ppa_info(&opts.ppa).await?;
|
||||
launchpad::check_ppa_series(&changes.distribution).await?;
|
||||
// The three pre-flights are independent requests, sent together: each
|
||||
// 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
|
||||
// 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)?;
|
||||
|
||||
let record = upload_record(&target, &changes_path)?;
|
||||
|
||||
Reference in new issue
Block a user