Skip to content

Update submodules separately to git checkout#21188

Merged
sergiou87 merged 13 commits intodevelopmentfrom
checkout-with-submodules
Jan 27, 2026
Merged

Update submodules separately to git checkout#21188
sergiou87 merged 13 commits intodevelopmentfrom
checkout-with-submodules

Conversation

@sergiou87
Copy link
Member

@sergiou87 sergiou87 commented Oct 30, 2025

#21005

Description

This PR changes how git checkout behaves, and instead of using the --recurse-submodules argument, it will run git submodule update --init --recursive.

For clarity's sake, the UI will show progress of this task as part of the checkout operation. Users might still run into some edge cases when switching between branches with submodules, but this seems to be an improvement over the previous behavior.

Release notes

Notes: [Fixed] Fix bad repository state when switching between branches with submodules

sergiou87 and others added 13 commits October 30, 2025 11:48
Introduces a helper to set up a repository with an uninitialized submodule and adds a unit test to verify that checking out a branch with such a submodule correctly initializes it. This ensures proper handling of submodules that have not been initialized when switching branches.
Replaces CheckoutWithSubmodulesProgressParser with a more flexible IGitProgressParser interface and updates submodule progress reporting logic. Adjusts progress value scaling for submodule updates in branch and commit checkout functions to improve accuracy and user feedback. Cleans up parser usage in progress-related modules for consistency.

Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Introduced clampProgress helper to standardize progress value scaling during branch and commit checkout. Replaced manual progress calculations with clampProgress for improved readability and maintainability.

Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Progress reporting for submodule updates during checkout now uses an exponential function based on detected submodule events, providing a more realistic and gradual progress indication when the number of submodules is unknown.

Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Eliminated the enableRecurseSubmodulesFlag feature flag and updated fetch and pull operations to always use the --recurse-submodules option. This simplifies submodule handling and removes unnecessary conditional logic.
Deleted the test for cleaning up submodules that no longer exist from checkout-test.ts. This test is no longer needed or relevant to current functionality.
Enhances the pull logic to update submodules after pulling from a remote, including progress reporting and file protocol support. Adds unit tests to verify submodule initialization, reference updates, and handling of pulls with no submodule changes.
Consolidates submodule update logic into a generic updateSubmodulesAfterOperation function in submodule.ts, replacing operation-specific implementations in checkout.ts and pull.ts. Also moves and generalizes clampProgress to progress.ts for reuse. This improves code maintainability and reduces duplication.
Refactored test helpers and unit tests to use native fs/promises methods and a custom pathExists utility instead of fs-extra. This reduces external dependencies and aligns with modern Node.js practices.
@sergiou87 sergiou87 marked this pull request as ready for review January 22, 2026 15:43
Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

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

@sergiou87 sergiou87 merged commit ee9d177 into development Jan 27, 2026
7 checks passed
@sergiou87 sergiou87 deleted the checkout-with-submodules branch January 27, 2026 13:23
@sergiou87 sergiou87 mentioned this pull request Jan 28, 2026
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