Skip to content

fix(nested-repos): do not process repos nested inside a working tree#34

Merged
richwklein merged 1 commit into
mainfrom
fix/master-detection
Jun 3, 2026
Merged

fix(nested-repos): do not process repos nested inside a working tree#34
richwklein merged 1 commit into
mainfrom
fix/master-detection

Conversation

@richwklein

Copy link
Copy Markdown
Owner

Summary

When scanning a directory for git repositories, the script previously used find to locate all .git directories recursively. This caused it to descend into a repo's working tree and process any nested git repos it found there — including repos created by tools like parsimony that store git data inside another repo's working directory.

Linked issue

Closes #

Type of change

  • Bug fix
  • Feature
  • Maintenance / cleanup
  • Documentation / content
  • Breaking change

Details

Replaced the find -name ".git" scan with a recursive shell function find_git_repo_roots that walks subdirectories and yields a directory as a repo root the moment it finds a .git entry, without recursing further into it. This means once the outer repo boundary is reached, no inner repos in its working tree are ever visited.

The fix handles both .git directories (regular clones) and .git files (linked worktrees) via [ -e "$subdir/.git" ].

Release / deploy impact

  • Preview deploy is useful for reviewing this change
  • Safe to label no-deploy
  • This PR intentionally updates the version

Validation

  • Lint passes locally
  • Unit tests pass locally
  • Added or updated tests where appropriate
  • Manually verified changes
  • Documentation updated where appropriate

Reviewer notes

The previous find-based approach also had an intermediate fix (-not -path '*/.git/*') that filtered out .git dirs nested inside another .git/ directory. The recursive function makes that filter unnecessary — it never descends into .git/ internals to begin with, and stops at working-tree boundaries too.

Replaced the find-based .git directory scan with a recursive shell
function that stops descending into a directory as soon as it finds
a .git entry. This prevents the script from processing git repos
that tools (e.g. parsimony) place inside another repo's working tree.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@richwklein
richwklein marked this pull request as ready for review June 3, 2026 13:37
@richwklein
richwklein merged commit f8f7727 into main Jun 3, 2026
4 checks passed
@richwklein
richwklein deleted the fix/master-detection branch June 3, 2026 13:39
richwklein pushed a commit that referenced this pull request Jun 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.2.2](v2.2.1...v2.2.2)
(2026-06-03)


### Bug Fixes

* **nested-repos:** do not process repos nested inside a working tree
([#34](#34))
([f8f7727](f8f7727))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-bot-richwklein[bot] <286966360+release-bot-richwklein[bot]@users.noreply.github.com>
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