Split git backend into modules and add history filters and issue branch UI #65

Closed
Christoph wants to merge 0 commits from opt into main
Owner

This change refactors the monolithic git backend and adds history search/filter features plus an Issue Center branch creation flow.

Summary

  • The large src-tauri/src/git.rs file has been split into many submodules (examples: ai, bisect, branches, commit, compare, conflicts, credentials, history, history_search, lfs, merge, notes, process, rebase, remotes, repository, staging, stash, status, sync, tags, types, worktrees) and those modules are re-exported with pub use at the top of git.rs. This centralizes and modularizes Git functionality while keeping many symbols available via the git facade.

  • Several previously inline types and helpers were removed from the large file body (they appear to have been relocated into the new modules). The diff shows many structs/enums and helper functions were taken out of the monolithic file and replaced by smaller, focused helpers in the refactored layout.

  • New repository and filesystem helper functions were added to the backend surface:

    • resolve_repo and git_dir_for_repo to resolve repository paths using git.
    • resolve_repo_child_path to validate and canonicalize file paths that must stay inside the repo (rejects absolute paths and ..).
    • normalize_git_path and parse_nul_paths for path normalization and NUL-separated output parsing.
    • git_path_exists, rebase_in_progress, cherry_pick_in_progress, merge_in_progress to detect Git internal state.
    • Cross-platform helpers to open/reveal paths in the OS file manager (open_path_in_file_manager and reveal_path_in_file_manager) with platform-specific implementations for Windows, macOS and other Unix.
    • file_status_index to build a lookup from GitFileStatus slices.
  • Some previously present search cancellation and sequence-editor/commit-editor helpers (e.g. SearchCancellationState, SearchCancellation, run_sequence_editor_if_requested, apply_reword_message) are removed from this file in the diff; they were likely moved into appropriate modules as part of the split.

  • CHANGELOG.md updated to document user-visible additions that match the code changes:

    • Commit history can be filtered by author, message, path/file and date range, combined with logical AND and applied by Git.
    • Global search exposes new history modes (git log -S, -G and file add/delete/rename), accepts the same filters and shows diffs for results including deleted files.
    • Issues can start a branch from the Issue Center detail panel; branch names are suggested from the issue number and title (example 12-login-fails), and while that branch is checked out the commit panel offers to append Fixes #12 to commit messages.

Testing

No test execution results were provided.

Recommended reviewer checks

  1. Build: run cargo build (and cargo test if applicable) to validate the refactor did not break public API usage across the codebase.
  2. Smoke UI flows:
    • Open a repository and exercise the Commits/History panel; try the Filter button and the new history search modes (where applicable).
    • From the Issue Center, use the Create branch action and confirm a branch is created with a suggested name and that the commit panel suggests appending Fixes #<issue> while that branch is checked out.
    • Try "Open in file manager" / "Reveal in file manager" for files and repository folders on each supported platform.
  3. Path/security: test resolve_repo_child_path behavior with absolute paths and .. references to ensure they are rejected.
  4. Backwards-compat: search for any direct imports of symbols that were previously defined directly in git.rs (if some types were not re-exported, update imports accordingly).

Compatibility / migration notes

  • The file-splitting appears to retain a façade via pub use re-exports to minimize import breakage, but reviewers should still verify any code that relied on private/internal locations or on types that might not have been re-exported.

  • The search-cancellation and sequence/commit editor helpers that were present in the old git.rs are no longer in this file; if other code referenced them by path, update imports to the new module locations (they were likely moved as part of the split).

Risks

  • Large refactors like this mainly risk missing re-exports or failing to update all call sites. The build and the smoke tests above are the primary mitigations.

Notes

  • The CHANGELOG entries included in this diff document the new history features and the Issue Center branch creation UI; those entries align with the code-level additions observed in the diff.

If you want, I can run through or suggest exact grep commands to find remaining call sites that might need import fixes (for example searching for previously-file-scoped type names) or prepare a short checklist of symbols to verify.

This change refactors the monolithic git backend and adds history search/filter features plus an Issue Center branch creation flow. Summary - The large `src-tauri/src/git.rs` file has been split into many submodules (examples: `ai`, `bisect`, `branches`, `commit`, `compare`, `conflicts`, `credentials`, `history`, `history_search`, `lfs`, `merge`, `notes`, `process`, `rebase`, `remotes`, `repository`, `staging`, `stash`, `status`, `sync`, `tags`, `types`, `worktrees`) and those modules are re-exported with `pub use` at the top of `git.rs`. This centralizes and modularizes Git functionality while keeping many symbols available via the `git` facade. - Several previously inline types and helpers were removed from the large file body (they appear to have been relocated into the new modules). The diff shows many structs/enums and helper functions were taken out of the monolithic file and replaced by smaller, focused helpers in the refactored layout. - New repository and filesystem helper functions were added to the backend surface: - `resolve_repo` and `git_dir_for_repo` to resolve repository paths using git. - `resolve_repo_child_path` to validate and canonicalize file paths that must stay inside the repo (rejects absolute paths and `..`). - `normalize_git_path` and `parse_nul_paths` for path normalization and NUL-separated output parsing. - `git_path_exists`, `rebase_in_progress`, `cherry_pick_in_progress`, `merge_in_progress` to detect Git internal state. - Cross-platform helpers to open/reveal paths in the OS file manager (`open_path_in_file_manager` and `reveal_path_in_file_manager`) with platform-specific implementations for Windows, macOS and other Unix. - `file_status_index` to build a lookup from `GitFileStatus` slices. - Some previously present search cancellation and sequence-editor/commit-editor helpers (e.g. `SearchCancellationState`, `SearchCancellation`, `run_sequence_editor_if_requested`, `apply_reword_message`) are removed from this file in the diff; they were likely moved into appropriate modules as part of the split. - CHANGELOG.md updated to document user-visible additions that match the code changes: - Commit history can be filtered by author, message, path/file and date range, combined with logical AND and applied by Git. - Global search exposes new history modes (git log -S, -G and file add/delete/rename), accepts the same filters and shows diffs for results including deleted files. - Issues can start a branch from the Issue Center detail panel; branch names are suggested from the issue number and title (example `12-login-fails`), and while that branch is checked out the commit panel offers to append `Fixes #12` to commit messages. Testing No test execution results were provided. Recommended reviewer checks 1. Build: run `cargo build` (and `cargo test` if applicable) to validate the refactor did not break public API usage across the codebase. 2. Smoke UI flows: - Open a repository and exercise the Commits/History panel; try the Filter button and the new history search modes (where applicable). - From the Issue Center, use the Create branch action and confirm a branch is created with a suggested name and that the commit panel suggests appending `Fixes #<issue>` while that branch is checked out. - Try "Open in file manager" / "Reveal in file manager" for files and repository folders on each supported platform. 3. Path/security: test `resolve_repo_child_path` behavior with absolute paths and `..` references to ensure they are rejected. 4. Backwards-compat: search for any direct imports of symbols that were previously defined directly in `git.rs` (if some types were not re-exported, update imports accordingly). Compatibility / migration notes - The file-splitting appears to retain a façade via `pub use` re-exports to minimize import breakage, but reviewers should still verify any code that relied on private/internal locations or on types that might not have been re-exported. - The search-cancellation and sequence/commit editor helpers that were present in the old `git.rs` are no longer in this file; if other code referenced them by path, update imports to the new module locations (they were likely moved as part of the split). Risks - Large refactors like this mainly risk missing re-exports or failing to update all call sites. The build and the smoke tests above are the primary mitigations. Notes - The CHANGELOG entries included in this diff document the new history features and the Issue Center branch creation UI; those entries align with the code-level additions observed in the diff. If you want, I can run through or suggest exact grep commands to find remaining call sites that might need import fixes (for example searching for previously-file-scoped type names) or prepare a short checklist of symbols to verify.
Split the large src-tauri/src/git.rs into multiple focused modules under
src-tauri/src/git/ (ai, bisect, branches, commit, compare, conflicts,
credentials, history, lfs, merge, notes, process, rebase, remotes,
repository, staging, stash, status, sync, tags, types, worktrees, tests)
and re-export their public items from src-tauri/src/git.rs. This
reorganizes the monolithic git implementation into smaller units while
preserving the crate's public surface via pub use.

Also moved and refactored several common helpers into the repository
module, including:
- repo/path resolution and validation (resolve_repo, resolve_repo_child_path,
  git_dir_for_repo, is_repository_folder_path, normalize_git_path)
- git-path existence checks (git_path_exists)
- OS-specific "open/reveal in file manager" helpers (explorer, open, xdg-open)
These helpers centralize path handling and file-manager behavior.

Frontend additions:
- Added app-related utility modules under src/lib/app (appConstants,
  appPreferences, appTypes, confirmRequests, gitErrors, repoPaths,
  reviewHelpers, startup) and updated src/App.svelte to use the new
  helpers.

Notes:
- This is an internal refactor and aims to preserve existing behavior;
  public symbols remain exported from the top-level git module.
- The changes primarily re-locate and split code; callers should see no
  behavioral differences, but internal code is now easier to navigate.
Add the ability to create a local branch directly from an issue in the Issue Center and optionally link commits on that branch to the issue.

- Issue Center detail panel now offers "Create branch" which finds a matching local repository (preferring the repo currently open), proposes a name derived from the issue number and title (e.g. "12-login-fails"), and opens a dialog to create the branch from the current branch.
- When a branch created from an issue is checked out the Commit panel shows a checkbox to append "Fixes #<number>" to commits. The branch→issue link is persisted per-repository in localStorage so the UI can suggest/apply the reference while on that branch.
- Adds issueBranch utilities (slugifying titles, branch name generation, commit reference and storage helpers) and the IssueBranchDialog component; wires the App to start/create issue branches and to append the issue reference when committing. Also refactors repository lookup into findLocalRepository which prefers the active repo.
Add GitHistoryFilter and HistorySearchMode to support narrowing commit lists
and performing history searches (pickaxe/-S, regex/-G, and file lifecycle
searches for added/deleted/renamed files).

- New src-tauri/src/git/history_search.rs: GitHistoryFilter parsing/validation,
  conversion to git log args, search_history_core and async tauri command
  search_history. Supports case sensitivity, oldest-first ordering, limits and
  cancellable searches.
- Wire filter support into commit listing: commit_page_for_repo and callers
  (notes, list_commits) now accept an optional GitHistoryFilter and pass
  corresponding git log options (author, grep, since/until, path, --all-match).
  Dates are validated as YYYY-MM-DD; path is passed after `--` to avoid option
  injection.
- Add FileStatusKind status to GitSearchHit to indicate how a file was changed
  in history searches, update types and tests accordingly. Many unit tests for
  filtering and history searches were added/updated.
- Export search_history and the new types via the git module and expose the
  new bindings to the frontend; update CHANGELOG.

No behavioral changes to existing APIs unless a caller opts to provide a
GitHistoryFilter (backwards-compatible when omitted).
Add an optional onCreateBranch prop to the integration board view and
forward it from IssueCenter so a parent can handle branch creation.
Render a GitBranch button in the issue-detail sidebar when the selected
card has a repository and number, invoking onCreateBranch(issue, sourceId).

Introduce a cardIssue(...) helper that maps an IntegrationBoardCard into
a minimal IntegrationIssue (id, number, title, description/HTML,
repository, labels, assignees, webUrl and state) suitable for branch
naming and repository matching. The new prop is optional and defaults
to undefined.
# Conflicts:
#	src-tauri/src/git.rs
#	src/App.svelte
Christoph closed this pull request 2026-10-07 19:14:02 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.