(451fb83) Add a discarded status for work that will not be done, and bump to 0.31.0
The flow ended at done, so a ticket that turned out to be a duplicate or obsolete had nowhere to go: it sat in the backlog or was deleted by hand, which destroyed the record and left every relation to it dangling. Discarded is a fifth status with its own directory, keeping the invariant that the filename, the Status field and the directory agree, and keeping done meaning the work landed. Entering it is allowed from any status without -f, because discarding is not a stage of work. Discarded sits last in Status::ALL, which is what makes the rest fall out rather than needing cases: nothing follows it, so a discard clears no stamp and a ticket abandoned from reviewing keeps the journey it made, and every move out is a backward move, so un-discarding needs -f. The two dependency guards now look opposite ways. check_blockers asks what a ticket waits on and gates work moves; check_dependents asks who waits on it and gates the discard, because those plans depended on work about to be declared never-happening. Both skip targets that are themselves terminal. Status::FLOW is the four stages the board draws, so a discarded column on screen stays a136d13's ticket and done stays the last drawn column. Every tree walker keeps using Status::ALL, or a discarded ticket would be unaddressable. util::is_open replaces three spellings of "not done and not discarded", across mv, ls and the campaign standing. The board's blocked mark goes through it as well: that path was only accidentally correct, since a discarded blocker is absent from the FLOW columns, and drawing the column later would have diverged it from what mv allows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
c03f47c52d
commit
5bf0fd1bfe
+7
-3
@@ -207,11 +207,11 @@ pub fn resolved_for(content: &str, worklane_dir: &Path) -> Result<Resolved> {
|
||||
})
|
||||
}
|
||||
|
||||
/// The members of a campaign, grouped by status in flow order.
|
||||
/// The members of a campaign, grouped by status in flow order, discarded last.
|
||||
///
|
||||
/// Read through `collect_ticket_items`, the source `ls` and the board already use, so
|
||||
/// there is no second parser and the rows print the way every other listing does.
|
||||
/// Empty groups are kept: a campaign's shape is the four statuses, and a caller that
|
||||
/// Empty groups are kept: a campaign's shape is the statuses, and a caller that
|
||||
/// wants only the filled ones can say so.
|
||||
pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec<TicketItem>)>> {
|
||||
let mut grouped = Vec::new();
|
||||
@@ -251,9 +251,13 @@ pub struct Standing {
|
||||
impl Standing {
|
||||
pub fn of(grouped: &[(&'static str, Vec<TicketItem>)]) -> Self {
|
||||
Self {
|
||||
// Discarded counts as finished: the work was decided out of the campaign,
|
||||
// not left in it, and one abandoned ticket must not hold a campaign open
|
||||
// forever. The same predicate `mv` gates on, so "nothing outstanding" means
|
||||
// one thing across the tool.
|
||||
done: grouped
|
||||
.iter()
|
||||
.filter(|(status, _)| *status == DONE)
|
||||
.filter(|(status, _)| !is_open(status))
|
||||
.map(|(_, items)| items.len())
|
||||
.sum(),
|
||||
total: grouped.iter().map(|(_, items)| items.len()).sum(),
|
||||
|
||||
+1
-1
@@ -568,7 +568,7 @@ mod tests {
|
||||
status.as_str()
|
||||
);
|
||||
}
|
||||
assert!(script.contains("-a 'backlog committed reviewing done' -d status"));
|
||||
assert!(script.contains("-a 'backlog committed reviewing done discarded' -d status"));
|
||||
for shell in ["fish", "bash", "zsh", "elvish", "powershell"] {
|
||||
assert!(script.contains(shell), "the shell positional is never offered {shell}");
|
||||
}
|
||||
|
||||
+73
-9
@@ -113,11 +113,12 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
|
||||
println!(" [{}] {} {}", status.to_uppercase(), count, label);
|
||||
}
|
||||
|
||||
// Show all tickets except done grouped by status. Over `Status::ALL` rather
|
||||
// than the names, because each column is ordered by its own entry stamp and the
|
||||
// comparator is keyed on the status, not on the directory it was read from.
|
||||
// Show all tickets except the two terminal statuses, grouped by status. Over
|
||||
// `Status::ALL` rather than the names, because each column is ordered by its own
|
||||
// entry stamp and the comparator is keyed on the status, not on the directory it
|
||||
// was read from.
|
||||
for status in Status::ALL {
|
||||
if status.as_str() == DONE {
|
||||
if !is_open(status.as_str()) {
|
||||
continue;
|
||||
}
|
||||
let status_path = worklane_dir.join(status.as_str());
|
||||
@@ -524,7 +525,10 @@ fn check_blockers(worklane_dir: &Path, content: &str, title: &str) -> Result<()>
|
||||
|
||||
for blocker in &blockers {
|
||||
match index.get(&blocker.target) {
|
||||
Some(target) if target.status == DONE => {}
|
||||
// Discarded satisfies a block the way done does: there is nothing left to
|
||||
// wait for. Whether the dependent still makes sense was asked when the
|
||||
// blocker was discarded, which is `check_dependents`' refusal.
|
||||
Some(target) if !is_open(&target.status) => {}
|
||||
Some(target) => open.push(format!(
|
||||
" ({}) {} [{}]",
|
||||
color_text(short_id(&target.uuid), Color::Red),
|
||||
@@ -552,6 +556,49 @@ fn check_blockers(worklane_dir: &Path, content: &str, title: &str) -> Result<()>
|
||||
))
|
||||
}
|
||||
|
||||
/// Refuse discarding a ticket while open tickets are blocked by it.
|
||||
///
|
||||
/// The mirror of [`check_blockers`], asked at the other end of the edge: those tickets
|
||||
/// recorded a dependency on work that is about to be declared never-happening, so their
|
||||
/// plans need a look before the ground moves. `-f` is the caller saying they looked.
|
||||
///
|
||||
/// Tickets already done or discarded do not hold it up: a dependency that was satisfied
|
||||
/// or abandoned is nobody's plan anymore.
|
||||
fn check_dependents(worklane_dir: &Path, uuid: &str, title: &str) -> Result<()> {
|
||||
let index = RelationIndex::load(worklane_dir)?;
|
||||
|
||||
// Every open dependent, not the first, for the reason `check_blockers` names them
|
||||
// all.
|
||||
let waiting: Vec<String> = index
|
||||
.iter()
|
||||
.filter(|ticket| is_open(&ticket.status))
|
||||
.filter(|ticket| {
|
||||
ticket
|
||||
.relations
|
||||
.iter()
|
||||
.any(|relation| relation.kind == RelationKind::BlockedBy && relation.target == uuid)
|
||||
})
|
||||
.map(|ticket| {
|
||||
format!(
|
||||
" ({}) {} [{}]",
|
||||
color_text(short_id(&ticket.uuid), Color::Red),
|
||||
ticket.title,
|
||||
color_text(&ticket.status, Color::Orange),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if waiting.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
"Cannot discard '{}' while open tickets are blocked by it:\n{}\nUse --force (-f) to discard it anyway.",
|
||||
color_text(title, Color::Green),
|
||||
waiting.join("\n"),
|
||||
))
|
||||
}
|
||||
|
||||
/// A status is a [`Status`] rather than a string, so an unknown one is clap's to refuse
|
||||
/// and nothing here has to check. What is left is the order of the flow, which is
|
||||
/// `Status::ALL`.
|
||||
@@ -573,7 +620,13 @@ pub fn cmd_mv(
|
||||
.unwrap();
|
||||
let target_idx = Status::ALL.iter().position(|status| *status == target).unwrap();
|
||||
|
||||
if !force && target_idx < current_idx {
|
||||
// Discarding is not a stage of work, so the walk rules below do not apply to
|
||||
// entering it: a ticket is abandoned from wherever it stands. They do apply to
|
||||
// leaving it, which with discarded last in `Status::ALL` is always a backward move,
|
||||
// so un-discarding needs `-f` with no rule of its own.
|
||||
let discarding = target == Status::Discarded;
|
||||
|
||||
if !force && !discarding && target_idx < current_idx {
|
||||
return Err(anyhow!(
|
||||
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
|
||||
color_text(¤t_status, Color::Orange),
|
||||
@@ -581,7 +634,7 @@ pub fn cmd_mv(
|
||||
));
|
||||
}
|
||||
|
||||
if !force && target_idx != current_idx + 1 && target_idx != current_idx {
|
||||
if !force && !discarding && target_idx != current_idx + 1 && target_idx != current_idx {
|
||||
return Err(anyhow!(
|
||||
"Can only move one stage forward at a time. Use --force (-f) to skip stages."
|
||||
));
|
||||
@@ -597,14 +650,25 @@ pub fn cmd_mv(
|
||||
|
||||
// After the no-op above, so a ticket is never refused for a move it is not making,
|
||||
// and behind `force`, which is where the other two overrides of a rule the board
|
||||
// keeps true already live.
|
||||
// keeps true already live. The two guards look opposite ways: a ticket being worked
|
||||
// must not run ahead of what it waits on, and a ticket being abandoned owes nothing
|
||||
// to its own blockers but must not be pulled out from under the tickets waiting on
|
||||
// it.
|
||||
if !force {
|
||||
check_blockers(&worklane_dir, &resolved, &title)?;
|
||||
match discarding {
|
||||
true => check_dependents(&worklane_dir, &parse_ticket_field(&resolved, "ID"), &title)?,
|
||||
false => check_blockers(&worklane_dir, &resolved, &title)?,
|
||||
}
|
||||
}
|
||||
|
||||
let current_path = worklane_dir.join(¤t_status);
|
||||
let target_path = worklane_dir.join(target_status);
|
||||
|
||||
// A board created before a status existed has no directory for it, and the first
|
||||
// move into one is the wrong place to refuse. Idempotent for every board that has
|
||||
// it.
|
||||
fs::create_dir_all(&target_path)?;
|
||||
|
||||
// Updated before the file is even located, so a ticket without a Status field is
|
||||
// refused for that reason rather than for whatever the lookup notices first.
|
||||
let content = set_status_field(&resolved, target_status, &title)?;
|
||||
|
||||
+39
-11
@@ -2013,9 +2013,11 @@ fn columns_of(worklane_dir: &Path) -> (Vec<Column>, CampaignIndex, TagIndex) {
|
||||
// `unwrap_or_default` on the campaigns index already avoids.
|
||||
let tags = TagIndex::load(worklane_dir).unwrap_or_default();
|
||||
|
||||
// Over `Status::ALL` rather than the names: each column is ordered by its own entry
|
||||
// stamp, so the build needs the status itself and not just the directory to read.
|
||||
let mut columns: Vec<Column> = Status::ALL
|
||||
// Over `Status::FLOW`, not `Status::ALL`: the board draws the stages work moves
|
||||
// through, and a discarded column on screen is a136d13's ticket, not a side effect
|
||||
// of the status existing. Each column is ordered by its own entry stamp, so the
|
||||
// build needs the status itself and not just the directory to read.
|
||||
let mut columns: Vec<Column> = Status::FLOW
|
||||
.into_iter()
|
||||
.map(|status| {
|
||||
// An absent or unreadable directory is an empty column, not a missing one:
|
||||
@@ -2245,7 +2247,7 @@ fn mark_blocked(columns: &mut [Column]) {
|
||||
for column in columns.iter_mut() {
|
||||
for card in column.cards.iter_mut() {
|
||||
card.blocked = card.ticket.blockers.iter().any(|blocker| {
|
||||
matches!(status_of.get(blocker.as_str()), Some(status) if *status != DONE)
|
||||
matches!(status_of.get(blocker.as_str()), Some(status) if is_open(status))
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2258,8 +2260,9 @@ fn mark_blocked(columns: &mut [Column]) {
|
||||
/// left as one project's column after another's: an overview whose order depended on
|
||||
/// the argument order would bury a p1 under another project's p5.
|
||||
fn merge(per_project: &[Vec<Column>], projects: &[Project]) -> Vec<Column> {
|
||||
status_dirs()
|
||||
Status::FLOW
|
||||
.into_iter()
|
||||
.map(Status::as_str)
|
||||
.enumerate()
|
||||
.map(|(index, status)| {
|
||||
let mut cards: Vec<Card> = Vec::new();
|
||||
@@ -3999,11 +4002,15 @@ mod tests {
|
||||
assert!(shown.ends_with('┐'), "{shown}");
|
||||
}
|
||||
|
||||
/// Hiding is a prefix of the columns, which only holds while done is last. The
|
||||
/// board leans on that, so the assumption is pinned rather than assumed.
|
||||
/// Hiding is a prefix of the columns, which only holds while done is last of what
|
||||
/// the board draws. The board leans on that, so the assumption is pinned rather
|
||||
/// than assumed. Discarded being last overall is the other decided order: the stamp
|
||||
/// arrival rule truncates by `Status::ALL`, so discarded after done is what lets a
|
||||
/// discard keep the journey the ticket made.
|
||||
#[test]
|
||||
fn the_done_column_is_last() {
|
||||
assert_eq!(status_dirs().last(), Some(&DONE));
|
||||
assert_eq!(Status::FLOW.last().map(|status| status.as_str()), Some(DONE));
|
||||
assert_eq!(status_dirs().last(), Some(&DISCARDED));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -4574,8 +4581,8 @@ mod tests {
|
||||
|
||||
board.toggle_done(SCREEN);
|
||||
let row = headings(&board, 120, 20);
|
||||
for status in status_dirs() {
|
||||
assert!(row.contains(&format!("{status} (0)")), "{row}");
|
||||
for status in Status::FLOW {
|
||||
assert!(row.contains(&format!("{} (0)", status.as_str())), "{row}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6360,6 +6367,27 @@ mod tests {
|
||||
assert!(marked_blocked(&one_board(&dir), "The waiter"));
|
||||
}
|
||||
|
||||
/// A discarded blocker holds nothing up, the answer `mv` gives it: there is nothing
|
||||
/// left to wait for.
|
||||
///
|
||||
/// The board reaches it through `is_open` rather than through the blocker being
|
||||
/// absent from the columns, which is what it would be today, since `columns_of`
|
||||
/// builds `Status::FLOW` and discarded is not in it. That distinction is the point of
|
||||
/// this test: when a136d13 draws the discarded column the blocker arrives in the map,
|
||||
/// and a rule written as `!= DONE` would start marking these cards while `mv` kept
|
||||
/// letting them move. The fixture writes the directory directly for that reason.
|
||||
#[test]
|
||||
fn a_discarded_blocker_marks_nothing() {
|
||||
let dir = board_dir();
|
||||
std::fs::create_dir_all(dir.join(DISCARDED)).unwrap();
|
||||
write_ticket(&dir, DISCARDED, BLOCKER, "The blocker", "");
|
||||
write_ticket(&dir, "backlog", WAITER, "The waiter", &blocked_by(BLOCKER));
|
||||
|
||||
assert!(!marked_blocked(&one_board(&dir), "The waiter"));
|
||||
assert!(!is_open(DISCARDED), "the rule the board and mv share");
|
||||
assert!(is_open("backlog") && is_open("committed") && is_open("reviewing"));
|
||||
}
|
||||
|
||||
/// The answer `mv` gives a dangling uuid: a bookkeeping fault, not a dependency.
|
||||
#[test]
|
||||
fn a_blocker_the_board_does_not_hold_marks_nothing() {
|
||||
@@ -7985,7 +8013,7 @@ mod tests {
|
||||
.collect();
|
||||
assert_eq!(titles, vec!["In v1".to_string(), "Also in v1".to_string()], "{titles:?}");
|
||||
// Every column is kept, empty ones included: a campaign's shape is the flow.
|
||||
assert_eq!(board.current().columns.len(), status_dirs().len());
|
||||
assert_eq!(board.current().columns.len(), Status::FLOW.len());
|
||||
}
|
||||
|
||||
/// The frame says which campaign the columns belong to, and how far it has got, from
|
||||
|
||||
+82
-18
@@ -1437,7 +1437,7 @@ pub fn parse_tags(content: &str) -> Vec<String> {
|
||||
/// Directly after ID, because that is where `campaign_body` writes it, so a campaign given
|
||||
/// a codename later ends up with the same file as one filed with it. Nothing ever upserts
|
||||
/// it on a ticket, so its place in a ticket's order costs nothing.
|
||||
const METADATA_ORDER: [&str; 12] = [
|
||||
const METADATA_ORDER: [&str; 13] = [
|
||||
"ID",
|
||||
CODENAME_FIELD,
|
||||
"Priority",
|
||||
@@ -1448,6 +1448,7 @@ const METADATA_ORDER: [&str; 12] = [
|
||||
COMMITTED_ON_FIELD,
|
||||
SUBMITTED_ON_FIELD,
|
||||
COMPLETED_ON_FIELD,
|
||||
DISCARDED_ON_FIELD,
|
||||
CAMPAIGN_FIELD,
|
||||
"Status",
|
||||
];
|
||||
@@ -1532,6 +1533,7 @@ fn insert_metadata_field(content: &str, field: &str, value: &str, title: &str) -
|
||||
pub const COMMITTED_ON_FIELD: &str = "Committed On";
|
||||
pub const SUBMITTED_ON_FIELD: &str = "Submitted On";
|
||||
pub const COMPLETED_ON_FIELD: &str = "Completed On";
|
||||
pub const DISCARDED_ON_FIELD: &str = "Discarded On";
|
||||
|
||||
/// Stamp the field of the status being entered and drop the ones after it.
|
||||
///
|
||||
@@ -2196,6 +2198,12 @@ impl RelationIndex {
|
||||
self.tickets.iter().find(|ticket| ticket.uuid == uuid)
|
||||
}
|
||||
|
||||
/// Every ticket the index holds, for a caller asking about the derived direction:
|
||||
/// which tickets point *at* one, which no single `get` can answer.
|
||||
pub fn iter(&self) -> impl Iterator<Item = &RelatedTicket> {
|
||||
self.tickets.iter()
|
||||
}
|
||||
|
||||
/// The relations other tickets hold pointing at `uuid`, as the kind reads from
|
||||
/// this end and the ticket that holds it.
|
||||
///
|
||||
@@ -2288,11 +2296,14 @@ pub const REGRESSION_MARK: &str = "\u{2190}";
|
||||
/// nobody has picked up, orange for work in hand, cyan for work waiting on a reader,
|
||||
/// green for done. Green is the one the priority ramp deliberately leaves out because it
|
||||
/// means a title, and it is safe on a one-cell mark that no title sits behind.
|
||||
const STATUS_MARKS: [(&str, &str, Color); 4] = [
|
||||
const STATUS_MARKS: [(&str, &str, Color); 5] = [
|
||||
("backlog", "\u{25cb}", Color::Grey),
|
||||
("committed", "\u{25d0}", Color::Orange),
|
||||
("reviewing", "\u{25d0}", Color::Cyan),
|
||||
("done", "\u{25cf}", Color::Green),
|
||||
// The full circle of done in the grey of the untouched pile: nothing is left to do,
|
||||
// and it is not an achievement. The pair is what is unique, as with the two halves.
|
||||
("discarded", "\u{25cf}", Color::Grey),
|
||||
];
|
||||
|
||||
/// The mark for a status, or `?` for a target the board no longer holds.
|
||||
@@ -2675,35 +2686,54 @@ pub fn trim_blank_ends(values: &[String]) -> &[String] {
|
||||
/// A status, as clap accepts it and as the directory is named.
|
||||
///
|
||||
/// An enum rather than the string it was, so an unknown status is a usage error at parse
|
||||
/// time with the four listed, the way `priority_level` and `iso_date` refuse a bad level
|
||||
/// time with the five listed, the way `priority_level` and `iso_date` refuse a bad level
|
||||
/// or date. That is the bargain the scalars already take, see AGENTS.md: nothing is
|
||||
/// written, the exit code is 2, and no handler has to check. It also gives every shell
|
||||
/// that completes possible values the four names for free.
|
||||
/// that completes possible values the five names for free.
|
||||
///
|
||||
/// The variants are in flow order, which is the order `mv` reads to decide whether a
|
||||
/// move goes forward, and the order [`status_dirs`] hands the two views.
|
||||
/// The variants are in flow order with `Discarded` last, which is the order `mv` reads
|
||||
/// to decide whether a move goes forward and the order the stamp arrival rule truncates
|
||||
/// by. Discarded sits after done deliberately: entering it clears nothing, so a ticket
|
||||
/// discarded from reviewing keeps the journey it made, and leaving it is always a
|
||||
/// backward move, which is what makes un-discarding need `-f` for free.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
|
||||
pub enum Status {
|
||||
Backlog,
|
||||
Committed,
|
||||
Reviewing,
|
||||
Done,
|
||||
Discarded,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
/// Every status, in flow order. The one list, which [`status_dirs`], `mv` and every
|
||||
/// caller of [`by_status_order`] read rather than spelling the four names again.
|
||||
pub const ALL: [Status; 4] = [
|
||||
/// Every status, in flow order with discarded last. The one list, which
|
||||
/// [`status_dirs`], `mv` and every caller of [`by_status_order`] read rather than
|
||||
/// spelling the five names again.
|
||||
pub const ALL: [Status; 5] = [
|
||||
Status::Backlog,
|
||||
Status::Committed,
|
||||
Status::Reviewing,
|
||||
Status::Done,
|
||||
Status::Discarded,
|
||||
];
|
||||
|
||||
/// The stages work moves through: every status but discarded, which work never
|
||||
/// moves through, it only ends up in.
|
||||
///
|
||||
/// What the board draws its columns from, so done stays the last drawn column and
|
||||
/// hiding it stays a prefix of the list. Showing a discarded column is a136d13's,
|
||||
/// not a side effect of the status existing.
|
||||
pub const FLOW: [Status; 4] = [
|
||||
Status::Backlog,
|
||||
Status::Committed,
|
||||
Status::Reviewing,
|
||||
Status::Done,
|
||||
];
|
||||
|
||||
/// The field `mv` stamps on entering this status, for the three that have one.
|
||||
/// The field `mv` stamps on entering this status, for the four that have one.
|
||||
///
|
||||
/// Derived from the status rather than spelled at the call site, so the mapping is
|
||||
/// in one place and a fifth status either brings its own stamp or explicitly has
|
||||
/// in one place and a new status either brings its own stamp or explicitly has
|
||||
/// none.
|
||||
pub const fn stamp_field(self) -> Option<&'static str> {
|
||||
match self {
|
||||
@@ -2711,6 +2741,7 @@ impl Status {
|
||||
Status::Committed => Some(COMMITTED_ON_FIELD),
|
||||
Status::Reviewing => Some(SUBMITTED_ON_FIELD),
|
||||
Status::Done => Some(COMPLETED_ON_FIELD),
|
||||
Status::Discarded => Some(DISCARDED_ON_FIELD),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2722,6 +2753,7 @@ impl Status {
|
||||
Status::Committed => "committed",
|
||||
Status::Reviewing => "reviewing",
|
||||
Status::Done => "done",
|
||||
Status::Discarded => "discarded",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2734,11 +2766,34 @@ pub fn status_dirs() -> Vec<&'static str> {
|
||||
/// in the summary and leaves it out of the listing, and the board hides its column until
|
||||
/// asked. Named because that rule now has two readers.
|
||||
///
|
||||
/// It is deliberately last in `status_dirs()`. The board leans on that: hiding done drops
|
||||
/// the final column, so the other three keep their indices and the selection only has to
|
||||
/// be handled when it is sitting on done itself.
|
||||
/// It is deliberately last in [`Status::FLOW`], which is what the board draws. The board
|
||||
/// leans on that: hiding done drops the final column, so the other three keep their
|
||||
/// indices and the selection only has to be handled when it is sitting on done itself.
|
||||
pub const DONE: &str = Status::Done.as_str();
|
||||
|
||||
/// Where a ticket that will not be done ends up: the other terminal status, and the
|
||||
/// other one `ls` leaves out of the listing.
|
||||
///
|
||||
/// A discarded ticket counts as finished wherever progress is measured, since nothing is
|
||||
/// left to do, and blocks nothing. What it is not is done: the two directories keep
|
||||
/// "the work landed" and "the work was abandoned" answerable apart.
|
||||
pub const DISCARDED: &str = Status::Discarded.as_str();
|
||||
|
||||
/// Whether a ticket in this status still has something outstanding.
|
||||
///
|
||||
/// The two terminal statuses do not: done landed and discarded never will, so in both
|
||||
/// cases there is nothing left to wait for and nothing left to plan around. One spelling
|
||||
/// for all three readers, because `mv` refuses a move on it, refuses a discard on it and
|
||||
/// the board draws its blocked mark from it, and two views disagreeing about what counts
|
||||
/// as open would be the difference nobody can explain later.
|
||||
///
|
||||
/// Takes the status as a string because that is what the callers hold: the directory a
|
||||
/// ticket was found in, not a parsed [`Status`]. An unrecognised value reads as open,
|
||||
/// which is the safe direction: it surfaces rather than silently satisfying a block.
|
||||
pub fn is_open(status: &str) -> bool {
|
||||
status != DONE && status != DISCARDED
|
||||
}
|
||||
|
||||
/// Lowest and highest level a ticket can carry. 1 is the most urgent, which is
|
||||
/// what the `p1` to `p3` tags this replaced already meant.
|
||||
pub const PRIORITY_RANGE: std::ops::RangeInclusive<u8> = 1..=5;
|
||||
@@ -2867,6 +2922,8 @@ pub struct TicketItem {
|
||||
pub submitted_on: Option<String>,
|
||||
/// The same for done.
|
||||
pub completed_on: Option<String>,
|
||||
/// The same for discarded.
|
||||
pub discarded_on: Option<String>,
|
||||
}
|
||||
|
||||
impl TicketItem {
|
||||
@@ -2882,6 +2939,7 @@ impl TicketItem {
|
||||
Status::Committed => self.committed_on.as_deref(),
|
||||
Status::Reviewing => self.submitted_on.as_deref(),
|
||||
Status::Done => self.completed_on.as_deref(),
|
||||
Status::Discarded => self.discarded_on.as_deref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3076,6 +3134,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
committed_on: parse_stamp(&content, Status::Committed),
|
||||
submitted_on: parse_stamp(&content, Status::Reviewing),
|
||||
completed_on: parse_stamp(&content, Status::Done),
|
||||
discarded_on: parse_stamp(&content, Status::Discarded),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -3104,7 +3163,8 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
|
||||
/// always printed. Past the backlog the question changes: committed asks what has waited
|
||||
/// longest, reviewing what was handed over first, done what just landed. The head of
|
||||
/// every column is therefore what the reader acts on next, which is ascending by entry
|
||||
/// stamp in committed and reviewing and descending in done, the way a changelog reads.
|
||||
/// stamp in committed and reviewing and descending in done and discarded, the way a
|
||||
/// changelog reads.
|
||||
///
|
||||
/// A ticket with no stamp sinks below every stamped one in its column. A missing time is
|
||||
/// unknown, not ancient, and unknown must not claim the head of a queue ahead of a wait
|
||||
@@ -3118,7 +3178,7 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
|
||||
pub fn by_status_order(status: Status, a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
|
||||
let by_stamp = match (a.entry_stamp(status), b.entry_stamp(status)) {
|
||||
(Some(left), Some(right)) => match status {
|
||||
Status::Done => right.cmp(left),
|
||||
Status::Done | Status::Discarded => right.cmp(left),
|
||||
_ => left.cmp(right),
|
||||
},
|
||||
(Some(_), None) => std::cmp::Ordering::Less,
|
||||
@@ -4132,7 +4192,11 @@ mod tests {
|
||||
_ => None,
|
||||
},
|
||||
completed_on: match status {
|
||||
Status::Done => stamp,
|
||||
Status::Done => stamp.clone(),
|
||||
_ => None,
|
||||
},
|
||||
discarded_on: match status {
|
||||
Status::Discarded => stamp,
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
@@ -5190,7 +5254,7 @@ Plain line with **bold** and a [link](http://x.test/a).
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(seen.len(), 4, "{seen:?}");
|
||||
assert_eq!(seen.len(), status_dirs().len(), "{seen:?}");
|
||||
}
|
||||
|
||||
/// An unrecognised value reads as missing rather than as a fifth stage of the flow.
|
||||
|
||||
Reference in New Issue
Block a user