Skip to content

refactor(git): split 2495-line git.rs into focused submodules - #448

Merged
BryanFRD merged 1 commit into
mainfrom
refactor/git-split-into-modules
May 18, 2026
Merged

BryanFRD merged 1 commit into
mainfrom
refactor/git-split-into-modules

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Why

src/git.rs had grown to 2495 lines (1308 production + 1185 tests). One file held: low-level repo/branch helpers, all tag operations (find/create/move/list/floating/prerelease), commit walking, diff helpers, credentials + remote URL rewriting, fetch logic, the substantial push subsystem (libgit2 + shell-out workaround + rebase + retry + verification), and 63 tests.

What

Split into src/git/:

File LOC Contents
mod.rs 30 pub use re-exports — all external call sites unchanged
repo.rs 47 open_repo, get_repo_root, resolve_current_branch
tags.rs 357 TagMatch, find_matching_commit, is_floating_tag, is_prerelease_tag, find_last_tag/name/commit, find_highest_semver_tag, find_last_stable_tag, collect_all_tags, tag_exists, create_tag, create_or_move_tag, get_tag_message
commits.rs 135 get_commits_since_last_tag/stable_tag, signature, create_commit, create_branch_and_commit(s)
diff.rs 78 get_changed_files, get_changed_files_since_tag
auth.rs 97 extract_url_password, credentials_callback, authenticated_remote_url, get_authenticated_remote, get_remote_url
fetch.rs 19 make_fetch_options, fetch_tags
push.rs 358 force_push_tags, make_push_options, check_push_errors, verify_remote_branch, resolve_push_source, push_branch, push_tags, shell_push_tags, try_push_branch(_once), fetch_and_rebase, reset_branch_to_remote, push
retry.rs 118 retry_transient, is_transient_git_error, is_push_rejected_error
tests.rs 1183 All 63 tests, unchanged

Compatibility

All external imports (use crate::git::* in changelog, monorepo, query, status, validate) keep working untouched — verified by clean cargo check --workspace.

Verification

  • cargo test --bin ferrflow → 598 passed, 0 failed
  • cargo clippy --workspace --all-targets -- -D warnings → clean
  • cargo fmt --check → clean

Conflict with #446 (fix/push-tags-shell-out-libgit2-revwalk-bug)

The push-tags fix branch and this refactor both touch git.rs heavily. Whichever lands first wins cheap; the second one needs a manual rebase that re-applies its edits inside the new git/ module structure. Suggested order: merge #446 first (small bug fix, urgent), then I'll rebase this PR on top of the new main.

Copilot AI review requested due to automatic review settings May 18, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Pure code-organization refactor: the 2 495-line src/git.rs is split into a src/git/ module with eight focused submodules (repo, tags, commits, diff, auth, fetch, push, retry) plus a shared tests submodule. mod.rs re-exports the previous public surface so external call sites in changelog, monorepo, query, status, and validate keep compiling unchanged. No behavior, signatures, or test bodies were modified — the 63 existing tests were moved verbatim into src/git/tests.rs.

Changes:

  • Split src/git.rs into per-concern submodules under src/git/ (auth, commits, diff, fetch, push, repo, retry, tags).
  • Preserve the existing public API via pub use re-exports in mod.rs; tighten visibility of internal helpers to pub(super).
  • Move all 63 tests into a single tests submodule that pulls helpers via super::* and module-specific use paths.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/git.rs Deleted; content distributed across the new src/git/ submodules.
src/git/mod.rs New module root, declares submodules and re-exports the previous public API.
src/git/repo.rs open_repo, get_repo_root, resolve_current_branch extracted.
src/git/tags.rs All tag query/create/move helpers, TagMatch, floating/prerelease classifiers.
src/git/commits.rs Commit walking, signature, single/multi-commit creators; re-exports GitLog.
src/git/diff.rs get_changed_files and get_changed_files_since_tag.
src/git/auth.rs URL credential parsing, libgit2 credentials callback, authenticated remote helpers.
src/git/fetch.rs make_fetch_options and fetch_tags.
src/git/push.rs Full push subsystem: shell-out tag push, branch push w/ retry, rebase, reset, verify.
src/git/retry.rs Generic transient retry loop, is_transient_git_error, is_push_rejected_error.
src/git/tests.rs All 63 tests moved verbatim; imports adjusted for the new module paths.

Comment thread src/git/mod.rs
Comment on lines +11 to +21
#[allow(unused_imports)]
pub use commits::{
GitLog, create_branch_and_commit, create_branch_and_commits, create_commit,
get_commits_since_last_stable_tag, get_commits_since_last_tag,
};
pub use diff::{get_changed_files, get_changed_files_since_tag};
pub use fetch::fetch_tags;
#[allow(unused_imports)]
pub use push::{
force_push_tags, push, push_branch, push_tags, reset_branch_to_remote, verify_remote_branch,
};

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Details
Benchmark suite Current: 9f692fb Previous: 0b5fe57 Ratio
version_files/toml_read 9484 ns/iter (± 126) 8489 ns/iter (± 791) 1.12
version_files/toml_write 127933 ns/iter (± 10741) 132036 ns/iter (± 10286) 0.97
version_files/json_read 6352 ns/iter (± 62) 5314 ns/iter (± 69) 1.20
version_files/json_write 97870 ns/iter (± 10319) 130851 ns/iter (± 8755) 0.75
version_files/xml_read 5862 ns/iter (± 47) 5140 ns/iter (± 16) 1.14
version_files/xml_write 100463 ns/iter (± 17010) 138826 ns/iter (± 18123) 0.72
version_files/gradle_read 5773 ns/iter (± 48) 4981 ns/iter (± 37) 1.16
version_files/gradle_write 97806 ns/iter (± 7688) 128857 ns/iter (± 12186) 0.76

This comment was automatically generated by workflow using github-action-benchmark.

@BryanFRD
BryanFRD merged commit 2ce2f18 into main May 18, 2026
37 checks passed
@BryanFRD
BryanFRD deleted the refactor/git-split-into-modules branch May 18, 2026 17:52
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.

2 participants