(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
@@ -50,6 +50,21 @@ pub struct Campaign {
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
impl Campaign {
|
||||
/// The name a reader knows the campaign by: the codename, or the title for a
|
||||
/// campaign filed without one.
|
||||
///
|
||||
/// What the history log records for a campaign move. The field holds a uuid, which
|
||||
/// says nothing in a log line, and resolving at read time would let an entry change
|
||||
/// meaning when a campaign is renamed, so the name is settled when the entry is
|
||||
/// written. The codename over the title because it is the word the board and the
|
||||
/// command line already use for the campaign, and a log row holds two of these
|
||||
/// around an arrow.
|
||||
pub fn name(&self) -> &str {
|
||||
self.codename.as_deref().unwrap_or(&self.title)
|
||||
}
|
||||
}
|
||||
|
||||
/// The campaigns directory as [`resolve_in`] takes it.
|
||||
///
|
||||
/// The name is empty because a campaign has no status: it is what makes the ambiguity
|
||||
|
||||
+5
-2
@@ -182,8 +182,8 @@ fn annotation_line(raw: &str) -> Result<String, String> {
|
||||
|
||||
/// What `--actor` says on every command that writes a history entry.
|
||||
///
|
||||
/// One string, so the four spell it the same: a flag documented differently on each
|
||||
/// command reads as four flags.
|
||||
/// One string, so the five spell it the same: a flag documented differently on each
|
||||
/// command reads as five flags.
|
||||
const ACTOR_HELP: &str = "Who the entry is attributed to, overriding WORKLANE_ACTOR and the git user. Free text, checked against nothing";
|
||||
|
||||
/// Arguments that carry prose, and therefore have to accept a value starting with
|
||||
@@ -302,6 +302,9 @@ pub enum Command {
|
||||
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
|
||||
#[arg(long, help = ACTOR_HELP)]
|
||||
actor: Option<String>,
|
||||
},
|
||||
|
||||
/// The tag vocabulary: what the board carries, and what each tag means
|
||||
|
||||
+26
-1
@@ -1509,7 +1509,12 @@ pub fn cmd_campaign_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so assigning
|
||||
/// a ticket to the campaign it already names writes nothing.
|
||||
pub fn cmd_assign(campaign_search: &str, ticket_id: &str, start: &Path) -> Result<()> {
|
||||
pub fn cmd_assign(
|
||||
campaign_search: &str,
|
||||
ticket_id: &str,
|
||||
actor: &Option<String>,
|
||||
start: &Path,
|
||||
) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(campaign_search, &worklane_dir)?;
|
||||
let (status, title, original) = resolve_ticket(ticket_id, &worklane_dir)?;
|
||||
@@ -1528,6 +1533,26 @@ pub fn cmd_assign(campaign_search: &str, ticket_id: &str, start: &Path) -> Resul
|
||||
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
|
||||
|
||||
// Behind the no-change return above and after the save, the rule every writer
|
||||
// follows. The entry records `Campaign::name`, not the uuid the field holds: what
|
||||
// the reader should see is settled here, when the entry is written. A campaign the
|
||||
// board no longer has reads `_missing_`, the way the Campaign field itself renders
|
||||
// a dangling uuid.
|
||||
let before = match parse_campaign(&original) {
|
||||
None => NOT_SET.to_string(),
|
||||
Some(old) => CampaignIndex::load(&worklane_dir)?
|
||||
.get(&old)
|
||||
.map(|was| was.name().to_string())
|
||||
.unwrap_or_else(|| "_missing_".to_string()),
|
||||
};
|
||||
write_entry(
|
||||
&worklane_dir,
|
||||
&uuid,
|
||||
Kind::Campaign,
|
||||
&change(&before, campaign.name()),
|
||||
&resolve_actor(actor.as_deref()),
|
||||
)?;
|
||||
|
||||
println!(
|
||||
"Assigned '{}' to campaign '{}'",
|
||||
color_text(&title, Color::Green),
|
||||
|
||||
+32
-13
@@ -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}");
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -82,7 +82,9 @@ fn main() -> Result<()> {
|
||||
cmd_campaign_show(&campaign, &worklane_dir)
|
||||
}
|
||||
},
|
||||
Some(Command::Assign { campaign, ticket }) => cmd_assign(&campaign, &ticket, &start),
|
||||
Some(Command::Assign { campaign, ticket, actor }) => {
|
||||
cmd_assign(&campaign, &ticket, &actor, &start)
|
||||
}
|
||||
// The bare form and `ls` are one arm: `worklane tags` was the listing before the
|
||||
// group existed and the fish completion still calls it that way, so the two
|
||||
// spellings cannot be allowed to drift into two behaviours.
|
||||
|
||||
+1
-1
@@ -4959,7 +4959,7 @@ mod tests {
|
||||
let plain = board.detail.as_ref().expect("no detail").plain();
|
||||
|
||||
assert!(plain.contains("HISTORY"), "{plain}");
|
||||
assert!(plain.contains("status backlog → committed claude ("), "{plain}");
|
||||
assert!(plain.contains("status backlog → committed claude ("), "{plain}");
|
||||
let moved = plain.find("backlog → committed").expect("the move is missing");
|
||||
let said = plain.find("And why.").expect("the comment is missing");
|
||||
assert!(moved < said, "the board reordered the log:\n{plain}");
|
||||
|
||||
Reference in New Issue
Block a user