(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:
Ansho Rei
2026-08-24 15:49:50 +02:00
co-authored by Claude Fable 5
parent 9d17f55860
commit c03f47c52d
11 changed files with 224 additions and 30 deletions
+32 -13
View File
@@ -3,8 +3,8 @@
//! The comments directory was already an append-only log with exactly one event kind:
//! one file per entry under a directory named by the ticket's uuid, stamped to the
//! microsecond and written with `create_new` so two writers cannot clobber each other.
//! This is that log with the kind named in it, so a status change, an owner change and a
//! tag change are recorded beside what somebody said about them.
//! This is that log with the kind named in it, so a status change, an owner change, a
//! tag change and a campaign move are recorded beside what somebody said about them.
//!
//! What is deliberately not logged: ticking or unticking a criterion, and edits to the
//! title, description, plan, priority or due. Those change often and a log of them is
@@ -59,25 +59,32 @@ pub fn history_dir(board: &Path, uuid: &str) -> PathBuf {
/// What an entry records.
///
/// An enum rather than a string, so a kind the reader does not know is a compile error
/// instead of a word that renders as itself. The variants are the four things worth
/// keeping: what somebody said, and the three fields whose history answers a question.
/// instead of a word that renders as itself. The variants are the five things worth
/// keeping: what somebody said, and the four fields whose history answers a question.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Kind {
Comment,
Status,
Owner,
Tags,
Campaign,
}
impl Kind {
/// Every kind, which is what the reader matches a marker against and what the
/// counter matches a filename against.
pub const ALL: [Kind; 4] = [Kind::Comment, Kind::Status, Kind::Owner, Kind::Tags];
pub const ALL: [Kind; 5] = [
Kind::Comment,
Kind::Status,
Kind::Owner,
Kind::Tags,
Kind::Campaign,
];
/// The width the mechanical labels are padded to, `status` being the longest of the
/// three. `comment` is longer and is not padded to: a comment renders as a header
/// and a body, not as a row.
const LABEL_WIDTH: usize = 6;
/// The width the mechanical labels are padded to, `campaign` being the longest of
/// the four. `comment` renders as a header and a body, not as a row, so it is not
/// among them.
const LABEL_WIDTH: usize = 8;
/// The word in the filename, and the label a mechanical entry renders under.
pub fn slug(self) -> &'static str {
@@ -86,6 +93,7 @@ impl Kind {
Kind::Status => "status",
Kind::Owner => "owner",
Kind::Tags => "tags",
Kind::Campaign => "campaign",
}
}
@@ -100,6 +108,7 @@ impl Kind {
Kind::Status => "**Status**",
Kind::Owner => "**Owner**",
Kind::Tags => "**Tags**",
Kind::Campaign => "**Campaign**",
}
}
}
@@ -560,7 +569,7 @@ mod tests {
let rendered = format_history_with(&entries, false);
assert!(rendered.contains("HISTORY"), "{rendered}");
assert!(
rendered.contains("status committed → reviewing claude (2026-08-24 12:00:00)\n"),
rendered.contains("status committed → reviewing claude (2026-08-24 12:00:00)\n"),
"{rendered}"
);
assert!(
@@ -574,6 +583,9 @@ mod tests {
/// The pin for the cells conversion: `show` prints the block exactly as it printed
/// it before, every painted run spelled out, the way
/// `show_prints_the_same_body_it_printed_before_the_cells_conversion` pins the body.
///
/// Updated once since, deliberately: `campaign` widened the label column from 6 to
/// 8, and the campaign row itself joined the pin (f774a33).
#[test]
fn show_prints_the_same_history_it_printed_before_the_cells_conversion() {
let entries = vec![
@@ -585,22 +597,28 @@ mod tests {
"20260824_120001_000000_comment",
"**Comment**\nThe offset was never passed\n\n**Author**: Ansho Rei\n**Time**: 2026-08-24 12:00:01\n",
),
parse_entry(
"20260824_120002_000000_campaign",
"**Campaign**\n_Not set_ → v1\n\n**Author**: claude\n**Time**: 2026-08-24 12:00:02\n",
),
];
let expected = format!(
"\n{}\n{}\n\n{} committed → reviewing {}\n\n{}\n The offset was never passed\n",
"\n{}\n{}\n\n{} committed → reviewing {}\n\n{}\n The offset was never passed\n\n{} _Not set_ → v1 {}\n",
paint("HISTORY", Color::Orange, true),
"─".repeat(20),
paint("status", Color::Orange, true),
paint("claude (2026-08-24 12:00:00)", Color::Cyan, true),
paint("From Ansho Rei (2026-08-24 12:00:01)", Color::Cyan, true),
paint("campaign", Color::Orange, true),
paint("claude (2026-08-24 12:00:02)", Color::Cyan, true),
);
assert_eq!(format_history_with(&entries, true), expected);
assert_eq!(format_history_with(&[], true), paint("No history yet.", Color::Grey, true));
}
/// Padded to the longest of the three, so every body starts in the same column
/// Padded to the longest of the four, so every body starts in the same column
/// however short the label above it is.
#[test]
fn the_mechanical_labels_are_aligned() {
@@ -608,6 +626,7 @@ mod tests {
("status", "backlog → committed"),
("owner", "_Not set_ → alice"),
("tags", "bug → bug, cli"),
("campaign", "v1 → beaver"),
];
let entries: Vec<Entry> = bodies
.into_iter()
@@ -631,7 +650,7 @@ mod tests {
at - line_start
})
.collect();
assert_eq!(columns.len(), 3);
assert_eq!(columns.len(), 4);
assert!(columns.windows(2).all(|pair| pair[0] == pair[1]), "{rendered}");
}