Repository navigation
refactor(git): split 2495-line git.rs into focused submodules - #448
Merged
Merged
Conversation
There was a problem hiding this comment.
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.rsinto per-concern submodules undersrc/git/(auth,commits,diff,fetch,push,repo,retry,tags). - Preserve the existing public API via
pub usere-exports inmod.rs; tighten visibility of internal helpers topub(super). - Move all 63 tests into a single
testssubmodule that pulls helpers viasuper::*and module-specificusepaths.
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 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, | ||
| }; |
There was a problem hiding this comment.
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.
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
src/git.rshad 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/:mod.rspub usere-exports — all external call sites unchangedrepo.rsopen_repo,get_repo_root,resolve_current_branchtags.rsTagMatch,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_messagecommits.rsget_commits_since_last_tag/stable_tag,signature,create_commit,create_branch_and_commit(s)diff.rsget_changed_files,get_changed_files_since_tagauth.rsextract_url_password,credentials_callback,authenticated_remote_url,get_authenticated_remote,get_remote_urlfetch.rsmake_fetch_options,fetch_tagspush.rsforce_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,pushretry.rsretry_transient,is_transient_git_error,is_push_rejected_errortests.rsCompatibility
All external imports (
use crate::git::*inchangelog,monorepo,query,status,validate) keep working untouched — verified by cleancargo check --workspace.Verification
cargo test --bin ferrflow→ 598 passed, 0 failedcargo clippy --workspace --all-targets -- -D warnings→ cleancargo fmt --check→ cleanConflict with #446 (
fix/push-tags-shell-out-libgit2-revwalk-bug)The push-tags fix branch and this refactor both touch
git.rsheavily. Whichever lands first wins cheap; the second one needs a manual rebase that re-applies its edits inside the newgit/module structure. Suggested order: merge #446 first (small bug fix, urgent), then I'll rebase this PR on top of the new main.