Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eae411ab50 | ||
|
|
95426e87be |
@@ -22,7 +22,7 @@
|
||||
- Filenames: `<uuid_v4>_<slug>.md`
|
||||
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Campaign`, `Status`. The last four are the ones no ticket is born with: `add` writes none of them, so they are inserted on demand, against `METADATA_ORDER`, which is also what keeps `Status` last
|
||||
- The three stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they are mutually exclusive: entering a status writes its field, leaving removes it, re-entering restamps. So a ticket carries at most one, the one for the status it is sitting in, and a backward move under `-f` leaves no stale `Completed On` behind. They are current state, like `Status` itself; the trail of how the ticket got there is d4ce964's job and must not be grown here. `backlog` has no stamp, `Created At` already answers for it
|
||||
- The three stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they **accumulate**: entering a status writes its field, re-entering restamps, and arriving anywhere removes the fields of every status *after* the target. One arrival rule keyed off `Status::ALL`, not a case per move, which is why a backward move truncates the journey at the target (`done` back to `reviewing` drops `Completed On`, anything back to `backlog` drops all three) and a forward skip under `-f` stamps only where it lands rather than fabricating the stages it jumped. A ticket that walks the whole flow ends with `Created At`, `Committed On`, `Submitted On` and `Completed On` side by side, so presence means *got this far and has not been sent back past it*, not *is here now* — `Status` is what says where it is. Still not d4ce964's history log: these answer how far and when, once per stage, and every change along the way is the log's. `backlog` has no stamp, `Created At` already answers for it
|
||||
- Format: `**Field Name**: value`
|
||||
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
|
||||
- A **campaign** file carries `ID`, `Codename`, `Owner` and `Created At`, in that order, and no `Status`. `Codename` sits directly under the ID because that is what it is, a second way to say which campaign this is; it is written by `campaign add --codename` alone and is `_Not set_` when the flag was not given. It is not in `METADATA_ORDER`, which is the anchor list for the *upsert* on a ticket, and nothing upserts a campaign
|
||||
@@ -179,6 +179,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- **The TUI got a card label and a frame, not a campaign tab.** 61879a4 decided it. A tab would have had to answer what its columns are, and a campaign groups *across* the flow rather than within one status, so the honest answer is the four statuses filtered — which is a filter on the board it already has rather than a fifth tab. So: a label on the card, a frame above the columns while one is selected, and `c` for the picker. The cost the earlier decision balked at, a campaigns read per reload, is paid once per project in `columns_of` and is what names the label; see The Board View
|
||||
- **A campaign is named by its codename on the board, and by its short id when it has none.** The uuid does not fit on a card and the title is a sentence, which is the gap `Codename` fills. `campaign_label` builds it in one place, as a `Cell`, so the CLI paints it and the board makes a span of it; the mark is `CAMPAIGN_MARK`, `~`, beside `#` for a tag
|
||||
- **`campaign set` is the only writer of a filed campaign's fields, and it carries the two scalars.** d637288 decided it: a `set` rather than a flag on something narrower, because the file has more than one editable thing and the moment somebody wants to fix a typo in a title there would be a second command to design. `--title`, which renames the file the way `set --title` does, and `--codename`. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
|
||||
- **Replacing a codename the campaign already has needs `--force`.** Once a campaign has one it is referred to by it: it is on every card in the campaign, it is what resolves the campaign at the command line, and it is in somebody's shell history. Changing it silently is the mistake `install-skill --force` exists to prevent, so it is refused and the refusal names both words and the flag rather than leaving it to be found. Checked before any edit is applied, like `SetArgs::contested`, so a call also carrying `--title` writes neither field. Setting the codename a campaign already carries stays a **no-op, not a refusal** — `--force` is about overwriting a *different* word, which is the same division `install::Outcome` draws between `Unchanged` and `Refused`. `--force` guards the codename alone: a campaign always has a title, so guarding that would mean the flag was always required
|
||||
- **No `campaign set --description`, and that is the line, not an oversight.** `set` and `append` are a pair for a prose section: a way to replace a description with no way to add a paragraph is half of it. The two scalars have no append form at all, which is the same line `append` already draws for a ticket. `campaign_set_offers_no_description_and_no_owner` pins it. No `--owner` either, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign; and no `--clear`, because a wrong codename is replaced rather than emptied and `Clearable` is `SetArgs`'s, its variants being a ticket's fields
|
||||
- **The codename is written through `set_or_insert_metadata_field`, not `set_metadata_field`.** Every campaign filed before the field existed has no such line, and those are exactly the campaigns the command is for, which is the same reasoning that puts `assign` on the upsert. **`Codename` is therefore in `METADATA_ORDER`, directly after ID**, so an inserted one lands where `campaign_body` writes it and a campaign given a codename later is the same file as one filed with it. Nothing upserts it on a ticket, so its place in a ticket's order costs nothing
|
||||
- **One write path for tickets and campaigns.** `save_entry` is the body, `save_ticket` and `save_campaign` are the named wrappers, and `write_then_replace` and `find_entry_file` take the noun as a `&str` so a failure says "campaign" where it is one. A campaign file is a ticket file in every way that matters here, `<uuid>_<slug>.md` in a directory, and the rename happens only after the write has landed. Every message puts the noun mid-sentence so there is no capital to case
|
||||
|
||||
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -19,7 +19,7 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
| `worklane uncheck <ticket> [criteria...]` | Unticks acceptance criteria, addressed the same way |
|
||||
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
|
||||
| `worklane campaign add` | Files a campaign in `.worklane/campaigns/` with `--title`, `--description`, `--codename` and `--owner`. A campaign has no status: its state is derived, open until every member is done. `--codename` is one word to call it by, `v1` or `beaver`, which is what the board draws on every card in it and what every command that takes a campaign will also resolve it by |
|
||||
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
|
||||
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
|
||||
| `worklane campaign ls` | Lists the campaigns as their short id, their codename, their title and how many members are done. `--ids` prints one per line as the id, a tab and the title, unstyled, for a script or a completion |
|
||||
| `worklane campaign show <campaign>` | Shows a campaign and its members grouped by status, done included, since what is finished against what is left is the question a campaign asks |
|
||||
| `worklane assign <campaign> <ticket>` | Puts a ticket in a campaign, the only command that writes the Campaign field. Campaign first and ticket second, after `chown`. A ticket is in at most one, so assigning one that already belongs somewhere moves it |
|
||||
|
||||
+4
-1
@@ -160,7 +160,7 @@ fields; a goal is a campaign.
|
||||
worklane campaign ls
|
||||
worklane campaign show v1
|
||||
worklane campaign add --title "..." --codename v1 --description "..."
|
||||
worklane campaign set v1 --codename beaver # or --title, on one already filed
|
||||
worklane campaign set v1 --title "..." # or --codename, on one already filed
|
||||
worklane assign v1 1b78a24
|
||||
```
|
||||
|
||||
@@ -183,6 +183,9 @@ tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
|
||||
line, and a campaign filed without one is drawn by its short id, which says nothing. A
|
||||
campaign already on the board that has no codename is worth pointing out for the same
|
||||
reason a near-duplicate tag is, and `campaign set` is how it gets one without refiling.
|
||||
- **Do not propose renaming a codename a campaign already has.** It is what the campaign is
|
||||
called on every card in it and at the command line, so changing it is churn dressed as
|
||||
grooming. `campaign set` refuses it without `--force` for that reason.
|
||||
|
||||
Proposing a campaign means naming the goal, the members, and what is deliberately left
|
||||
out of it. The last part is what makes it a goal rather than a pile.
|
||||
|
||||
+3
-1
@@ -222,7 +222,9 @@ sentence, and it is the shortest thing that addresses the campaign at the comman
|
||||
Optional: a campaign without one is drawn and listed by its short id instead, which
|
||||
resolves but says nothing. `campaign set <campaign> --codename <word>` gives one to a
|
||||
campaign that is already filed, which is what every campaign filed before the field
|
||||
existed needs.
|
||||
existed needs. **Replacing a codename it already has needs `--force`**: that word is how
|
||||
the campaign is referred to on the board and at the command line, so changing it is a
|
||||
decision rather than a correction. Setting the one it already has is a no-op either way.
|
||||
|
||||
`campaign set` is the only way to change a campaign after it is filed, and it reaches the
|
||||
title and the codename only. There is no way to edit a campaign's description or its owner
|
||||
|
||||
+18
-1
@@ -337,6 +337,13 @@ pub enum CampaignCommand {
|
||||
/// variants are a ticket's fields, so reusing it here would put a ticket's enum on a
|
||||
/// campaign and inventing a second one is a decision worth making on purpose.
|
||||
///
|
||||
/// `--force` guards the codename and nothing else. A campaign that already has one is
|
||||
/// referred to by it: it is on every card in the campaign, it is what resolves it at the
|
||||
/// command line, and it is very likely in somebody's shell history. Replacing that silently
|
||||
/// is the same mistake overwriting an edited skill document would be, which is what
|
||||
/// `install-skill --force` exists for. A title needs no guard, since a campaign always has
|
||||
/// one and replacing it is the whole point of the flag.
|
||||
///
|
||||
/// The group makes at least one field mandatory, so a bare `worklane campaign set <c>` is a
|
||||
/// usage error rather than a silent no-op, exactly as it is for [`SetArgs`].
|
||||
#[derive(clap::Args)]
|
||||
@@ -357,9 +364,19 @@ pub struct CampaignSetArgs {
|
||||
/// Replace the codename, a single word to call the campaign by
|
||||
///
|
||||
/// The same parser `campaign add --codename` takes, so a codename is one thing however
|
||||
/// it was written.
|
||||
/// it was written. Replacing one a campaign already has needs `--force`
|
||||
#[arg(short, long, value_parser = codename)]
|
||||
pub codename: Option<String>,
|
||||
|
||||
/// Replace a codename the campaign already has
|
||||
///
|
||||
/// Without it, `--codename` on a campaign that already has one is refused and nothing
|
||||
/// is written. The codename is how a campaign is referred to once it has one, on every
|
||||
/// card in it and at the command line, so changing it is a decision rather than a
|
||||
/// correction. Setting the codename a campaign already carries is a no-op either way,
|
||||
/// not a refusal: there is nothing to overwrite
|
||||
#[arg(short, long)]
|
||||
pub force: bool,
|
||||
}
|
||||
|
||||
/// What a campaign holds: a title, a description and an owner.
|
||||
|
||||
+26
-1
@@ -1242,13 +1242,38 @@ pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
|
||||
/// `set_or_insert_metadata_field`, the upsert `assign` already uses for the Campaign field
|
||||
/// on a ticket, for the same reason.
|
||||
///
|
||||
/// **Replacing a codename the campaign already has needs `--force`.** Once a campaign has
|
||||
/// one it is referred to by it: it is on every card in the campaign, it is what resolves the
|
||||
/// campaign at the command line, and changing it out from under that is the same mistake
|
||||
/// overwriting an edited skill document would be. So it is refused, and the refusal names
|
||||
/// both words and the flag, the way `install-skill` names `--force` rather than leaving it
|
||||
/// to be found.
|
||||
///
|
||||
/// Checked before any edit is applied, like `SetArgs::contested`, so a call that also
|
||||
/// carries `--title` writes neither field rather than half of what was asked for.
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
|
||||
/// codename a campaign already carries writes nothing.
|
||||
/// codename a campaign already carries writes nothing. That is a no-op and not a refusal:
|
||||
/// `--force` is about overwriting a *different* word, and there is nothing to overwrite.
|
||||
pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
|
||||
let title = campaign.title.clone();
|
||||
|
||||
let overwrite = match (&args.codename, &campaign.codename) {
|
||||
(Some(wanted), Some(held)) if wanted != held => Some((held, wanted)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((held, wanted)) = overwrite.filter(|_| !args.force) {
|
||||
return Err(anyhow!(
|
||||
"Campaign '{}' is already codenamed '{}', so nothing was written. \
|
||||
Pass --force to replace it with '{}'",
|
||||
title,
|
||||
held,
|
||||
wanted
|
||||
));
|
||||
}
|
||||
|
||||
let mut content = campaign.content.clone();
|
||||
let mut changed: Vec<&str> = Vec::new();
|
||||
|
||||
|
||||
+72
-23
@@ -1364,28 +1364,38 @@ pub const COMMITTED_ON_FIELD: &str = "Committed On";
|
||||
pub const SUBMITTED_ON_FIELD: &str = "Submitted On";
|
||||
pub const COMPLETED_ON_FIELD: &str = "Completed On";
|
||||
|
||||
/// Stamp the field of the status being entered and drop the other two.
|
||||
/// Stamp the field of the status being entered and drop the ones after it.
|
||||
///
|
||||
/// A stamp is present exactly while the ticket sits in its status, so the three are
|
||||
/// mutually exclusive: entering writes one, leaving removes it, and re-entering
|
||||
/// restamps rather than keeping the first value. That is what keeps a ticket moved
|
||||
/// backward under `-f` from carrying a `Completed On` for work it has undone, and it is
|
||||
/// the line between these fields and d4ce964's history log. Metadata carries current
|
||||
/// state, which is why `Status` is a field at all; the trail of how the ticket got here
|
||||
/// belongs to the log, and a stamp left behind would be a second copy of that job.
|
||||
/// The stamps accumulate down the flow rather than being mutually exclusive, so a
|
||||
/// ticket that has walked the whole way carries `Created At`, `Committed On`,
|
||||
/// `Submitted On` and `Completed On` side by side and the journey behind it is legible.
|
||||
/// Presence therefore means the ticket got that far and has not been sent back past it,
|
||||
/// not that it is sitting there now; `Status` is what says where it is.
|
||||
///
|
||||
/// One arrival rule covers both directions. A backward move truncates the journey at
|
||||
/// the target, so `done` back to `reviewing` drops `Completed On` and keeps the two
|
||||
/// before it, and anything back to `backlog` drops all three. A forward skip under `-f`
|
||||
/// has nothing after it to clear, so `backlog` straight to `done` stamps `Completed On`
|
||||
/// alone and leaves the stages it jumped over unwritten rather than fabricated.
|
||||
/// Re-entering restamps rather than keeping the earlier value.
|
||||
///
|
||||
/// This is still not d4ce964's history log. These fields answer how far and when, once
|
||||
/// per stage; every status change, every owner and every tag along the way is the log's
|
||||
/// job and must not be grown here. `backlog` has no stamp, `Created At` answers for it.
|
||||
///
|
||||
/// The time comes in as a string rather than being read here, so the caller stamps the
|
||||
/// same moment it reports and a test can pin the value.
|
||||
pub fn set_status_stamp(content: &str, target: Status, now: &str, title: &str) -> Result<String> {
|
||||
let mut content = content.to_string();
|
||||
|
||||
// Every status but the target, so a skipping move under `-f` clears the stamps of
|
||||
// the stages it jumped over as well as the one it left.
|
||||
for status in Status::ALL {
|
||||
if status == target {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Every status after the target, off the flow order `Status::ALL` already holds
|
||||
// rather than a case per move, so arrival alone decides what is cleared and a
|
||||
// backward move and a skip are the same rule.
|
||||
for status in Status::ALL
|
||||
.iter()
|
||||
.skip_while(|status| **status != target)
|
||||
.skip(1)
|
||||
{
|
||||
let Some(field) = status.stamp_field() else {
|
||||
continue;
|
||||
};
|
||||
@@ -3403,10 +3413,10 @@ mod tests {
|
||||
assert!(error.to_string().contains("Campaign"), "{error}");
|
||||
}
|
||||
|
||||
/// The one stamp the target status carries, and nothing of the others: the fields
|
||||
/// are current state, not a record of every stage the ticket has been through.
|
||||
/// The stamp of the status being entered, added to what the ticket already carries:
|
||||
/// the fields accumulate down the flow, so the stages behind it stay readable.
|
||||
#[test]
|
||||
fn entering_a_status_stamps_its_field_and_clears_the_rest() {
|
||||
fn entering_a_status_stamps_its_field_and_keeps_the_ones_before_it() {
|
||||
let content = with_metadata(
|
||||
"- **ID**: abc\n- **Committed On**: 2026-08-01 09:00:00\n- **Status**: committed\n",
|
||||
);
|
||||
@@ -3415,25 +3425,64 @@ mod tests {
|
||||
set_status_stamp(&content, Status::Reviewing, "2026-08-22 10:11:12", "T").unwrap();
|
||||
|
||||
assert!(updated.contains("- **Submitted On**: 2026-08-22 10:11:12"), "{updated}");
|
||||
assert!(!updated.contains("**Committed On**"), "{updated}");
|
||||
assert!(updated.contains("- **Committed On**: 2026-08-01 09:00:00"), "{updated}");
|
||||
}
|
||||
|
||||
/// Backlog has no stamp of its own, so a backward move under `-f` leaves the ticket
|
||||
/// carrying none rather than a Completed On for work it has undone.
|
||||
/// Arrival truncates the journey at the target, so the stage the ticket has been
|
||||
/// sent back out of is dropped and the ones it still got through are not.
|
||||
#[test]
|
||||
fn arriving_removes_the_stamps_of_the_statuses_after_the_target() {
|
||||
let content = with_metadata(
|
||||
"- **ID**: abc\n\
|
||||
- **Committed On**: 2026-08-01 09:00:00\n\
|
||||
- **Submitted On**: 2026-08-02 09:00:00\n\
|
||||
- **Completed On**: 2026-08-03 09:00:00\n\
|
||||
- **Status**: done\n",
|
||||
);
|
||||
|
||||
let updated =
|
||||
set_status_stamp(&content, Status::Reviewing, "2026-08-22 10:11:12", "T").unwrap();
|
||||
|
||||
assert!(!updated.contains("**Completed On**"), "{updated}");
|
||||
assert!(updated.contains("- **Committed On**: 2026-08-01 09:00:00"), "{updated}");
|
||||
assert!(updated.contains("- **Submitted On**: 2026-08-22 10:11:12"), "{updated}");
|
||||
}
|
||||
|
||||
/// Backlog has no stamp of its own and every status follows it, so a ticket forced
|
||||
/// all the way back carries none of the three rather than a trail it has undone.
|
||||
#[test]
|
||||
fn moving_back_to_backlog_leaves_no_stamp_behind() {
|
||||
let content = with_metadata(
|
||||
"- **ID**: abc\n- **Completed On**: 2026-08-01 09:00:00\n- **Status**: done\n",
|
||||
"- **ID**: abc\n\
|
||||
- **Committed On**: 2026-08-01 09:00:00\n\
|
||||
- **Submitted On**: 2026-08-02 09:00:00\n\
|
||||
- **Completed On**: 2026-08-03 09:00:00\n\
|
||||
- **Status**: done\n",
|
||||
);
|
||||
|
||||
let updated =
|
||||
set_status_stamp(&content, Status::Backlog, "2026-08-22 10:11:12", "T").unwrap();
|
||||
|
||||
assert!(!updated.contains("**Completed On**"), "{updated}");
|
||||
for field in [COMMITTED_ON_FIELD, SUBMITTED_ON_FIELD, COMPLETED_ON_FIELD] {
|
||||
assert!(!updated.contains(&format!("**{}**", field)), "{updated}");
|
||||
}
|
||||
assert!(!updated.contains("2026-08-22 10:11:12"), "{updated}");
|
||||
assert!(updated.contains("- **ID**: abc\n- **Status**: done\n"), "{updated}");
|
||||
}
|
||||
|
||||
/// A skip stamps the target and nothing else. The stages it jumped over are left
|
||||
/// unwritten rather than given a time the ticket never spent there.
|
||||
#[test]
|
||||
fn a_forward_skip_stamps_only_the_status_it_lands_in() {
|
||||
let content = with_metadata("- **ID**: abc\n- **Status**: backlog\n");
|
||||
|
||||
let updated = set_status_stamp(&content, Status::Done, "2026-08-22 10:11:12", "T").unwrap();
|
||||
|
||||
assert!(updated.contains("- **Completed On**: 2026-08-22 10:11:12"), "{updated}");
|
||||
assert!(!updated.contains("**Committed On**"), "{updated}");
|
||||
assert!(!updated.contains("**Submitted On**"), "{updated}");
|
||||
}
|
||||
|
||||
/// Re-entry is the time of the move that brought it back, not the first one.
|
||||
#[test]
|
||||
fn re_entering_a_status_restamps_rather_than_keeping_the_earlier_value() {
|
||||
|
||||
@@ -1113,3 +1113,120 @@ fn campaign_set_offers_no_description_and_no_owner() {
|
||||
assert!(!help.contains("--owner"), "{help}");
|
||||
assert!(!help.contains("--clear"), "{help}");
|
||||
}
|
||||
|
||||
/// A codename is how a campaign is referred to once it has one: on every card in it and at
|
||||
/// the command line. Replacing that silently is the mistake `install-skill --force` exists
|
||||
/// to prevent, so it is refused and the refusal names the flag.
|
||||
#[test]
|
||||
fn an_existing_codename_is_not_replaced_without_force() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1", "-c", "beaver"]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
let said = stderr(&out);
|
||||
// Both words and the flag, so the message says what is there, what was asked for and
|
||||
// how to get it.
|
||||
assert!(said.contains("already codenamed 'v1'"), "{said}");
|
||||
assert!(said.contains("'beaver'"), "{said}");
|
||||
assert!(said.contains("--force"), "{said}");
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written anyway");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_replaces_an_existing_codename() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1", "-c", "beaver", "--force"]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("- **Codename**: beaver"), "{content}");
|
||||
// The line is replaced, not added beside the old one. Asserted on the field rather
|
||||
// than on the word, since the campaign's title is "v1 release" and holds it too.
|
||||
assert!(!content.contains("- **Codename**: v1"), "the old line survived: {content}");
|
||||
assert_eq!(content.matches("**Codename**").count(), 1, "two codenames: {content}");
|
||||
}
|
||||
|
||||
/// The guard is about overwriting a *different* word. A campaign with no codename has
|
||||
/// nothing to overwrite, so `--force` is not the price of the first one.
|
||||
#[test]
|
||||
fn the_first_codename_needs_no_force() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_A).contains("Codename"),
|
||||
"the fixture changed"
|
||||
);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(campaign_file(&worklane, CAMP_A).contains("- **Codename**: v1"));
|
||||
}
|
||||
|
||||
/// And setting the one it already has stays a no-op rather than becoming a refusal: there
|
||||
/// is nothing to overwrite, which is the same answer `install-skill` gives an identical
|
||||
/// document.
|
||||
#[test]
|
||||
fn setting_the_same_codename_again_is_a_no_op_not_a_refusal() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1", "-c", "v1"]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
|
||||
assert!(campaign_file(&worklane, CAMP_A).contains("- **Codename**: v1"));
|
||||
}
|
||||
|
||||
/// Refused before any edit is applied, like `SetArgs::contested`, so a call carrying both
|
||||
/// fields writes neither rather than half of what was asked for.
|
||||
#[test]
|
||||
fn a_refused_codename_takes_the_title_down_with_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1",
|
||||
"-t",
|
||||
"Renamed anyway",
|
||||
"-c",
|
||||
"beaver",
|
||||
],
|
||||
);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the title went through");
|
||||
let names = campaigns(&worklane);
|
||||
assert!(
|
||||
!names.iter().any(|name| name.contains("renamed-anyway")),
|
||||
"renamed: {names:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The title needs no guard, since a campaign always has one and replacing it is what the
|
||||
/// flag is for. `--force` is the codename's alone.
|
||||
#[test]
|
||||
fn the_title_is_replaced_without_force() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1", "--title", "First public release"]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(campaign_file(&worklane, CAMP_A).starts_with("# First public release\n"));
|
||||
}
|
||||
|
||||
+103
-13
@@ -923,35 +923,89 @@ fn ticket_at(worklane: &Path, status: &str, filename: &str) -> String {
|
||||
fs::read_to_string(worklane.join(status).join(filename)).unwrap()
|
||||
}
|
||||
|
||||
/// One field per status, written with the time of the move, and only the current one:
|
||||
/// the stamps are where the ticket is now, not the trail of how it got there.
|
||||
/// One field per status, written with the time of the move and added to the ones
|
||||
/// already there: walking the flow leaves the whole journey on the ticket.
|
||||
#[test]
|
||||
fn mv_stamps_the_field_of_the_status_it_enters() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
for (status, stamp, cleared) in [
|
||||
("committed", "Committed On", "Submitted On"),
|
||||
("reviewing", "Submitted On", "Committed On"),
|
||||
("done", "Completed On", "Submitted On"),
|
||||
// The fixture predates Created At as well as the stamps, and the four reading as
|
||||
// one block is the point, so it is seeded rather than asserted around.
|
||||
let path = worklane.join("backlog").join(&filename);
|
||||
let seeded = fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace("- **Status**:", "- **Created At**: 2026-08-01 09:00:00\n- **Status**:");
|
||||
fs::write(&path, seeded).unwrap();
|
||||
|
||||
let mut carried: Vec<&str> = Vec::new();
|
||||
|
||||
for (status, stamp) in [
|
||||
("committed", "Committed On"),
|
||||
("reviewing", "Submitted On"),
|
||||
("done", "Completed On"),
|
||||
] {
|
||||
let out = move_ticket(&temp, "cccc3333", status, false);
|
||||
assert!(out.status.success(), "{:?}", out);
|
||||
carried.push(stamp);
|
||||
|
||||
let content = ticket_at(&worklane, status, &filename);
|
||||
let value = field(&content, stamp)
|
||||
.unwrap_or_else(|| panic!("no {stamp} after moving to {status}: {content}"));
|
||||
|
||||
assert!(is_timestamp(&value), "{stamp} reads '{value}'");
|
||||
assert_eq!(field(&content, cleared), None, "{content}");
|
||||
for stamp in &carried {
|
||||
let value = field(&content, stamp)
|
||||
.unwrap_or_else(|| panic!("no {stamp} after moving to {status}: {content}"));
|
||||
assert!(is_timestamp(&value), "{stamp} reads '{value}'");
|
||||
}
|
||||
}
|
||||
|
||||
// The four side by side and in flow order, which is what a reader asking when this
|
||||
// was filed, picked up, handed over and finished gets one answer each from.
|
||||
let content = ticket_at(&worklane, "done", &filename);
|
||||
let block: Vec<&str> = content
|
||||
.lines()
|
||||
.filter_map(|line| line.strip_prefix("- **"))
|
||||
.filter_map(|line| line.split("**:").next())
|
||||
.skip_while(|name| *name != "Created At")
|
||||
.collect();
|
||||
|
||||
assert_eq!(
|
||||
block,
|
||||
[
|
||||
"Created At",
|
||||
"Committed On",
|
||||
"Submitted On",
|
||||
"Completed On",
|
||||
"Status"
|
||||
],
|
||||
"{content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Backlog has no stamp of its own, so a ticket forced back to it carries none at all
|
||||
/// rather than a Completed On for work that has been undone.
|
||||
/// Arrival clears what comes after it and nothing before, so a ticket sent back out of
|
||||
/// done keeps the stages it did get through.
|
||||
#[test]
|
||||
fn mv_removes_the_stamp_of_the_status_it_leaves() {
|
||||
fn mv_removes_the_stamps_of_the_statuses_after_the_one_it_enters() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
for status in ["committed", "reviewing", "done"] {
|
||||
move_ticket(&temp, "cccc3333", status, false);
|
||||
}
|
||||
|
||||
move_ticket(&temp, "cccc3333", "reviewing", true);
|
||||
|
||||
let content = ticket_at(&worklane, "reviewing", &filename);
|
||||
assert_eq!(field(&content, "Completed On"), None, "{content}");
|
||||
assert!(field(&content, "Committed On").is_some(), "{content}");
|
||||
assert!(field(&content, "Submitted On").is_some(), "{content}");
|
||||
}
|
||||
|
||||
/// Backlog has no stamp of its own and every status follows it, so a ticket forced back
|
||||
/// to it carries none at all rather than a Completed On for work that has been undone.
|
||||
#[test]
|
||||
fn mv_back_to_backlog_removes_all_three_stamps() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
@@ -968,6 +1022,42 @@ fn mv_removes_the_stamp_of_the_status_it_leaves() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A skip stamps where it lands and leaves the stages it jumped unwritten: an absent
|
||||
/// field says the ticket never got that far, and inventing one would say it did.
|
||||
#[test]
|
||||
fn mv_skipping_forward_stamps_only_the_target() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
move_ticket(&temp, "cccc3333", "done", true);
|
||||
|
||||
let content = ticket_at(&worklane, "done", &filename);
|
||||
assert!(field(&content, "Completed On").is_some(), "{content}");
|
||||
assert_eq!(field(&content, "Committed On"), None, "{content}");
|
||||
assert_eq!(field(&content, "Submitted On"), None, "{content}");
|
||||
}
|
||||
|
||||
/// The three are `mv`'s alone. Nothing that edits a ticket by hand offers a way to
|
||||
/// write one or take one away, so a stamp is always the record of a real move. Pinned
|
||||
/// so the omission stays a decision rather than becoming an oversight somebody fills in.
|
||||
#[test]
|
||||
fn no_other_command_can_write_or_clear_a_stamp() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
for command in ["add", "set", "append", "chown"] {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args([command, "--help"]);
|
||||
let out = cmd.assert().get_output().clone();
|
||||
let help = String::from_utf8_lossy(&out.stdout).to_lowercase();
|
||||
|
||||
for flag in ["committed-on", "submitted-on", "completed-on", "stamp"] {
|
||||
assert!(!help.contains(flag), "{command} --help names {flag}: {help}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-entry is the time of the move that brought the ticket back, not the first one.
|
||||
#[test]
|
||||
fn mv_restamps_a_status_the_ticket_is_re_entering() {
|
||||
|
||||
Reference in New Issue
Block a user