Skip to content

fix(importer): clean untracked files after checkout in reconciler#5440

Merged
another-rex merged 1 commit into
google:masterfrom
another-rex:extend-commit-clean-untracked-20260526
May 26, 2026
Merged

fix(importer): clean untracked files after checkout in reconciler#5440
another-rex merged 1 commit into
google:masterfrom
another-rex:extend-commit-clean-untracked-20260526

Conversation

@another-rex
Copy link
Copy Markdown
Contributor

@another-rex another-rex commented May 26, 2026

In handleReconcileGit, after checking out the target branch, clean up any untracked files and directories to ensure a clean state and avoid processing stale/deleted files.

This extends commit 828810a.

Key Changes:

  • System Git Refactor: Refactored handleReconcileGit to use system git checkout and git clean -fdx commands instead of go-git library calls. This is much more robust and avoids potential out-of-memory or timeout issues with go-git's Status() on large repositories when deployed.
  • Concurrency Fix: Moved checkout and clean out of repoGroup.Do and protected them with repo.mu lock to avoid incorrect state when concurrent imports and reconciles occur.
  • Testing: Added TestHandleReconcileGit_CleanUntracked to verify that untracked files and directories are correctly cleaned up.

agy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure whether we should even have this test.

@another-rex another-rex requested a review from michaelkedar May 26, 2026 04:02
@another-rex another-rex merged commit e444e9e into google:master May 26, 2026
25 checks passed
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