Skip to content

refactor: remove duplication found in code review - #118

Open
tylerbutler wants to merge 10 commits into
mainfrom
refactor/review-cleanup
Open

refactor: remove duplication found in code review#118
tylerbutler wants to merge 10 commits into
mainfrom
refactor/review-cleanup

Conversation

@tylerbutler

@tylerbutler tylerbutler commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Whole-repo cleanup from a review for duplicate code, simplifiable structures, and idiom. No behavior changes intended; CLI output, JSON, and error text are unchanged except where noted below.

  • git: one git_output helper behind every git spawn; duplicate git_stdout in release.rs deleted; repo_root/slash_path reused; remote_tag_oid collapses onto remote_tag_oids.
  • doctor: Fix is a struct with a kind instead of three identical variants.
  • lockfile: one walker for both manifest shapes, shared set_str_keep_decor, patch_member shared by doctor and version apply.
  • workspace: fixes invalid exclusion globs being reported twice; root manifest parsed once via ConfigFile::from_document; compile_overrides, Diagnostics::config_error, Member::rel_file/has_series_tag, Workspace::series_tags_of.
  • tests: all helpers in tests/common/mod.rs; files renamed by subject (changelog_version.rs, tag_publish.rs, release_pr.rs); member_discovery.rs merged into configless.rs; 7 --json shape tests already pinned by snapshots removed, 2 invalid-fragment tests merged.
  • run/exec/runner/github/pin: shared parallelism rule and run_and_report tail; job index no longer smuggled through JobResult; GitHub URL and status-check helpers; pin arms hoisted; with_retry simplified.
  • release/tag/version/changelog: dispatch matches once; bootstrap deleted; git_with_identity; PlanEntry holds semver::Version and member index; heading_version and release_notes shared; Strictness::key; minijinja render_str.
  • style: one-time clippy pedantic sweep (not enabled in CI).

Deferred items are marked with ponytail: comments.

Behavior notes

  • lockfile refresh unknown-package error now lists members (goes through workspace.select like other commands).
  • Bump.current/next in the JSON document are owned strings now; wire output identical.

Route every git invocation through git_output; delete the private
git_stdout copy in release.rs; collapse tag.rs rev_parse/remote_tag_oid
onto local_tag_oid/remote_tag_oids.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
The three variants carried identical fields; four accessor matches
existed only to re-extract them. Also drop the clone into in_package
and collapse check_member_glob to one push.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
…mber

patch_locked_versions inlined the two-shape walk twice; both patchers
now share patch_packages. set_str_keep_decor replaces five copies of
the replace-but-keep-decor block. doctor and version apply share
patch_member.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
Invalid exclusion globs were reported twice (once by the exclude sweep,
again for @Release and @members). ConfigFile::from_document takes the
already-parsed root manifest. compile_overrides and Diagnostics
config_error/config_warning replace repeated blocks; Member::rel_file,
has_series_tag and Workspace::series_tags_of replace four copies of the
series-tag iteration.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
Move fixture, trellis, git, json_output and the other duplicated helpers
into tests/common/mod.rs; every test file now imports them. Inline
git init/add/commit triples use init_repo and JSON-parsing blocks use
json_output. 413 tests, snapshots unchanged.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
phase2 -> changelog_version, phase3 -> tag_publish, new_and_release ->
release_pr; member_discovery merged into configless; doctor and publish
tests moved next to their peers; the two invalid-fragment tests merged
into one; seven cli.rs --json tests removed because the json_contract
snapshots already pin every assertion. Tests: 413 before, 405 after.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
- runner: RunOptions::parallelism and run_and_report shared by run/exec;
  channel carries (job_idx, JobOutcome); run_jobs takes &[Job]; one
  paint_status; name width computed once
- github: url() and expect_status() helpers, Write enum for POST/PATCH,
  read_response returns the tuple, iterator-based token lookup
- pin: one status line and insert per rewrite arm; entry API in resolve
- lockfile: use Workspace::select for the single-package case
- tools: with_retry loops 1..attempts then makes the final call directly
- info: or_none helper; generate: write completions to a locked stdout

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
…on, changelog

- main: fold doctor into the first dispatch match; call tag::create for bootstrap
- git: add git_with_identity for commit/tag calls that need the CI identity
- tag: claim closure in plan_tags, Copy CreateOptions with push normalized
  once, release_notes returns Option and is shared with the PR body
- changelog: heading_version shared with tag, one minijinja Environment per
  section, callers pass &Member instead of re-resolving member_index
- version: PlanEntry holds semver::Version and its member index
- changelog check: one EntryState enum drives text and preview output;
  Strictness::key replaces the hand-rolled match

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
Redundant closures, map_or, raw-string hashes, merged identical match
arms, literal separators, and an unused self argument. One-time sweep;
pedantic is not added to CI.

Claude-Session: https://claude.ai/code/session_015R9SdGkqtNm1mTzyCR9kZZ
@netlify

netlify Bot commented Sep 2, 2026

Copy link
Copy Markdown

Deploy Preview for trellis-gleam canceled.

Name Link
🔨 Latest commit 1e10413
🔍 Latest deploy log https://app.netlify.com/projects/trellis-gleam/deploys/6a98354e8756750009fbe582

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.

1 participant