diff --git a/AGENTS.md b/AGENTS.md index 03b89fc..59a8e0d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -350,7 +350,9 @@ and this file is for what someone changing worklane's own code needs. - The UUID tier applies from `MIN_ID_SEARCH` (4) characters up. Not 8: `ls` prints `SHORT_ID_WIDTH` (7) characters, so a longer minimum would drop the printed id out of the UUID tier and let any title quoting it win instead. Below the minimum the search is text, so `show 641` is a title search - The filename tier earns its place by reaching the middle of a UUID, which the prefix tier cannot. It is also why a short UUID search still resolves under a longer minimum, just at the wrong precedence, so a test for the minimum needs a decoy title to be meaningful - Ambiguous matches (multiple results) print options and exit(1) -- Never return empty strings for required fields — use the `NOT_SET` and `NONE` constants in `util.rs`, which are what `add` writes and what `--clear` puts back. `is_unknown_value` reads both, plus the two hyphenated spellings an earlier version wrote +- Never return empty strings for required fields — use the `NOT_SET` and `NONE` constants in `util.rs`, which are what `add` writes and what `--clear` puts back. `is_unknown_value` reads those two and nothing else +- **`-None-` and `-Not set-` are not unset, and re-adding them would be a mistake with a plausible story behind it.** They were accepted by `is_unknown_value` from the day it was written, by analogy with the `**-Status**` field name the `mv` splicing bug really did produce, c230d2c. But no version of this tool ever wrote a hyphenated *value*: `git log -S` finds both spellings in exactly one commit, the one that added them to the check. Dead from birth, and dropped by bdddc09. `a_hyphenated_marker_is_not_unset` is what stops the analogy being drawn a second time +- **The `**-Status**` repair in `is_status_line` is the opposite case and stays.** That corruption was real, `mv` wrote it, and the repair is what fixes a damaged ticket as it moves. Do not tidy the two away together on the grounds that they look alike ### Git Workflow - Commit format: `([ticketID]) [short description]` diff --git a/Cargo.lock b/Cargo.lock index 102ca2b..0fc9123 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1503,7 +1503,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.18.0" +version = "0.18.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index edd1240..8ee482d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.18.0" +version = "0.18.1" edition = "2024" [dependencies] diff --git a/src/util.rs b/src/util.rs index 5013c27..4a750f1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -939,9 +939,18 @@ pub const NOT_SET: &str = "_Not set_"; /// distinction `add` already makes and clearing has to keep. pub const NONE: &str = "_None_"; +/// Whether a field holds one of the two markers that mean it holds nothing. +/// +/// The two constants and nothing else. `-None-` and `-Not set-` were accepted here from +/// the day the function was written, by analogy with the `**-Status**` field name the +/// `mv` splicing bug really did produce, c230d2c. But no version of this tool ever wrote +/// a hyphenated *value*: `git log -S` finds the two spellings in exactly one commit, the +/// one that added them to this line. They were dead from birth, and a ticket that somehow +/// holds one now reads as the text it is rather than being quietly taken for unset, which +/// is the right way round for corruption nobody can produce. pub fn is_unknown_value(value: &str) -> bool { let trimmed = value.trim(); - trimmed == NONE || trimmed == NOT_SET || trimmed == "-None-" || trimmed == "-Not set-" + trimmed == NONE || trimmed == NOT_SET } /// Replace `**bold**` with colour, or leave the line exactly as it is. @@ -2764,6 +2773,21 @@ mod tests { } } + /// The hyphenated spellings are values like any other, and this is what says so. + /// + /// They were accepted as unset for months without any version of the tool ever + /// writing one, so the risk this pins is somebody re-adding them by analogy with the + /// `**-Status**` repair in `is_status_line`, which guards a corruption that was real. + #[test] + fn a_hyphenated_marker_is_not_unset() { + for legacy in ["-None-", "-Not set-", "-Nothing-"] { + assert!( + !is_unknown_value(legacy), + "{legacy} is read as unset, so a corrupted field would pass for an empty one" + ); + } + } + fn ticket_with_priority(raw: &str) -> String { format!("# T\n\n## Metadata\n\n- **Priority**: {}\n", raw) }