Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39ee86e308 | ||
|
|
5a7cfeb849 |
@@ -79,7 +79,7 @@ worklane show "ticket title or uuid"
|
|||||||
Move a ticket between statuses.
|
Move a ticket between statuses.
|
||||||
|
|
||||||
**Positional arguments:**
|
**Positional arguments:**
|
||||||
- `<id>`: Ticket UUID (8+ characters) or title
|
- `<id>`: Ticket UUID prefix (4+ characters) or title
|
||||||
|
|
||||||
**Required options:**
|
**Required options:**
|
||||||
- `--status <target>`: Target status (`backlog`, `committed`, `reviewing`, `done`)
|
- `--status <target>`: Target status (`backlog`, `committed`, `reviewing`, `done`)
|
||||||
@@ -103,7 +103,7 @@ worklane mv "My Ticket" --status done -f # Move by title with force
|
|||||||
Add a comment to a ticket.
|
Add a comment to a ticket.
|
||||||
|
|
||||||
**Positional arguments:**
|
**Positional arguments:**
|
||||||
- `<ticket>`: Ticket UUID (8+ characters) or title
|
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||||
- `<body>`: Comment text
|
- `<body>`: Comment text
|
||||||
|
|
||||||
Comments are stored as timestamped markdown files in `.worklane/comments/<ticket-uuid>/` and include the git author and timestamp.
|
Comments are stored as timestamped markdown files in `.worklane/comments/<ticket-uuid>/` and include the git author and timestamp.
|
||||||
|
|||||||
+45
-18
@@ -38,6 +38,39 @@ async function run(cmd: string[], context: ToolContext): Promise<string> {
|
|||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description lines as worklane wants them, one --description value per line,
|
||||||
|
* blank ones included.
|
||||||
|
*
|
||||||
|
* cmd_add joins the values with a single newline, so an empty value is how a
|
||||||
|
* paragraph break is spelled. Dropping the blanks here, which is what the old
|
||||||
|
* filter(Boolean) did, collapsed every multi paragraph description into a single
|
||||||
|
* paragraph, against this tool's own instruction to separate paragraphs with
|
||||||
|
* newlines.
|
||||||
|
*
|
||||||
|
* Only the ends are trimmed, and only trailing whitespace within a line. Leading
|
||||||
|
* whitespace is content: it is what makes a nested markdown list or an indented
|
||||||
|
* block survive the trip.
|
||||||
|
*/
|
||||||
|
function descriptionLines(text: string): string[] {
|
||||||
|
const lines = text.split("\n").map((line: string) => line.trimEnd());
|
||||||
|
|
||||||
|
let start = 0;
|
||||||
|
let end = lines.length;
|
||||||
|
while (start < end && lines[start] === "") start++;
|
||||||
|
while (end > start && lines[end - 1] === "") end--;
|
||||||
|
|
||||||
|
return lines.slice(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One value per non-empty line, for the arguments that hold a list of items. */
|
||||||
|
function itemLines(text: string): string[] {
|
||||||
|
return text
|
||||||
|
.split("\n")
|
||||||
|
.map((line: string) => line.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
export const init = tool({
|
export const init = tool({
|
||||||
description:
|
description:
|
||||||
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
|
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
|
||||||
@@ -87,27 +120,21 @@ export const add = tool({
|
|||||||
}
|
}
|
||||||
const cmd: string[] = ["add", "--title", args.title];
|
const cmd: string[] = ["add", "--title", args.title];
|
||||||
if (args.description) {
|
if (args.description) {
|
||||||
args.description
|
descriptionLines(args.description).forEach((line: string) =>
|
||||||
.split("\n")
|
cmd.push("--description", line),
|
||||||
.map((l: string) => l.trim())
|
);
|
||||||
.filter(Boolean)
|
|
||||||
.forEach((line: string) => cmd.push("--description", line));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Blanks are dropped from these two on purpose: each value is one criterium or
|
||||||
|
// one step, so an empty line between them is spacing rather than content.
|
||||||
if (args.acceptance) {
|
if (args.acceptance) {
|
||||||
args.acceptance
|
itemLines(args.acceptance).forEach((line: string) =>
|
||||||
.split("\n")
|
cmd.push("--acceptance", line),
|
||||||
.map((l: string) => l.trim())
|
);
|
||||||
.filter(Boolean)
|
|
||||||
.forEach((line: string) => cmd.push("--acceptance", line));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.plan) {
|
if (args.plan) {
|
||||||
args.plan
|
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
|
||||||
.split("\n")
|
|
||||||
.map((l: string) => l.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
.forEach((line: string) => cmd.push("--plan", line));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.tags) cmd.push("--tags", args.tags);
|
if (args.tags) cmd.push("--tags", args.tags);
|
||||||
@@ -155,7 +182,7 @@ export const show = tool({
|
|||||||
args: {
|
args: {
|
||||||
id: tool.schema
|
id: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||||
},
|
},
|
||||||
async execute(args: Record<string, any>, context: ToolContext) {
|
async execute(args: Record<string, any>, context: ToolContext) {
|
||||||
if (!args.id) {
|
if (!args.id) {
|
||||||
@@ -175,7 +202,7 @@ export const mv = tool({
|
|||||||
args: {
|
args: {
|
||||||
ticket: tool.schema
|
ticket: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||||
status: tool.schema
|
status: tool.schema
|
||||||
.enum(["backlog", "committed", "reviewing", "done"])
|
.enum(["backlog", "committed", "reviewing", "done"])
|
||||||
.describe("Target status (required)"),
|
.describe("Target status (required)"),
|
||||||
@@ -207,7 +234,7 @@ export const comment = tool({
|
|||||||
args: {
|
args: {
|
||||||
ticket: tool.schema
|
ticket: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||||
body: tool.schema
|
body: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
|
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
- The ticket positionals (`show <id>`, `mv <ticket>`, `comment <ticket>`) are also left alone, so a search term starting with a hyphen is a usage error. Reachable now that a hyphen-leading title can be stored: use the UUID, or put the flags first and separate with `--`, as in `mv --status committed -- -leading-title`
|
- The ticket positionals (`show <id>`, `mv <ticket>`, `comment <ticket>`) are also left alone, so a search term starting with a hyphen is a usage error. Reachable now that a hyphen-leading title can be stored: use the UUID, or put the flags first and separate with `--`, as in `mv --status committed -- -leading-title`
|
||||||
- A bare `--` is a value when it follows an option (`--title -- ` stores `--`) and clap's end-of-options marker when it sits in a positional. So a `comment` body of exactly `--` needs its own separator, `comment <ticket> -- --`. Without it the body is reported missing and nothing is written, which is a clear failure rather than a silent drop
|
- A bare `--` is a value when it follows an option (`--title -- ` stores `--`) and clap's end-of-options marker when it sits in a positional. So a `comment` body of exactly `--` needs its own separator, `comment <ticket> -- --`. Without it the body is reported missing and nothing is written, which is a clear failure rather than a silent drop
|
||||||
- `add` has no positionals, so anything after a bare `--` is an unexpected argument and fails
|
- `add` has no positionals, so anything after a bare `--` is an unexpected argument and fails
|
||||||
|
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
|
||||||
|
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
|
||||||
|
|
||||||
### Color and Output
|
### Color and Output
|
||||||
- Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection)
|
- Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection)
|
||||||
@@ -67,7 +69,9 @@
|
|||||||
|
|
||||||
### Ticket Resolution
|
### Ticket Resolution
|
||||||
- `resolve_ticket()` returns `(status, title, content)` tuple
|
- `resolve_ticket()` returns `(status, title, content)` tuple
|
||||||
- Priority: exact UUID prefix (8+ chars) > title substring > filename substring
|
- Three tiers, evaluated in order: UUID prefix > title substring > filename substring. The first non-empty tier wins outright and later tiers are not consulted. This is not cosmetic: ticket titles reference other tickets by id, so a flat OR of the three reported an exact prefix match as ambiguous against whichever title mentioned it
|
||||||
|
- The UUID tier applies from `MIN_ID_SEARCH` (4) characters up. Not 8: `ls` prints `SHORT_ID_WIDTH` (7) characters, so a longer minimum would drop the printed id out of the UUID tier and let any title quoting it win instead. Below the minimum the search is text, so `show 641` is a title search
|
||||||
|
- The filename tier earns its place by reaching the middle of a UUID, which the prefix tier cannot. It is also why a short UUID search still resolves under a longer minimum, just at the wrong precedence, so a test for the minimum needs a decoy title to be meaningful
|
||||||
- Ambiguous matches (multiple results) print options and exit(1)
|
- Ambiguous matches (multiple results) print options and exit(1)
|
||||||
- Never return empty strings for required fields — use `_Not set_` or `_None_` as defaults
|
- Never return empty strings for required fields — use `_Not set_` or `_None_` as defaults
|
||||||
|
|
||||||
|
|||||||
Generated
+1
-1
@@ -1029,7 +1029,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "worklane"
|
name = "worklane"
|
||||||
version = "0.3.3"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "worklane"
|
name = "worklane"
|
||||||
version = "0.3.3"
|
version = "0.4.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Worklane is a local Kanban flow for agentic software development.
|
|||||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||||
| `worklane show <id>` | Shows ticket by UUID prefix (8+ chars) or title substring |
|
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
|
||||||
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
||||||
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
|
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,9 @@ pub fn cmd_add(
|
|||||||
return Err(anyhow!("A ticket with this title already exists."));
|
return Err(anyhow!("A ticket with this title already exists."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Joined with a single newline, so an empty value is how a caller spells a
|
||||||
|
// paragraph break and an all-blank description is no description at all.
|
||||||
|
let description = trim_blank_ends(description);
|
||||||
let description_text = if description.is_empty() {
|
let description_text = if description.is_empty() {
|
||||||
"_No description provided._".to_string()
|
"_No description provided._".to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+91
-14
@@ -177,11 +177,28 @@ fn ambiguous(search: &str, matches: &[(String, String, String, String)]) -> anyh
|
|||||||
anyhow!(message)
|
anyhow!(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, String, String)> {
|
/// Shortest search tried as a UUID prefix. Below it the search is text, so a one or
|
||||||
let statuses = status_dirs();
|
/// two character term is a title search rather than a prefix matching half the board.
|
||||||
let mut matches: Vec<(String, String, String, String)> = Vec::new();
|
///
|
||||||
|
/// Four, not eight. The guard this replaces read `short_id.len() >= 8`, and `short_id`
|
||||||
|
/// there was always the full 36 character uuid, so it was always true and any length
|
||||||
|
/// already worked. Requiring eight would have broken the id the tool prints itself:
|
||||||
|
/// `ls` shows [`SHORT_ID_WIDTH`] characters, and pasting that back has to resolve.
|
||||||
|
pub const MIN_ID_SEARCH: usize = 4;
|
||||||
|
|
||||||
for status in &statuses {
|
pub fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, String, String)> {
|
||||||
|
let search_lower = search.to_lowercase();
|
||||||
|
let long_enough_for_an_id = search.chars().count() >= MIN_ID_SEARCH;
|
||||||
|
|
||||||
|
// Three tiers, filled in one pass and consulted in order. A uuid prefix has to win
|
||||||
|
// outright rather than join a flat list: ticket titles reference other tickets by
|
||||||
|
// id, so an exact prefix match was reported as ambiguous against whichever title
|
||||||
|
// happened to mention it.
|
||||||
|
let mut by_id: Vec<(String, String, String, String)> = Vec::new();
|
||||||
|
let mut by_title: Vec<(String, String, String, String)> = Vec::new();
|
||||||
|
let mut by_filename: Vec<(String, String, String, String)> = Vec::new();
|
||||||
|
|
||||||
|
for status in status_dirs() {
|
||||||
let status_path = worklane_dir.join(status);
|
let status_path = worklane_dir.join(status);
|
||||||
if !status_path.exists() {
|
if !status_path.exists() {
|
||||||
continue;
|
continue;
|
||||||
@@ -206,23 +223,34 @@ pub fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, Stri
|
|||||||
.file_stem()
|
.file_stem()
|
||||||
.map(|s| s.to_string_lossy().to_string())
|
.map(|s| s.to_string_lossy().to_string())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let short_id = filename.split('_').next().unwrap_or("");
|
let uuid = filename.split('_').next().unwrap_or("");
|
||||||
|
|
||||||
let search_lower = search.to_lowercase();
|
let by_prefix = long_enough_for_an_id && uuid.to_lowercase().starts_with(&search_lower);
|
||||||
let title_lower = title.to_lowercase();
|
let in_title = title.to_lowercase().contains(&search_lower);
|
||||||
let filename_lower = filename.to_lowercase();
|
// Still reaches the middle of a uuid, which the prefix tier cannot.
|
||||||
|
let in_filename = filename.to_lowercase().contains(&search_lower);
|
||||||
|
|
||||||
let id_match =
|
if !(by_prefix || in_title || in_filename) {
|
||||||
short_id.to_lowercase().starts_with(&search_lower) && short_id.len() >= 8;
|
continue;
|
||||||
let title_match = title_lower.contains(&search_lower);
|
}
|
||||||
let filename_match = filename_lower.contains(&search_lower);
|
|
||||||
|
|
||||||
if id_match || title_match || filename_match {
|
let found = (status.to_string(), title, content, uuid.to_string());
|
||||||
matches.push((status.to_string(), title, content, short_id.to_string()));
|
if by_prefix {
|
||||||
|
by_id.push(found);
|
||||||
|
} else if in_title {
|
||||||
|
by_title.push(found);
|
||||||
|
} else {
|
||||||
|
by_filename.push(found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut matches = match (by_id.is_empty(), by_title.is_empty()) {
|
||||||
|
(false, _) => by_id,
|
||||||
|
(true, false) => by_title,
|
||||||
|
(true, true) => by_filename,
|
||||||
|
};
|
||||||
|
|
||||||
if matches.is_empty() {
|
if matches.is_empty() {
|
||||||
return Err(anyhow!("No ticket found matching '{}'", search));
|
return Err(anyhow!("No ticket found matching '{}'", search));
|
||||||
}
|
}
|
||||||
@@ -597,6 +625,27 @@ pub fn format_created_at(created_at: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The slice with blank values trimmed from both ends, interior ones kept.
|
||||||
|
///
|
||||||
|
/// Description values are joined with a single newline, so an empty value is how a
|
||||||
|
/// caller spells a paragraph break. That makes the interior blanks content, while a
|
||||||
|
/// blank at either end would only open or close the section with a gap.
|
||||||
|
pub fn trim_blank_ends(values: &[String]) -> &[String] {
|
||||||
|
let first = values.iter().position(|v| !v.trim().is_empty());
|
||||||
|
|
||||||
|
match first {
|
||||||
|
None => &[],
|
||||||
|
Some(first) => {
|
||||||
|
// Guaranteed to find one, since `first` is itself non-blank.
|
||||||
|
let last = match values.iter().rposition(|v| !v.trim().is_empty()) {
|
||||||
|
Some(last) => last,
|
||||||
|
None => first,
|
||||||
|
};
|
||||||
|
&values[first..=last]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn status_dirs() -> Vec<&'static str> {
|
pub fn status_dirs() -> Vec<&'static str> {
|
||||||
vec!["backlog", "committed", "reviewing", "done"]
|
vec!["backlog", "committed", "reviewing", "done"]
|
||||||
}
|
}
|
||||||
@@ -1087,6 +1136,34 @@ mod tests {
|
|||||||
assert!(rendered.ends_with("after\n"), "{rendered:?}");
|
assert!(rendered.ends_with("after\n"), "{rendered:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn blank_values_are_trimmed_from_the_ends_but_kept_inside() {
|
||||||
|
let owned = |values: &[&str]| -> Vec<String> {
|
||||||
|
values.iter().map(|v| v.to_string()).collect()
|
||||||
|
};
|
||||||
|
|
||||||
|
// A break between paragraphs is content
|
||||||
|
let two_paragraphs = owned(&["First.", "", "Second."]);
|
||||||
|
assert_eq!(trim_blank_ends(&two_paragraphs), two_paragraphs.as_slice());
|
||||||
|
|
||||||
|
// A run of them is kept verbatim rather than collapsed
|
||||||
|
let wide = owned(&["A", "", "", "B"]);
|
||||||
|
assert_eq!(trim_blank_ends(&wide), wide.as_slice());
|
||||||
|
|
||||||
|
// The ends are not
|
||||||
|
assert_eq!(
|
||||||
|
trim_blank_ends(&owned(&["", " ", "Only.", "", ""])),
|
||||||
|
owned(&["Only."]).as_slice()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Nothing but blanks is nothing at all
|
||||||
|
assert!(trim_blank_ends(&owned(&["", " ", ""])).is_empty());
|
||||||
|
assert!(trim_blank_ends(&[]).is_empty());
|
||||||
|
|
||||||
|
// A single value survives either way
|
||||||
|
assert_eq!(trim_blank_ends(&owned(&["One."])), owned(&["One."]).as_slice());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_level_in_range_parses() {
|
fn a_level_in_range_parses() {
|
||||||
for level in 1..=5u8 {
|
for level in 1..=5u8 {
|
||||||
|
|||||||
@@ -380,3 +380,80 @@ fn only_ticket(worklane: &PathBuf) -> String {
|
|||||||
assert_eq!(files.len(), 1, "expected exactly one ticket");
|
assert_eq!(files.len(), 1, "expected exactly one ticket");
|
||||||
fs::read_to_string(files[0].path()).unwrap()
|
fs::read_to_string(files[0].path()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The contract the opencode wrapper relies on: values are joined with a single
|
||||||
|
/// newline, so an empty value is how a paragraph break is spelled. The wrapper used
|
||||||
|
/// to drop those blanks, collapsing every multi paragraph description into one.
|
||||||
|
#[test]
|
||||||
|
fn add_keeps_a_paragraph_break_in_the_description() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.args(["add", "--title", "Two Paras"])
|
||||||
|
.args(["--description", "First paragraph."])
|
||||||
|
.args(["--description", ""])
|
||||||
|
.args(["--description", "Second paragraph."])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let content = only_ticket(&worklane);
|
||||||
|
assert!(
|
||||||
|
content.contains("## Description\nFirst paragraph.\n\nSecond paragraph.\n"),
|
||||||
|
"was {content:?}"
|
||||||
|
);
|
||||||
|
|
||||||
|
// And it survives the round trip back out
|
||||||
|
let mut show = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
show.current_dir(&temp.path()).args(["show", "Two Paras"]);
|
||||||
|
let stdout = String::from_utf8(show.assert().success().get_output().stdout.clone()).unwrap();
|
||||||
|
assert!(
|
||||||
|
stdout.contains("First paragraph.\n\nSecond paragraph."),
|
||||||
|
"was {stdout:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A break belongs between paragraphs, not against the section headings.
|
||||||
|
#[test]
|
||||||
|
fn add_discards_blank_descriptions_at_either_end() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.args(["add", "--title", "Padded"])
|
||||||
|
.args(["--description", ""])
|
||||||
|
.args(["--description", " "])
|
||||||
|
.args(["--description", "The only line."])
|
||||||
|
.args(["--description", ""])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let content = only_ticket(&worklane);
|
||||||
|
assert!(
|
||||||
|
content.contains("## Description\nThe only line.\n\n## Acceptance Criteria"),
|
||||||
|
"was {content:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Nothing but blanks is no description, not an empty section.
|
||||||
|
#[test]
|
||||||
|
fn add_treats_an_all_blank_description_as_none() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.args(["add", "--title", "Blank"])
|
||||||
|
.args(["--description", ""])
|
||||||
|
.args(["--description", " "])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let content = only_ticket(&worklane);
|
||||||
|
assert!(
|
||||||
|
content.contains("## Description\n_No description provided._"),
|
||||||
|
"was {content:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -485,3 +485,193 @@ fn show_renders_the_metadata_as_an_aligned_table() {
|
|||||||
let content = fs::read_to_string(worklane.join("backlog").join(filename)).unwrap();
|
let content = fs::read_to_string(worklane.join("backlog").join(filename)).unwrap();
|
||||||
assert!(content.contains("- **Owner**: alice"));
|
assert!(content.contains("- **Owner**: alice"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Write a ticket with an exact uuid and title, since both matter to resolution.
|
||||||
|
fn ticket_with(worklane: &std::path::Path, status: &str, uuid: &str, title: &str, slug: &str) {
|
||||||
|
fs::write(
|
||||||
|
worklane.join(status).join(format!("{}_{}.md", uuid, slug)),
|
||||||
|
format!(
|
||||||
|
"# {}\n\n## Metadata\n\n- **ID**: {}\n- **Status**: {}\n",
|
||||||
|
title, uuid, status
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show(temp: &TempDir, search: &str) -> std::process::Output {
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path()).arg("show").arg(search);
|
||||||
|
cmd.assert().get_output().clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The bug. A flat OR of the three predicates put an exact uuid prefix and a title
|
||||||
|
/// that merely mentions it in the same list, so the search reported as ambiguous
|
||||||
|
/// the very id the listing had just printed.
|
||||||
|
#[test]
|
||||||
|
fn show_prefers_a_uuid_prefix_over_a_title_that_mentions_it() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||||
|
"Alpha",
|
||||||
|
"alpha",
|
||||||
|
);
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||||
|
"Notes on 641e3d5 regression",
|
||||||
|
"notes",
|
||||||
|
);
|
||||||
|
|
||||||
|
let out = show(&temp, "641e3d5");
|
||||||
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||||
|
|
||||||
|
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||||
|
assert!(stdout.contains("Alpha"), "{stdout:?}");
|
||||||
|
assert!(!stdout.contains("Notes on"), "{stdout:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `ls` prints SHORT_ID_WIDTH characters, so pasting that back has to resolve. This
|
||||||
|
/// is the guard against reinstating an eight character minimum.
|
||||||
|
#[test]
|
||||||
|
fn show_resolves_the_short_id_the_listing_prints() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let uuid = "641e3d5d-ef23-4213-8346-e8b0114b84e9";
|
||||||
|
ticket_with(&worklane, "backlog", uuid, "Alpha", "alpha");
|
||||||
|
|
||||||
|
let mut ls = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
ls.current_dir(&temp.path()).args(["ls", "backlog"]);
|
||||||
|
let listing = String::from_utf8(ls.assert().success().get_output().stdout.clone()).unwrap();
|
||||||
|
|
||||||
|
// Take the id exactly as printed, so this couples to the display width rather
|
||||||
|
// than to a hardcoded number
|
||||||
|
let printed = listing
|
||||||
|
.split('(')
|
||||||
|
.nth(1)
|
||||||
|
.and_then(|rest| rest.split(')').next())
|
||||||
|
.expect("no id in the listing")
|
||||||
|
.to_string();
|
||||||
|
assert!(printed.len() < 8, "the listing prints {} chars", printed.len());
|
||||||
|
|
||||||
|
// A decoy whose title quotes that id. Without it the search would still land on
|
||||||
|
// Alpha through the filename tier, since the filename contains the uuid, and the
|
||||||
|
// test would pass under a minimum longer than the printed id.
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||||
|
&format!("Notes on {} regression", printed),
|
||||||
|
"notes",
|
||||||
|
);
|
||||||
|
|
||||||
|
let out = show(&temp, &printed);
|
||||||
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||||
|
assert!(out.status.success(), "{printed} did not resolve");
|
||||||
|
assert!(stdout.contains("Alpha"), "{stdout:?}");
|
||||||
|
assert!(!stdout.contains("Notes on"), "{stdout:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn show_resolves_a_four_character_uuid_prefix() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||||
|
"Alpha",
|
||||||
|
"alpha",
|
||||||
|
);
|
||||||
|
|
||||||
|
let out = show(&temp, "641e");
|
||||||
|
assert!(out.status.success());
|
||||||
|
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Below four characters the search is text, so it must not be read as a prefix
|
||||||
|
/// matching a large slice of the board.
|
||||||
|
#[test]
|
||||||
|
fn show_treats_a_search_below_four_characters_as_text() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||||
|
"Alpha",
|
||||||
|
"alpha",
|
||||||
|
);
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||||
|
"Notes on 641 regression",
|
||||||
|
"notes",
|
||||||
|
);
|
||||||
|
|
||||||
|
// "641" prefixes Alpha's uuid, but it is too short to be read as one, so the
|
||||||
|
// title match is the only match
|
||||||
|
let out = show(&temp, "641");
|
||||||
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||||
|
|
||||||
|
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||||
|
assert!(stdout.contains("Notes on"), "{stdout:?}");
|
||||||
|
assert!(!stdout.contains("Alpha"), "{stdout:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The last tier earns its place: it reaches the middle of a uuid, which the prefix
|
||||||
|
/// tier cannot.
|
||||||
|
#[test]
|
||||||
|
fn show_falls_back_to_the_filename_for_a_mid_uuid_substring() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||||
|
"Alpha",
|
||||||
|
"alpha",
|
||||||
|
);
|
||||||
|
|
||||||
|
let out = show(&temp, "ef23");
|
||||||
|
assert!(out.status.success());
|
||||||
|
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tiering removes false ambiguity across tiers, not real ambiguity inside one.
|
||||||
|
#[test]
|
||||||
|
fn show_still_reports_ambiguity_within_the_uuid_tier() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"5eeddeed-1111-2222-3333-444444444444",
|
||||||
|
"Beta",
|
||||||
|
"beta",
|
||||||
|
);
|
||||||
|
ticket_with(
|
||||||
|
&worklane,
|
||||||
|
"backlog",
|
||||||
|
"5eedbeef-9999-8888-7777-666666666666",
|
||||||
|
"Gamma",
|
||||||
|
"gamma",
|
||||||
|
);
|
||||||
|
|
||||||
|
let out = show(&temp, "5eed");
|
||||||
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||||
|
|
||||||
|
assert!(!out.status.success());
|
||||||
|
assert!(stderr.contains("Multiple tickets found"), "{stderr:?}");
|
||||||
|
assert!(stderr.contains("Beta") && stderr.contains("Gamma"), "{stderr:?}");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user