Skip to content

User config, with merge.always and --no-merge - #116

Merged
JacobStephens2 merged 3 commits into
mainfrom
issue-111
Sep 29, 2026
Merged

JacobStephens2 merged 3 commits into
mainfrom
issue-111

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

A Run now reads the User config, ~/.thirdshift/config.toml. merge.always = true makes every Run a Merge run, and no-merge / --no-merge turns that off for one Run. Argument parsing moved out of main into src/args.rs, so later flags drop in cleanly.

 main
-  match first arg: help | version | update | merge | <Issue URL>
-  anything after the Issue URL → exit 2
+  args::parse                      # help | version | update return here
+    Run flags before or after the Issue URL
+    repeated flag, or merge + no-merge → exit 2
+  UserConfig::load                 # only a Run reads it
+    unparsable / unknown key or section → exit 1, naming file + key
+  goal = flag given ?? config.default_goal()
   run::run(issue, goal)
src/
├── args.rs     # new: Command + RunArgs { issue, goal: Option<Goal> }
├── config.rs   # new: UserConfig { merge_always }, strict TOML (toml crate)
└── main.rs     # dispatches on Command

The help text and README document --no-merge, the config location and merge.always.

Evidence

  • Before: thirdshift <url> --merge → exit 2, "unexpected argument after the Issue URL". There was no User config.
    After: tests/user_config.rs (new, 10 end-to-end tests through the compiled binary, with a Scenario::user_config_is helper) passes:

    • merge.always = true with no flag → PR merged
    • no-merge / --no-merge, before or after the URL, with merge.always → ready for review, no gh pr merge
    • no file, an empty file, [merge] alone, always = false → not a Merge run
    • [merge / alway / [merges] / colour → exit 1 before any work, naming the file and key
    • help and version with a broken config → exit 0. update is covered in tests/update.rs.
    $ thirdshift https://github.com/acme/widgets/issues/7     # config has alway = true
    thirdshift: unknown key merge.alway in the User config /home/me/.thirdshift/config.toml
    exit 1
    $ thirdshift merge https://github.com/acme/widgets/issues/7 no-merge
    thirdshift: merge and no-merge can't be used together
    exit 2
    

    All cargo test suites pass, and cargo clippy --all-targets is clean.

Merge Danger

Door: two-way

Revert the commits. No one has a config file until they write one, and the new flag positions only accept more.

Blast Radius: CLI

Every Run now reads ~/.thirdshift/config.toml. A stray or typo'd file there stops Runs, which is on purpose. <url> merge used to exit 2 and now starts a Merge run. A missing HOME means no config, not an error.

Unaddressed findings

Standards

  • Duplicated error block in main.rs (config load vs. interrupt install): this follows the existing pattern in main, and a helper for two three-line blocks adds little.
  • Help shows bare merge but dashed --no-merge: the issue asks help to list --no-merge, and an existing test forbids help from listing the --merge alias. Both spellings are accepted and the README gives both.
  • AGENT_OPENS_PR / PR_URL copied into tests/user_config.rs: each test file already keeps its own copy. Moving them into tests/support is a separate cleanup.
  • Unit tests call the private UserConfig::parse as well as the end-to-end tests: it's a cheap internal seam for error wording, and the end-to-end tests stay the contract.
  • merge_always: bool could store a Goal: the bool mirrors the config key. Later sections ([email], [logs]) will sit alongside it the same way.

Spec

  • Wrong-type values (merge = true, always = "yes") are errors too: not asked for, but a value thirdshift silently ignored would defeat the "unknown key stops the Run" rule.
  • A config error exits 1; an unreadable file is an error; an unset HOME means no config: the spec doesn't say. These match how the other pre-flight failures behave.
  • A bad token before the URL says "not a GitHub issue URL" rather than "unexpected argument": it still exits 2 with the help text, as the spec requires. The first non-flag is treated as the URL, which keeps the existing error.

Closes #111

🤖 Generated with Claude Code

JacobStephens2 and others added 3 commits September 29, 2026 18:52
…r after the Issue URL

thirdshift reads ~/.thirdshift/config.toml at the start of a Run.
merge.always = true makes every Run a Merge run; no-merge/--no-merge
overrides it for one Run. An unparsable config or an unknown key or
section stops the Run before any work, naming the file and the key.
update, version and help never read it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JacobStephens2
JacobStephens2 merged commit cc7932e into main Sep 29, 2026
13 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-111 branch September 29, 2026 19:22
@JacobStephens2 JacobStephens2 mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User config, with merge.always and --no-merge

1 participant