Skip to content

fix(prepare): improve git submodule parser and fix check_staleness error handling#8412

Merged
jdx merged 2 commits into
mainfrom
fix/prepare-git-submodule-parser
Mar 2, 2026
Merged

fix(prepare): improve git submodule parser and fix check_staleness error handling#8412
jdx merged 2 commits into
mainfrom
fix/prepare-git-submodule-parser

Conversation

@jdx

@jdx jdx commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Parse .gitmodules with INI section awareness: only extract path values from [submodule "..."] sections, skip comments (#, ;) and non-submodule sections. Previously the parser would pick up path = lines from any section or even comments.
  • Change check_staleness() unwrap_or(true) to unwrap_or(false) so freshness check errors default to fresh rather than stale, preventing spurious warnings.

Follow-up to #8407 which was merged before these fixes landed.

Test plan

  • Existing test_prepare e2e tests pass
  • mise run build compiles cleanly

🤖 Generated with Claude Code


Note

Low Risk
Low risk: small, localized change to .gitmodules parsing logic that may alter which submodule paths are detected, but doesn’t touch execution, auth, or data persistence.

Overview
Improves GitSubmodulePrepareProvider::submodule_paths to be INI-section aware: it now tracks when the parser is inside a [submodule "…"] section, ignores comments (#/;) and other sections, and only extracts path = … values from those submodule sections.

This prevents unrelated path keys (or commented lines) from being treated as submodule outputs, reducing false positives during prepare output detection.

Written by Cursor Bugbot for commit 0b52446. This will update automatically on new commits. Configure here.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the preparation engine by improving how Git submodule paths are parsed and by correcting an error handling default in freshness checks. The changes ensure more robust and accurate processing of .gitmodules files and prevent misleading staleness warnings, leading to a more reliable and less noisy system.

Highlights

  • Git Submodule Parsing: The .gitmodules parser was enhanced to correctly handle INI-style sections and comments, ensuring that only path values from [submodule "..."] sections are extracted. This prevents incorrect parsing from comments or non-submodule sections.
  • Staleness Check Error Handling: The check_staleness() function's error handling was adjusted from unwrap_or(true) to unwrap_or(false). This change means that if a freshness check encounters an error, it will now default to considering the item fresh rather than stale, thereby preventing spurious warnings.
Changelog
  • src/prepare/engine.rs
    • Modified the check_freshness call to use unwrap_or(false) instead of unwrap_or(true) for error handling.
  • src/prepare/providers/git_submodule.rs
    • Implemented logic to filter lines in .gitmodules based on INI section awareness.
    • Added checks to skip comment lines starting with # or ;.
    • Introduced a state variable in_submodule_section to track if the parser is currently within a [submodule "..."] section.
    • Ensured that path values are only extracted when in_submodule_section is true.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/prepare/engine.rs Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request improves the git submodule parser and changes error handling for staleness checks. The submodule parser change is a good improvement, though I've suggested a refactoring for better readability and to follow idiomatic Rust practices. The change to staleness check error handling introduces a contradiction between the code's behavior and the pull request description, which I've flagged as a critical issue needing clarification.

Comment thread src/prepare/engine.rs Outdated
.iter()
.filter(|p| p.is_auto())
.filter(|p| !self.check_freshness(p.as_ref()).unwrap_or(true))
.filter(|p| !self.check_freshness(p.as_ref()).unwrap_or(false))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

There's a contradiction between the code change and the pull request description.

The PR description states: "freshness check errors default to fresh rather than stale, preventing spurious warnings."

However, this change from unwrap_or(true) to unwrap_or(false) seems to do the opposite. Let's analyze the filter !self.check_freshness(p.as_ref()).unwrap_or(...):

  • Old code (unwrap_or(true)): If check_freshness returns an Err, the expression becomes !true, which is false. The provider is considered fresh and not included in the list of stale providers. This prevents warnings on error.
  • New code (unwrap_or(false)): If check_freshness returns an Err, the expression becomes !false, which is true. The provider is considered stale and is included in the list, which will trigger a warning.

This change makes errors default to stale, not fresh. Could you please clarify the intended behavior and update either the code or the description to match? If the goal is to show warnings on errors, the code is correct but the description is not.

@greptile-apps

greptile-apps Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR attempts to fix two issues from #8407: improving the .gitmodules parser to handle INI sections correctly, and fixing error handling in staleness checks.

Critical issue found:

  • The check_staleness() change in engine.rs inverts the error handling logic. Changing unwrap_or(true) to unwrap_or(false) makes errors default to stale instead of fresh, which causes spurious warnings rather than preventing them (opposite of the PR description).

Git submodule parser improvements look good:

  • Properly tracks INI section state to only extract path values from [submodule "..."] sections
  • Correctly skips comment lines and non-submodule sections
  • Minor: section name check could be stricter to avoid theoretical edge cases

Confidence Score: 1/5

  • This PR contains a critical logic bug that inverts the intended behavior
  • The engine.rs change does the exact opposite of what's intended - it makes freshness check errors default to stale (causing warnings) instead of fresh (preventing warnings). This will introduce spurious warnings contrary to the PR's stated goal.
  • src/prepare/engine.rs requires immediate attention - the logic change is backwards

Important Files Changed

Filename Overview
src/prepare/engine.rs Critical logic bug: error handling inverted, causes spurious warnings instead of preventing them
src/prepare/providers/git_submodule.rs INI parser improvements look good; minor edge case with section name matching

Fix All in Claude Code

Last reviewed commit: 3480584

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread src/prepare/providers/git_submodule.rs Outdated
if line.starts_with('#') || line.starts_with(';') {
return None;
}
if line.starts_with("[submodule") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Edge case: starts_with("[submodule") would incorrectly match sections like [submodule-config] or [submodule_settings]

While unlikely in real .gitmodules files, consider stricter matching:

  • starts_with("[submodule ") (with space), or
  • starts_with("[submodule\"") (with quote)

This ensures only true [submodule "name"] sections are matched.

Fix in Claude Code

@greptile-apps

greptile-apps Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

src/prepare/engine.rs
Logic bug: the change inverts the error handling behavior

The logic here is filter(|p| !check_freshness().unwrap_or(?)). When check_freshness() errors:

  • With unwrap_or(false): !false = true → provider added to stale list → causes warning
  • With unwrap_or(true): !true = false → provider NOT in stale list → no warning

The PR description says this change should "default to fresh rather than stale, preventing spurious warnings", but the code does the opposite - it makes errors default to stale and causes spurious warnings.

            .filter(|p| !self.check_freshness(p.as_ref()).unwrap_or(true))

Fix in Claude Code

jdx and others added 2 commits March 2, 2026 03:07
…ror handling

- Parse .gitmodules with INI section awareness: only extract path values
  from [submodule "..."] sections, skip comments and non-submodule sections
- Change check_staleness() unwrap_or(true) to unwrap_or(false) so errors
  are treated as fresh rather than stale, avoiding spurious warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match [submodule " or [submodule" specifically to avoid false matches
on hypothetical sections like [submodule-config].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jdx jdx force-pushed the fix/prepare-git-submodule-parser branch from c011531 to 0b52446 Compare March 2, 2026 03:08
@jdx jdx enabled auto-merge (squash) March 2, 2026 03:08
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.24 x -- echo 29.5 ± 0.9 28.0 35.3 1.17 ± 0.20
mise x -- echo 25.3 ± 4.3 23.3 119.4 1.00
✅ Performance improvement for x -- echo is 17%

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.24 env 28.9 ± 0.9 27.2 38.5 1.18 ± 0.04
mise env 24.4 ± 0.5 22.8 26.0 1.00
✅ Performance improvement for env is 18%

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.24 hook-env 30.4 ± 0.7 28.9 36.3 1.20 ± 0.04
mise hook-env 25.3 ± 0.6 24.0 29.7 1.00
✅ Performance improvement for hook-env is 20%

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.24 ls 23.9 ± 0.6 22.7 31.8 1.03 ± 0.03
mise ls 23.1 ± 0.4 22.0 24.7 1.00

xtasks/test/perf

Command mise-2026.2.24 mise Variance
install (cached) 167ms 154ms +8%
ls (cached) 91ms 83ms +9%
bin-paths (cached) 99ms ✅ 87ms +13%
task-ls (cached) 863ms 844ms +2%

✅ Performance improvement: bin-paths cached is 13%

@jdx jdx merged commit 44fa0d7 into main Mar 2, 2026
35 checks passed
@jdx jdx deleted the fix/prepare-git-submodule-parser branch March 2, 2026 03:23
jdx pushed a commit that referenced this pull request Mar 2, 2026
### 🚀 Features

- **(hooks)** add task references to hooks and watch_files by @jdx in
[#8400](#8400)
- **(prepare)** add git-submodule built-in provider by @jdx in
[#8407](#8407)
- **(prepare)** add human-readable stale reasons to prepare output by
@jdx in [#8408](#8408)
- **(prepare)** add dependency ordering to prepare steps by @jdx in
[#8401](#8401)
- **(prepare)** add --explain flag for provider diagnostics by @jdx in
[#8409](#8409)
- **(prepare)** add per-provider timeout support by @jdx in
[#8405](#8405)
- **(prepare)** add blake3 content-hash freshness checking by @jdx in
[#8404](#8404)
- **(tasks)** monorepo vars and per-task vars by @halms in
[#8248](#8248)

### 🐛 Bug Fixes

- **(aqua)** restore bin_paths disk cache with fresh_file invalidation
by @jdx in [#8398](#8398)
- **(idiomatic)** use generic parser for idiomatic files by @risu729 in
[#8171](#8171)
- **(install)** apply precompiled options to all platforms in lockfile
by @jdx in [#8396](#8396)
- **(install)** normalize "v" prefix when matching lockfile versions by
@jdx in [#8413](#8413)
- **(prepare)** improve git submodule parser and fix check_staleness
error handling by @jdx in [#8412](#8412)
- **(python)** respect precompiled settings in lock file generation by
@jdx in [#8399](#8399)
- **(python)** clarify uv_venv_auto docs + prevent uv shim recursion in
venv creation by @halms in
[#8402](#8402)
- **(task)** remove deprecated `# mise` task header syntax by @jdx in
[#8403](#8403)
- **(vfox)** avoid eager metadata loading during config file detection
by @jdx in [#8397](#8397)
- clarify GitHub attestations to be artifact ones by @scop in
[#8394](#8394)
- ignore comments in idiomatic version files by @iloveitaly in
[#7682](#7682)

### 🚜 Refactor

- unify archive detection by @risu729 in
[#8137](#8137)

### 📚 Documentation

- remove duplicated docs for npm.package_manager by @risu729 in
[#8414](#8414)
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.

1 participant