fix: warn when Git target exists but is not a valid git repository (#86)#194
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Git dependency handler behavior when the clone target directory already exists but is not a valid git repository, replacing a confusing/silent no-op path with an explicit warning, and adds Pester coverage for the new/related behaviors.
Changes:
- Added a
Write-Warningand install short-circuit when$RepoPathexists butgit rev-parseyields no branch. - Added Pester tests for idempotency (no re-clone) and the “existing non-git directory” scenario.
- Updated
CHANGELOG.mdto document the fix and new tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Tests/Git.Type.Tests.ps1 | Adds new Pester coverage for idempotency and non-git-directory handling. |
| PSDepend/PSDependScripts/Git.ps1 | Emits a warning and skips install when an existing target directory isn’t a valid git repo. |
| CHANGELOG.md | Documents the Git handler behavior change and new tests under Unreleased. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test Results 3 files 66 suites 1m 27s ⏱️ Results for commit 4c9df6a. ♻️ This comment has been updated with latest results. |
7b88c04 to
8bfb4ae
Compare
HeyItsGilbert
added a commit
that referenced
this pull request
Jun 14, 2026
- Return $false (not $null) from Test action when target exists but is not a valid git repository, preserving the Boolean contract - Idempotency test now also asserts git checkout is not invoked - Warning test mocks Write-Warning and asserts it is called with the expected message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HeyItsGilbert
added a commit
that referenced
this pull request
Jun 14, 2026
- Return $false (not $null) from Test action when target exists but is not a valid git repository, preserving the Boolean contract - Idempotency test now also asserts git checkout is not invoked - Warning test mocks Write-Warning and asserts it is called with the expected message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8386fed to
e492cc0
Compare
Previously, if a directory already existed at the clone target but was not a git repository, `git rev-parse` returned nothing and the handler silently fell into the "we don't support moving versions" branch with null branch/commit values, producing a confusing verbose message and a no-op install. Now emits `Write-Warning` in that case so the user knows why the dependency was skipped. Also confirmed that the nesting bug from #86 (Repo/Repo on repeated runs) does not reproduce on current code; adds two Pester tests to lock in idempotency and the non-git-directory warning path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Return $false (not $null) from Test action when target exists but is not a valid git repository, preserving the Boolean contract - Idempotency test now also asserts git checkout is not invoked - Warning test mocks Write-Warning and asserts it is called with the expected message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Keep a Changelog does not define a Tests category; test additions are implementation details, not user-facing changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e492cc0 to
4c9df6a
Compare
HeyItsGilbert
added a commit
that referenced
this pull request
Jun 14, 2026
- Return $false (not $null) from Test action when target exists but is not a valid git repository, preserving the Boolean contract - Idempotency test now also asserts git checkout is not invoked - Warning test mocks Write-Warning and asserts it is called with the expected message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Repo/Repobug was confirmed non-reproducible on current code)Write-Warningwhen$RepoPathexists butgit rev-parsereturns nothing, so users get a clear signal instead of a silent no-op with a misleading verbose messageTest plan
.\build.ps1 StageFilesthenInvoke-Pester Tests/Git.Type.Tests.ps1— all 5 tests pass🤖 Generated with Claude Code