(f774a33) Record a campaign move in the history log, and bump to 0.30.0
assign was the only field writer without an entry: a ticket could leave one campaign for another with nothing recording it. Kind gains Campaign, assign gains the --actor flag the other four writers carry, and the entry is written after the save and behind the no-change return, the rule every writer follows. The entry records Campaign::name, the codename or failing that the title, settled when the entry is written so a rename cannot change what an old entry means. The uuid the field holds says nothing in a log line, and a before-uuid the board no longer has reads _missing_, the way the Campaign field itself renders a dangling one. campaign is the longest mechanical label, so LABEL_WIDTH widens from 6 to 8 and every mechanical row moves two columns right, a deliberate output change that makes this a minor alongside the new flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
9d17f55860
commit
c03f47c52d
+127
-2
@@ -164,6 +164,119 @@ fn clearing_the_tags_writes_a_tags_entry() {
|
||||
assert!(entry.starts_with("**Tags**\nalpha → _None_\n"), "{entry:?}");
|
||||
}
|
||||
|
||||
/// The entry names the campaign the way a reader knows it, the codename, not the uuid
|
||||
/// the field actually holds. A ticket never assigned starts from the sentinel an unset
|
||||
/// field reads as everywhere else.
|
||||
#[test]
|
||||
fn assign_writes_a_campaign_entry_naming_the_codename() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog");
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"First public release",
|
||||
"--codename",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
|
||||
run(&temp, &["assign", "v1", UUID]);
|
||||
|
||||
let entry = only_entry(&worklane, "campaign");
|
||||
assert!(entry.starts_with("**Campaign**\n_Not set_ → v1\n"), "{entry:?}");
|
||||
}
|
||||
|
||||
/// A campaign filed without a codename is recorded by its title, the name `show` and
|
||||
/// `campaign ls` fall back to.
|
||||
#[test]
|
||||
fn a_campaign_without_a_codename_is_recorded_by_its_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog");
|
||||
run(&temp, &["campaign", "add", "--title", "First public release"]);
|
||||
|
||||
run(&temp, &["assign", "First public", UUID]);
|
||||
|
||||
let entry = only_entry(&worklane, "campaign");
|
||||
assert!(
|
||||
entry.starts_with("**Campaign**\n_Not set_ → First public release\n"),
|
||||
"{entry:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A ticket leaving one campaign for another records both ends, which is the move the
|
||||
/// log exists to answer for: the field is rewritten, so nothing else remembers where the
|
||||
/// ticket was.
|
||||
#[test]
|
||||
fn moving_between_campaigns_records_both_names() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog");
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"First release",
|
||||
"--codename",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"Second release",
|
||||
"--codename",
|
||||
"beaver",
|
||||
],
|
||||
);
|
||||
|
||||
run(&temp, &["assign", "v1", UUID]);
|
||||
run(&temp, &["assign", "beaver", UUID]);
|
||||
|
||||
let found = entries(&worklane);
|
||||
assert_eq!(found.len(), 2, "{found:?}");
|
||||
assert!(found[1].1.starts_with("**Campaign**\nv1 → beaver\n"), "{:?}", found[1].1);
|
||||
}
|
||||
|
||||
/// Assigning the campaign a ticket already names is reported as no change, and a log of
|
||||
/// no change would be a log of nothing happening.
|
||||
#[test]
|
||||
fn a_no_op_assign_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog");
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"First release",
|
||||
"--codename",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
|
||||
run(&temp, &["assign", "v1", UUID]);
|
||||
let out = run(&temp, &["assign", "v1", UUID]);
|
||||
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(
|
||||
entries(&worklane).len(),
|
||||
1,
|
||||
"a no-op assign logged a change it did not make"
|
||||
);
|
||||
}
|
||||
|
||||
/// The fields that change often enough that a log of them is noise. `set` writing one of
|
||||
/// them is not an entry, and neither is a criterion being ticked.
|
||||
#[test]
|
||||
@@ -277,7 +390,7 @@ fn show_prints_the_comments_and_the_changes_in_one_sequence() {
|
||||
let owned = stdout.find("alice → bob").expect("the chown is missing");
|
||||
assert!(said < moved && moved < owned, "out of order:\n{stdout}");
|
||||
|
||||
for line in ["status backlog → committed", "owner alice → bob"] {
|
||||
for line in ["status backlog → committed", "owner alice → bob"] {
|
||||
assert!(stdout.contains(line), "{line:?} not in:\n{stdout}");
|
||||
}
|
||||
assert!(stdout.contains("From claude ("), "{stdout}");
|
||||
@@ -337,14 +450,26 @@ fn the_actor_flag_names_the_writer_on_every_command_that_writes_one() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog");
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"First release",
|
||||
"--codename",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
|
||||
run(&temp, &["comment", UUID, "By hand.", "--actor", "opencode"]);
|
||||
run(&temp, &["mv", UUID, "--status", "committed", "--actor", "opencode"]);
|
||||
run(&temp, &["chown", "bob", UUID, "--actor", "opencode"]);
|
||||
run(&temp, &["set", UUID, "--tags", "beta", "--actor", "opencode"]);
|
||||
run(&temp, &["assign", "v1", UUID, "--actor", "opencode"]);
|
||||
|
||||
let found = entries(&worklane);
|
||||
assert_eq!(found.len(), 4, "{found:?}");
|
||||
assert_eq!(found.len(), 5, "{found:?}");
|
||||
for (name, content) in found {
|
||||
assert!(content.contains("**Author**: opencode"), "{name}: {content:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user