Skip to content

Keep a cloned repository's folder when an owner scan lists it [patch] - #473

Open
matt-edmondson wants to merge 2 commits into
mainfrom
fix/438-keep-cloned-path
Open

matt-edmondson wants to merge 2 commits into
mainfrom
fix/438-keep-cloned-path

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #438

Problem

SyncGitHubRepoInfoForOwner always replaced Options.Repos[repoName] with a repository at <dev>/<owner>/<repo>, even when Scan Dev Dir had already found it cloned somewhere else, such as <dev>/<repo>. UpdateClonedStatus walks only Options.Repos, so it never visited the old ClonedRepos entry. After Scan Dev Dir followed by Scan GitHub Owners, the repository:

  • fetched a folder that doesn't exist every 60 seconds,
  • offered Pull, Commit and Push, all of which failed,
  • dropped out of sibling comparisons.

Changes

  • New ChooseSyncedLocalPath: if the repository is already known and its LocalPath is a git repository, the owner scan keeps that path. Otherwise it uses the conventional one.
  • New PruneStaleClonedRepos, called from UpdateClonedStatus: removes ClonedRepos entries whose repository is unknown or no longer points at that path.

Both are plain internal static methods, following the repo's pattern of keeping logic out of the ImGui layer so it can be tested.

Tests

New OwnerSyncTests:

  • AnOwnerScanKeepsTheFolderARepositoryIsAlreadyClonedIn: a real git init under a temp dev directory
  • AnOwnerScanUsesTheConventionalFolderForAnUnknownRepository
  • AnOwnerScanUsesTheConventionalFolderWhenTheKnownOneIsNotAClone
  • ACloneRecordedAtAPathItsRepositoryNoLongerUsesIsPruned
  • ACloneOfAnUnknownRepositoryIsPruned
  • ACloneRecordedAtItsRepositorysPathIsKept

I stubbed both methods back to the old behaviour (always the conventional path, never prune). With the stubs, the three tests that cover the bug fail. With the fix they pass.

Full suite: 138 of 139 pass. The one failure, GitCliTests.CloningAnLfsRepositoryRestoresTheFileContentRatherThanThePointer, fails the same way with this change reverted. It's caused by the local sandbox's git-lfs setup, not by this PR.

dotnet format --verify-no-changes reports two findings in ProjectDirector.cs (import ordering, and IDE0001 in ChooseCredentials). Both are already on main, and nothing in this diff adds to them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KLpJqJzDAe9WoXTVLt65CJ


Generated by Claude Code

Scan GitHub Owners replaced every listed repository with one at
<dev>/<owner>/<repo>, even when Scan Dev Dir had already found it cloned
elsewhere, and the old ClonedRepos entry was never visited again. The
repository then fetched a folder that does not exist every minute and offered
Pull, Commit and Push that all failed.

The owner scan now keeps a known repository's path when it is a clone, and
UpdateClonedStatus prunes ClonedRepos entries whose repository no longer
points at their path.

Fixes #438

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KLpJqJzDAe9WoXTVLt65CJ
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
Comment thread ProjectDirector.Test/OwnerSyncTests.cs Fixed
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

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.

After "Scan GitHub Owners", repos found by "Scan Dev Dir" point at a nonexistent folder, fail a fetch every minute, and show broken Pull/Commit/Push

2 participants