(da03690) Add set and append for editing a ticket, and bump to 0.5.0
Nothing could change a ticket after it was created. mv wrote status, comment appended a file, and that was the whole set of mutations, so correcting a typo or adding a criterion meant hand editing the markdown. Two commands rather than the one vague "edit" the ticket described. set replaces a field, append adds to a section, so the verb carries the meaning instead of a prefix on seven flag names, and append only offers the three sections that hold multiple lines. Owner is absent from both, it belongs to the chown command filed alongside this, and status stays mv's. One field, one writer. Sections are a table, DESCRIPTION, ACCEPTANCE and PLAN, each carrying a heading, a label, the placeholder add writes when empty, and a kind. Both commands walk it, so a section added later is one entry rather than edits in two places. Everything is targeted line surgery and never a regenerated file, which is what keeps a ticked criterion ticked and a handwritten section intact when an unrelated field changes. Appending to a numbered section continues from the count already there rather than renumbering above it, so a handwritten line survives exactly as written. Appending to an empty section replaces the placeholder instead of following it. An empty value is a paragraph break for a section and a usage error for a scalar, since it looks like a way to clear a field and clearing is not supported yet. No-op detection compares the whole file before and after each edit, so a field set to the value it already holds is reported unchanged and nothing is written. Two things came out of building it. move_ticket_file's staged write is extracted as write_then_replace, now the only way any ticket file is written. And the file is located by uuid rather than by title: titles are not unique, add allows duplicates on purpose, and the old title scan meant mv <uuid-of-second> moved the first ticket sharing its title. Reproduced, fixed, and pinned by a test. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
6c43e62a4b
commit
3810e442c6
@@ -602,3 +602,41 @@ fn mv_leaves_nothing_behind_on_success() {
|
||||
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// Duplicate titles are allowed, so the file cannot be located by title. It used to be,
|
||||
/// and `mv <uuid-of-second>` moved the first ticket that shared its title.
|
||||
#[test]
|
||||
fn mv_moves_the_resolved_ticket_when_two_share_a_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
for uuid in [
|
||||
"11111111-aaaa-bbbb-cccc-dddddddddddd",
|
||||
"22222222-aaaa-bbbb-cccc-dddddddddddd",
|
||||
] {
|
||||
fs::write(
|
||||
worklane.join("backlog").join(format!("{}_foo.md", uuid)),
|
||||
format!(
|
||||
"# Foo\n\n## Metadata\n\n- **ID**: {}\n- **Status**: backlog\n",
|
||||
uuid
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
.args(["mv", "22222222", "--status", "committed"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
assert_eq!(
|
||||
md_files(&worklane.join("committed")),
|
||||
vec!["22222222-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()],
|
||||
"the wrong ticket moved"
|
||||
);
|
||||
assert_eq!(
|
||||
md_files(&worklane.join("backlog")),
|
||||
vec!["11111111-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user