(d637288) Guard an existing codename behind --force, and bump to 0.21.1
`campaign set --codename` replaced whatever was there. Once a campaign has a codename it is referred to by it -- on every card in the campaign, at the command line, and in somebody's shell history -- so changing it silently is the mistake `install-skill --force` exists to prevent. So it is refused, and the refusal names both words and the flag rather than leaving it to be found. Checked before any edit is applied, like `SetArgs::contested`, so a call also carrying `--title` writes neither field rather than half of what was asked for. Setting the codename a campaign already carries stays a no-op rather than becoming a refusal: `--force` is about overwriting a *different* word, and there is nothing to overwrite. That is the division `install::Outcome` already draws between `Unchanged` and `Refused`. `--force` guards the codename alone. A campaign always has a title, so guarding that would mean the flag was always required, which is a tax rather than a guard. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
72dbdec2ec
commit
95426e87be
+26
-1
@@ -1242,13 +1242,38 @@ pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
|
||||
/// `set_or_insert_metadata_field`, the upsert `assign` already uses for the Campaign field
|
||||
/// on a ticket, for the same reason.
|
||||
///
|
||||
/// **Replacing a codename the campaign already has needs `--force`.** Once a campaign has
|
||||
/// one it is referred to by it: it is on every card in the campaign, it is what resolves the
|
||||
/// campaign at the command line, and changing it out from under that is the same mistake
|
||||
/// overwriting an edited skill document would be. So it is refused, and the refusal names
|
||||
/// both words and the flag, the way `install-skill` names `--force` rather than leaving it
|
||||
/// to be found.
|
||||
///
|
||||
/// Checked before any edit is applied, like `SetArgs::contested`, so a call that also
|
||||
/// carries `--title` writes neither field rather than half of what was asked for.
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
|
||||
/// codename a campaign already carries writes nothing.
|
||||
/// codename a campaign already carries writes nothing. That is a no-op and not a refusal:
|
||||
/// `--force` is about overwriting a *different* word, and there is nothing to overwrite.
|
||||
pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
|
||||
let title = campaign.title.clone();
|
||||
|
||||
let overwrite = match (&args.codename, &campaign.codename) {
|
||||
(Some(wanted), Some(held)) if wanted != held => Some((held, wanted)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((held, wanted)) = overwrite.filter(|_| !args.force) {
|
||||
return Err(anyhow!(
|
||||
"Campaign '{}' is already codenamed '{}', so nothing was written. \
|
||||
Pass --force to replace it with '{}'",
|
||||
title,
|
||||
held,
|
||||
wanted
|
||||
));
|
||||
}
|
||||
|
||||
let mut content = campaign.content.clone();
|
||||
let mut changed: Vec<&str> = Vec::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user