Add submodule management and enable recursive clone by default #44

Merged
Christoph merged 1 commits from git-submodule into main 2026-09-16 20:59:35 +00:00
Owner

This change introduces first-class submodule support and makes clone operations initialize submodules by default.

Summary

  • Adds a new Rust module src-tauri/src/git/submodules.rs that implements listing, adding, initializing/updating, staging and syncing submodules. The module supports nested submodules (with a maximum nesting depth check) and includes path-safety checks (safe_path).
  • Exposes Tauri commands: list_submodules, add_submodule and submodule_action by registering them in src-tauri/src/main.rs.
  • Integrates submodule UI state and flows in the frontend (src/App.svelte): variables and logic for submodule counts, initialization flows, dialog state and auto-refresh inhibition while submodule dialogs are open are added (partial UI diff included).
  • Changes clone behavior in src-tauri/src/git.rs: the clone implementation now appends --recurse-submodules to initialize every submodule (including nested ones) at the recorded commit. A run_git_clone_command wrapper was introduced to allow injecting a Command for tests.
  • parse_custom_clone_flags was updated to reject certain clone flags that would disable or conflict with recursive submodule handling (examples added: --no-recurse-submodules, --no-recursive, --remote-submodules are considered invalid custom flags).
  • Documentation: README.md gains a Submodules section describing the UI and behavior.

Concrete observable outcomes (from the diff)

  • Cloning via the built clone path will pass --recurse-submodules to Git, so submodules recorded in the parent will be initialized during clone.
  • The code exposes async Tauri commands for listing submodules, adding a submodule, and performing actions (initialize/update/stage/sync) on a named submodule path.
  • The submodule listing returns per-module details including recorded commit, local_commit (when initialized), dirty/conflicted flags, URL, branch and nesting depth.
  • New unit tests were added: tests covering nested submodule clone behavior (in src-tauri/src/git.rs), and many tests for submodule listing, initialization, staging, syncing, path validation and nested discovery (in src-tauri/src/git/submodules.rs).

Testing

  • Tests added or changed: multiple unit tests added in src-tauri/src/git/submodules.rs and one new test in src-tauri/src/git.rs that exercises cloning with nested submodules and validates recorded vs checked-out commits and statuses.
  • No test execution results were provided.

Recommended reviewer checks

  1. Run the test suite (cargo test in the Tauri backend) and specifically exercise the newly added tests exercising clone + nested submodules and the submodules unit tests.
  2. Manually validate cloning a repository with nested submodules using the application (or the underlying run_git_clone_command path) to confirm the --recurse-submodules behavior, and verify the UI shows uninitialized submodule counts and the initialization flow described in README.

Compatibility / migration notes

  • Clone invocations through the modified pathway will initialize submodules by default. Custom clone flags that explicitly disable recursion (e.g. --no-recurse-submodules, --no-recursive, --remote-submodules) are rejected by parse_custom_clone_flags as invalid input to custom flags.
  • The new submodule operations call Git with GIT_TERMINAL_PROMPT=0 for non-interactive behavior when invoking submodule Git commands.

Files/areas to review closely

  • src-tauri/src/git/submodules.rs: path-safety (safe_path) and canonicalization logic, recursion depth limit, and error messages returned to the UI.
  • src-tauri/src/git.rs: addition of --recurse-submodules and the new run_git_clone_command wrapper and parse_custom_clone_flags changes.
  • Tauri command registration in src-tauri/src/main.rs and the frontend wiring in src/App.svelte (ensure command names/types match the expected contract).

If you want I can also provide a concise test plan with exact commands to reproduce a nested-submodule clone and the expected outputs.

This change introduces first-class submodule support and makes clone operations initialize submodules by default. Summary - Adds a new Rust module src-tauri/src/git/submodules.rs that implements listing, adding, initializing/updating, staging and syncing submodules. The module supports nested submodules (with a maximum nesting depth check) and includes path-safety checks (safe_path). - Exposes Tauri commands: list_submodules, add_submodule and submodule_action by registering them in src-tauri/src/main.rs. - Integrates submodule UI state and flows in the frontend (src/App.svelte): variables and logic for submodule counts, initialization flows, dialog state and auto-refresh inhibition while submodule dialogs are open are added (partial UI diff included). - Changes clone behavior in src-tauri/src/git.rs: the clone implementation now appends --recurse-submodules to initialize every submodule (including nested ones) at the recorded commit. A run_git_clone_command wrapper was introduced to allow injecting a Command for tests. - parse_custom_clone_flags was updated to reject certain clone flags that would disable or conflict with recursive submodule handling (examples added: --no-recurse-submodules, --no-recursive, --remote-submodules are considered invalid custom flags). - Documentation: README.md gains a Submodules section describing the UI and behavior. Concrete observable outcomes (from the diff) - Cloning via the built clone path will pass --recurse-submodules to Git, so submodules recorded in the parent will be initialized during clone. - The code exposes async Tauri commands for listing submodules, adding a submodule, and performing actions (initialize/update/stage/sync) on a named submodule path. - The submodule listing returns per-module details including recorded commit, local_commit (when initialized), dirty/conflicted flags, URL, branch and nesting depth. - New unit tests were added: tests covering nested submodule clone behavior (in src-tauri/src/git.rs), and many tests for submodule listing, initialization, staging, syncing, path validation and nested discovery (in src-tauri/src/git/submodules.rs). Testing - Tests added or changed: multiple unit tests added in src-tauri/src/git/submodules.rs and one new test in src-tauri/src/git.rs that exercises cloning with nested submodules and validates recorded vs checked-out commits and statuses. - No test execution results were provided. Recommended reviewer checks 1) Run the test suite (cargo test in the Tauri backend) and specifically exercise the newly added tests exercising clone + nested submodules and the submodules unit tests. 2) Manually validate cloning a repository with nested submodules using the application (or the underlying run_git_clone_command path) to confirm the --recurse-submodules behavior, and verify the UI shows uninitialized submodule counts and the initialization flow described in README. Compatibility / migration notes - Clone invocations through the modified pathway will initialize submodules by default. Custom clone flags that explicitly disable recursion (e.g. --no-recurse-submodules, --no-recursive, --remote-submodules) are rejected by parse_custom_clone_flags as invalid input to custom flags. - The new submodule operations call Git with GIT_TERMINAL_PROMPT=0 for non-interactive behavior when invoking submodule Git commands. Files/areas to review closely - src-tauri/src/git/submodules.rs: path-safety (safe_path) and canonicalization logic, recursion depth limit, and error messages returned to the UI. - src-tauri/src/git.rs: addition of --recurse-submodules and the new run_git_clone_command wrapper and parse_custom_clone_flags changes. - Tauri command registration in src-tauri/src/main.rs and the frontend wiring in src/App.svelte (ensure command names/types match the expected contract). If you want I can also provide a concise test plan with exact commands to reproduce a nested-submodule clone and the expected outputs.
Christoph added 1 commit 2026-09-16 20:37:04 +00:00
Add a new backend module to manage Git submodules (list, initialize/update,
stage, sync, add) and expose Tauri commands (list_submodules,
submodule_action, add_submodule). The implementation enforces safe relative
paths, a maximum nesting depth, and guards (dirty/conflicted checks and
initialization/no-op semantics) to avoid unsafe operations.

Refactor clone logic to a testable run_git_clone_command and enable
automatic initialization of submodules during clone by passing
--recurse-submodules. Also disallow certain submodule-related custom clone
flags so callers cannot override this behaviour.

Update README with a Submodules section and add frontend components and types
to surface submodule UI (dialogs, toolbar badge). Unit tests were added for
submodule discovery, initialization/update semantics, and recursive clone
behavior.
Christoph merged commit 50410187f3 into main 2026-09-16 20:59:35 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Christoph/GitLite#44