From a1bdb5df49f1c7bd824b8f86df0f3b373619a587 Mon Sep 17 00:00:00 2001 From: Ansho Rei Date: Mon, 24 Aug 2026 12:28:36 +0200 Subject: [PATCH] (87862df) Attribute an entry to WORKLANE_ACTOR, not to the git user, and bump to 0.28.0 Every comment the CLI wrote was attributed to the git user, so a board several agents write to read as a list of things one human had done. resolve_actor is now the single source: flag, then WORKLANE_ACTOR, then get_git_user(), then unknown. comment --owner is renamed to --actor with no alias, since it names the writer of the entry and not the ticket's assignee, which is chown's. add --owner and campaign add --owner still default to the git user. Co-Authored-By: Claude Opus 5 (1M context) --- AGENTS.md | 11 ++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 10 ++- assets/SKILL.md | 28 ++++++++- assets/TOOL.ts | 6 +- src/command.rs | 10 ++- src/handlers.rs | 7 +-- src/main.rs | 4 +- src/util.rs | 105 +++++++++++++++++++++++++++++++ tests/cmd_comment.rs | 144 +++++++++++++++++++++++++++++++++++++++---- 11 files changed, 299 insertions(+), 30 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 8c41193..c19ccc4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -371,6 +371,17 @@ and this file is for what someone changing worklane's own code needs. - **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw - `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first +### Who Wrote an Entry +- **Identity is supplied, not detected.** Every option that needs no cooperation fails: a harness variable such as `CLAUDECODE` names the tool rather than the instance and breaks across versions, walking the parent process is platform specific and also only names the harness, and a terminal check separates interactive from not, which a human piping output is too. So the actor is `WORKLANE_ACTOR`, set once per session, with `--actor` as the per-call override +- **Precedence: flag, then `WORKLANE_ACTOR`, then `get_git_user()`, then `unknown`.** `resolve_actor` is the only caller of `get_git_user` for an entry's author, and every entry the CLI writes goes through it. The two halves are separate pure functions, `session_actor` and `entry_actor`, tested without touching the process environment for the reason `colors_wanted` is split that way +- **The session half is cached in a `OnceLock`, the way `should_use_colors` is:** neither the variable nor the git user can change mid-run, and the fallback costs a `git config` subprocess. `session_actor` takes the git user as a closure so that subprocess is not run when the variable already answered +- An **empty `WORKLANE_ACTOR` counts as unset**, the convention `colors_wanted` follows for `NO_COLOR`, so a wrapper script can clear an inherited one. Whitespace counts the same, since a shell quoting a missing value writes one +- **The actor is free text, checked against nothing**, like the `chown` user: there is no registry of actors, and the same reason `ls --tag` refuses to validate a tag +- **It was `comment --owner`, renamed with no alias.** Owner is the ticket's assignee and has one writer, `chown`; this names the writer of the entry, which is a different field. Pre-1.0, and two names for one thing is what splitting `set` and `chown` avoided. `the_owner_flag_is_gone` pins the refusal, since an alias kept "for now" is what makes the wrong name permanent +- **`add --owner` and `campaign add --owner` still default to the git user, deliberately.** Those write the assignee, and a ticket an agent files is work for the person whose board it is; attributing it to the agent would put its name in the Owner column of everything it reported +- **An entry does not record whether the call had a terminal.** It is the one agent signal that needs no cooperation, so it was worth considering, and it was rejected: it cannot name an actor, a human piping output produces the same value, and once the actor is explicit the extra field answers no question anybody asks +- **Set it in the agent's configuration, not per call.** `env` in `~/.claude/settings.json` reaches every command Claude Code runs. opencode has no equivalent: its config is JSON with no `env` block for the tools it spawns, so it inherits the environment it was started with, which means a wrapper or a shell function around `opencode`. Both are documented in `assets/SKILL.md` rather than assumed + ### Shipping the Agent Assets - The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it - **`assets/SKILL.md` is the only worklane skill document in this repo, and nothing may reintroduce a second.** There was one: `.opencode/skill/worklane-kanban-skill/SKILL.md`, 223 lines of the same document that nothing shipped and no test checked, and it drifted exactly as far as a copy nobody reads does. Its frontmatter still called the skill `worklane_kanban`, its examples still used short flags the CLI had stopped accepting, and it knew nothing about `relate`, `campaign`, `chown`, `check` or the four-status flow. It was **not** inert while it existed: `opencode debug skill` listed it, so an agent working in this repo saw two worklane skills and could load either. Deleted by b2c5531. A copy under `.opencode/`, in a second assets file, or in the README is the same mistake; the document has one home and `install-skill` is how it travels diff --git a/Cargo.lock b/Cargo.lock index ea97afb..01bb5e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1503,7 +1503,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.27.3" +version = "0.28.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index ef03cad..af72a4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.27.3" +version = "0.28.0" edition = "2024" [dependencies] diff --git a/README.md b/README.md index 9b5447d..31adead 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Worklane is a local Kanban flow for agentic software development. | `worklane chown ` | Sets the Owner field, the only command that writes it. Free text, checked against nothing. User first and ticket second, after Unix `chown`. `worklane chown --clear ` returns the field to unset, taking the ticket in the flag since there is no user to give, and not to the git user `add` falls back to | | `worklane check [criteria...]` | Ticks acceptance criteria, each by number as shown by `show` or by a substring. Several in one call, or `all` for every one of them. Prompts with the numbered list if none is given, or errors with it when there is no terminal | | `worklane uncheck [criteria...]` | Unticks acceptance criteria, addressed the same way | -| `worklane comment ` | Adds a comment to a ticket by UUID or title | +| `worklane comment ` | Adds a comment to a ticket by UUID or title. The author is `--actor`, or `WORKLANE_ACTOR`, or the git user, in that order | | `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 ` | Replaces `--title`, which renames the file keeping the uuid, `--description` and `--codename`. At least one required. The way a campaign filed before codenames existed gets one, and the way a description filed with a typo in it gets fixed. 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. A description needs no `--force`: it is prose written to be revised. No `--clear` and no `--owner` | | `worklane campaign append ` | Adds a paragraph to a campaign's description with `--description`, which is required. The other half of `campaign set --description`, so adding a line to a description does not mean retyping the rest of it. Repeat the flag for more lines within the one paragraph. Its own subcommand rather than the top-level `append`, which resolves a ticket | @@ -29,6 +29,14 @@ Worklane is a local Kanban flow for agentic software development. | `worklane install-skill [skill]` | Writes the embedded agent skills to `~/.claude/skills//SKILL.md`, which Claude Code and opencode both read. Four ship: `worklane` teaches the CLI, `worklane-review` reviews a finished ticket against the code that claims to close it, `worklane-plan` grooms the board as a whole, its priorities, due dates, tags and campaigns, and `worklane-admin` sets a board up and repairs one, its tag vocabulary and the faults a board can develop. Every document unless one is named. Leaves a modified copy alone unless `--force`; `--print` writes one to stdout instead and needs the name | | `worklane install-tool` | Writes the embedded opencode tool definitions to `$XDG_CONFIG_HOME/opencode/tool/worklane.ts`, or `~/.config/opencode/tool/` without it, where opencode loads them for every project. One file and so no name to pass. `--force` and `--print` behave as they do for a skill. opencode only: it registers the eleven `worklane_*` tools from the file name and its exports, and Claude Code has no directory it scans for a tool definition, so reaching it would mean an MCP server rather than this. Restart opencode after installing, since it reads its config at startup and never reloads it. Nothing else to install: the file runs inside opencode's own runtime, so neither Bun nor `@opencode-ai/plugin` has to be on the machine | +## Environment + +| Variable | Effect | +|----------|--------| +| `WORKLANE_ACTOR` | Who every entry the CLI writes is attributed to: today the author of a comment. Set it once, in the environment an agent runs in, and every call it makes is attributed to it instead of to the git user of whoever's machine it is on. `--actor` overrides it per call, an empty value counts as unset, and with neither supplied the author is the git user and then `unknown`. Free text, checked against nothing | +| `NO_COLOR` | Set and non-empty turns colour off, whatever the value, per no-color.org. Colour is also off when output is not a terminal, and when `TERM` is `dumb` or empty | +| `XDG_CONFIG_HOME` | Where `install-tool` looks for opencode's config root, `$XDG_CONFIG_HOME/opencode`, defaulting to `~/.config`. `install-skill` does not follow it: `~/.claude` is not an XDG path | + ## Completions ```sh diff --git a/assets/SKILL.md b/assets/SKILL.md index 10d94e5..1bd1a8f 100644 --- a/assets/SKILL.md +++ b/assets/SKILL.md @@ -270,6 +270,27 @@ existing ticket will have been written from a different angle. - Related but not the same: file it, and record it with `relate --relates-to ` rather than only mentioning the id in prose. +## Who your entries are attributed to + +Every comment carries an author, and by default that is the git user of the machine you +are running on, which is the human whose checkout it is and not you. Set +`WORKLANE_ACTOR` in your own environment and it becomes the author of every entry you +write, so a board several agents write to says which of them said what: + +``` +WORKLANE_ACTOR=claude worklane comment 1b78a24 "The offset was never passed to the widget." +``` + +Set it once where your session's environment is configured, not on each call: `env` in +`~/.claude/settings.json` for Claude Code, and the environment opencode is started with +for opencode, since it passes its own environment to the tools it runs. `--actor` on +`comment` overrides it for one call, an empty value counts as unset and falls back to the +git user, and with nothing at all the author is `unknown`. It is free text, checked +against nothing: name yourself something a person reading the board will recognise. + +If the variable is not set and you cannot set it, pass `--actor` rather than letting the +comment claim to be the user's. + ## Shell completions ``` @@ -300,8 +321,8 @@ the candidates and exits 1 rather than guessing. `--print is supported` is stored, not parsed as a flag. The cost is that a genuinely mistyped flag there lands as content instead of failing, so read back what you wrote with `worklane show`. -- `--due`, `--priority`, `--tags`, `--owner` and `--status` do *not* accept one, so a - mistyped flag on those is a usage error and nothing is written. +- `--due`, `--priority`, `--tags`, `--owner`, `--actor` and `--status` do *not* accept one, + so a mistyped flag on those is a usage error and nothing is written. - A ticket argument that starts with a hyphen needs the flags first and a separator: `worklane mv --status committed -- -leading-title`. - A comment body of exactly `--` needs its own separator: @@ -309,4 +330,7 @@ the candidates and exits 1 rather than guessing. - An empty value for a scalar is a usage error, not a way to clear the field: use `--clear`. For a section an empty value is a paragraph break, so it cannot mean empty the section either, and an all-blank one is refused with the `--clear` for it named. +- **`comment` has no `--owner`.** Owner is the ticket's assignee, which `chown` writes; + the author of a comment is `--actor` or `WORKLANE_ACTOR`. The old spelling is a usage + error, not an alias. - Piping is safe: `worklane ls | head -3` exits on the closed pipe instead of panicking. diff --git a/assets/TOOL.ts b/assets/TOOL.ts index 75f15fb..89a855a 100644 --- a/assets/TOOL.ts +++ b/assets/TOOL.ts @@ -247,9 +247,9 @@ export const comment = tool({ body: tool.schema .string() .describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."), - owner: tool.schema + actor: tool.schema .string() - .describe("Comment author. If omitted, defaults to the git user.") + .describe("Who the comment is attributed to. If omitted, WORKLANE_ACTOR is used, then the git user, then \"unknown\". Set WORKLANE_ACTOR in the environment opencode is started with rather than passing this on every call.") .optional(), }, async execute(args: Record, context: ToolContext) { @@ -261,7 +261,7 @@ export const comment = tool({ } const cmd: string[] = ["comment", args.ticket, args.body]; - if (args.owner) cmd.push("--owner", args.owner); + if (args.actor) cmd.push("--actor", args.actor); try { return await run(cmd, context); diff --git a/src/command.rs b/src/command.rs index 16deda0..733a7ef 100644 --- a/src/command.rs +++ b/src/command.rs @@ -267,9 +267,13 @@ pub enum Command { #[arg(allow_hyphen_values = PROSE)] body: String, - /// Owner - #[arg(short, long)] - owner: Option, + /// Who the comment is attributed to, overriding `WORKLANE_ACTOR` and the git + /// user. Free text, checked against nothing + /// + /// Named after the writer of the entry, not after the ticket's assignee, which + /// is `chown`'s. It was `--owner`, which said the wrong one of the two. + #[arg(long)] + actor: Option, }, /// Group tickets that have to be finished together diff --git a/src/handlers.rs b/src/handlers.rs index 1657f53..799cf9f 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -725,7 +725,7 @@ pub fn cmd_mv(ticket_id: &str, target: Status, force: bool, start: &Path) -> Res pub fn cmd_comment( ticket_id: &str, body: &str, - owner: &Option, + actor: &Option, start: &Path, ) -> Result<()> { if body.is_empty() { @@ -745,10 +745,7 @@ pub fn cmd_comment( let stem = Local::now().format(COMMENT_FILE_FORMAT).to_string(); - let author = match owner { - Some(o) => o.clone(), - None => get_git_user().unwrap_or_else(|| "unknown".to_string()), - }; + let author = resolve_actor(actor.as_deref()); let comment_content = format!( "**Comment**\n\ diff --git a/src/main.rs b/src/main.rs index 598583b..bbd0e34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,8 +63,8 @@ fn main() -> Result<()> { Some(Command::Chown(args)) => cmd_chown(&args, &start), Some(Command::Check(args)) => cmd_check(&args, true, &start), Some(Command::Uncheck(args)) => cmd_check(&args, false, &start), - Some(Command::Comment { ticket, body, owner }) => { - cmd_comment(&ticket, &body, &owner, &start) + Some(Command::Comment { ticket, body, actor }) => { + cmd_comment(&ticket, &body, &actor, &start) } Some(Command::Campaign { command }) => match command { CampaignCommand::Add(args) => cmd_campaign_add(&args, &start), diff --git a/src/util.rs b/src/util.rs index 323361f..c11c9f5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -416,6 +416,63 @@ pub fn get_git_user() -> Option { } }) } + +/// The variable that names the writer of an entry, set once per session. +/// +/// A per-call flag can be forgotten on the fortieth call; a variable set by an agent's +/// own configuration is inherited by every call it makes. +pub const ACTOR_ENV: &str = "WORKLANE_ACTOR"; + +/// The author written when nothing names one. +pub const UNKNOWN_ACTOR: &str = "unknown"; + +/// The actor for the whole run: the variable, then the git user. +/// +/// Split out from the caching wrapper for the reason `colors_wanted` is: a threaded test +/// binary cannot mutate the process environment to reach one branch at a time. +/// +/// An empty `WORKLANE_ACTOR` counts as unset, the convention `colors_wanted` follows for +/// `NO_COLOR`, so a wrapper script can clear an inherited one. `git_user` is a closure +/// rather than a value because the fallback costs a subprocess and the variable usually +/// answers first. +fn session_actor(env: Option<&str>, git_user: impl FnOnce() -> Option) -> Option { + match env.map(str::trim).filter(|value| !value.is_empty()) { + Some(value) => Some(value.to_string()), + None => git_user(), + } +} + +/// The actor for one entry: the flag wins, otherwise the session's, otherwise unknown. +/// +/// Free text, validated against nothing, the way the `chown` user is: there is no +/// registry of actors to check a name against. +fn entry_actor(flag: Option<&str>, session: Option<&str>) -> String { + [flag, session] + .into_iter() + .flatten() + .map(str::trim) + .find(|value| !value.is_empty()) + .unwrap_or(UNKNOWN_ACTOR) + .to_string() +} + +/// Who to attribute an entry to, from the flag the call carried. +/// +/// Precedence: flag, then `WORKLANE_ACTOR`, then the git user, then `unknown`. Every +/// entry the CLI writes goes through here, so a board several agents write to says which +/// of them wrote what instead of attributing all of it to one human. +pub fn resolve_actor(flag: Option<&str>) -> String { + // The session half is decided once, the way should_use_colors is: neither input can + // change mid-run, and the git user costs a subprocess. + static SESSION: OnceLock> = OnceLock::new(); + + let session = SESSION.get_or_init(|| { + let env = std::env::var(ACTOR_ENV).ok(); + session_actor(env.as_deref(), get_git_user) + }); + + entry_actor(flag, session.as_deref()) +} /// One file a search matched, and where it was found. pub struct Found { /// The name the match is reported under: the status directory for a ticket, and @@ -3377,6 +3434,54 @@ mod tests { assert!(colors_wanted(true, None, None)); } + /// The variable answers when no flag does, and the git user is never asked: the + /// closure returns a name that must not appear. + #[test] + fn the_variable_names_the_actor() { + let session = session_actor(Some("claude"), || Some("Ansho Rei".to_string())); + assert_eq!(entry_actor(None, session.as_deref()), "claude"); + } + + #[test] + fn the_flag_overrides_the_variable() { + let session = session_actor(Some("claude"), || None); + assert_eq!(entry_actor(Some("opencode"), session.as_deref()), "opencode"); + } + + /// With neither supplied the author is still the git user. + #[test] + fn the_git_user_is_the_fallback() { + let session = session_actor(None, || Some("Ansho Rei".to_string())); + assert_eq!(entry_actor(None, session.as_deref()), "Ansho Rei"); + } + + /// An empty variable counts as unset, the way `NO_COLOR` does, so a wrapper script + /// can clear an inherited one and get the git user back. + #[test] + fn an_empty_variable_reads_as_unset() { + let session = session_actor(Some(""), || Some("Ansho Rei".to_string())); + assert_eq!(entry_actor(None, session.as_deref()), "Ansho Rei"); + // Whitespace is the same case: a shell that quotes a missing value writes one + let session = session_actor(Some(" "), || Some("Ansho Rei".to_string())); + assert_eq!(entry_actor(None, session.as_deref()), "Ansho Rei"); + } + + /// And with nothing at all, including a git that has no user configured. + #[test] + fn nothing_at_all_is_unknown() { + let session = session_actor(None, || None); + assert_eq!(entry_actor(None, session.as_deref()), UNKNOWN_ACTOR); + // An empty flag falls through rather than writing a blank author + assert_eq!(entry_actor(Some(""), None), UNKNOWN_ACTOR); + } + + /// Free text, validated against nothing, the way the `chown` user is. + #[test] + fn an_actor_is_free_text() { + let session = session_actor(Some("claude-code, session 3 (opus)"), || None); + assert_eq!(entry_actor(None, session.as_deref()), "claude-code, session 3 (opus)"); + } + #[test] fn unset_values_are_dimmed_and_set_ones_are_not() { // Both paths, now that the colour decision is a parameter: with colour off the diff --git a/tests/cmd_comment.rs b/tests/cmd_comment.rs index 266979e..2685a84 100644 --- a/tests/cmd_comment.rs +++ b/tests/cmd_comment.rs @@ -41,6 +41,24 @@ fn create_ticket(worklane_dir: &Path, status: &str, title: &str) -> String { uuid } +/// The one comment on a ticket, which every author test writes exactly one of. +fn only_comment(worklane_dir: &Path, uuid: &str) -> String { + let files: Vec<_> = fs::read_dir(worklane_dir.join("comments").join(uuid)) + .unwrap() + .filter_map(|e| e.ok()) + .collect(); + assert_eq!(files.len(), 1, "expected one comment"); + fs::read_to_string(files[0].path()).unwrap() +} + +/// A git config file holding nothing but a `user.name`, for the tests that need the +/// fallback to answer something known instead of whatever the machine is configured with. +fn git_config_naming(temp: &TempDir, name: &str) -> PathBuf { + let path = temp.path().join("gitconfig"); + fs::write(&path, format!("[user]\n\tname = {}\n", name)).unwrap(); + path +} + #[test] fn comment_creates_file_with_valid_ticket_uuid() { let temp = TempDir::new().unwrap(); @@ -162,32 +180,134 @@ fn comment_creates_comments_directory() { } #[test] -fn comment_uses_owner_flag_when_provided() { +fn comment_uses_actor_flag_when_provided() { let temp = TempDir::new().unwrap(); let worklane = setup_worklane(&temp); - let uuid = create_ticket(&worklane, "backlog", "Owner Test"); + let uuid = create_ticket(&worklane, "backlog", "Actor Test"); let mut cmd = Command::cargo_bin(BIN_NAME).unwrap(); cmd.current_dir(temp.path()) .arg("comment") - .args([&uuid, "Test comment with owner"]) - .arg("-o") - .arg("TestUser") + .args([&uuid, "Test comment with actor"]) + .args(["--actor", "TestUser"]) .assert() .success(); - let comments_dir = worklane.join("comments").join(&uuid); - let files: Vec<_> = fs::read_dir(&comments_dir) + assert!(only_comment(&worklane, &uuid).contains("**Author**: TestUser")); +} + +/// The flag it was, which named the ticket's assignee and not the writer of the entry. +/// Renamed without an alias, so the old spelling is a usage error rather than something +/// that half works. +#[test] +fn the_owner_flag_is_gone() { + let temp = TempDir::new().unwrap(); + let worklane = setup_worklane(&temp); + let uuid = create_ticket(&worklane, "backlog", "Gone Test"); + + for flag in ["--owner", "-o"] { + Command::cargo_bin(BIN_NAME) + .unwrap() + .current_dir(temp.path()) + .arg("comment") + .args([&uuid, "A body"]) + .args([flag, "TestUser"]) + .assert() + .failure(); + } + + assert!( + !worklane.join("comments").join(&uuid).exists(), + "a comment was written despite the usage error" + ); +} + +/// The variable is the case an agent runs in: set once by its configuration and +/// inherited by every call, where a flag can be forgotten on the fortieth one. +#[test] +fn comment_takes_the_author_from_the_actor_variable() { + let temp = TempDir::new().unwrap(); + let worklane = setup_worklane(&temp); + let uuid = create_ticket(&worklane, "backlog", "Variable Test"); + + Command::cargo_bin(BIN_NAME) .unwrap() - .filter_map(|e| e.ok()) - .collect(); - let content = fs::read_to_string(files[0].path()).unwrap(); - assert!(content.contains("**Author**: TestUser")); + .current_dir(temp.path()) + .env("WORKLANE_ACTOR", "claude") + .arg("comment") + .args([&uuid, "Written by an agent"]) + .assert() + .success(); + + assert!(only_comment(&worklane, &uuid).contains("**Author**: claude")); } #[test] -fn comment_falls_back_to_git_user_when_owner_omitted() { +fn the_actor_flag_overrides_the_variable() { + let temp = TempDir::new().unwrap(); + let worklane = setup_worklane(&temp); + let uuid = create_ticket(&worklane, "backlog", "Override Test"); + + Command::cargo_bin(BIN_NAME) + .unwrap() + .current_dir(temp.path()) + .env("WORKLANE_ACTOR", "claude") + .arg("comment") + .args([&uuid, "Written by the other one"]) + .args(["--actor", "opencode"]) + .assert() + .success(); + + assert!(only_comment(&worklane, &uuid).contains("**Author**: opencode")); +} + +/// An empty variable counts as unset, the convention `NO_COLOR` follows, so a wrapper +/// script can clear an inherited one and get the git user back. +#[test] +fn an_empty_actor_variable_falls_through_to_the_git_user() { + let temp = TempDir::new().unwrap(); + let worklane = setup_worklane(&temp); + let uuid = create_ticket(&worklane, "backlog", "Empty Variable Test"); + + Command::cargo_bin(BIN_NAME) + .unwrap() + .current_dir(temp.path()) + .env("WORKLANE_ACTOR", "") + .env("GIT_CONFIG_GLOBAL", git_config_naming(&temp, "Configured User")) + .env("GIT_CONFIG_NOSYSTEM", "1") + .arg("comment") + .args([&uuid, "Written by a person"]) + .assert() + .success(); + + assert!(only_comment(&worklane, &uuid).contains("**Author**: Configured User")); +} + +/// The last resort. Reached with a git that has no `user.name`, which is why the config +/// files are redirected: the machine running the suite has one. +#[test] +fn the_author_is_unknown_when_nothing_names_one() { + let temp = TempDir::new().unwrap(); + let worklane = setup_worklane(&temp); + let uuid = create_ticket(&worklane, "backlog", "Unknown Test"); + + Command::cargo_bin(BIN_NAME) + .unwrap() + .current_dir(temp.path()) + .env_remove("WORKLANE_ACTOR") + .env("GIT_CONFIG_GLOBAL", temp.path().join("no-such-gitconfig")) + .env("GIT_CONFIG_NOSYSTEM", "1") + .arg("comment") + .args([&uuid, "Written by nobody in particular"]) + .assert() + .success(); + + assert!(only_comment(&worklane, &uuid).contains("**Author**: unknown")); +} + +#[test] +fn comment_falls_back_to_git_user_when_actor_omitted() { let temp = TempDir::new().unwrap(); let worklane = setup_worklane(&temp);