Skip to content

[repo-assist] Fix local git dependency version restriction failure (#3422) - #4390

Merged
dsyme merged 1 commit into
masterfrom
repo-assist/fix-issue-3422-local-git-version-restriction-567cf01596424271
Aug 29, 2026
Merged

dsyme merged 1 commit into
masterfrom
repo-assist/fix-issue-3422-local-git-version-restriction-567cf01596424271

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Closes #3422

Root cause

RemoteDownload.getSHA1OfBranch handles resolving a commit hash for git dependencies. For local git repos (git (redacted) it only handled VersionRestriction.NoVersionRestrictionandVersionRestriction.Concrete(a literal branch/tag name). Any version-range requirement (e.g.git (redacted) >= 1.0, matching the documented syntax) parses to VersionRestriction.VersionRequirement`, which fell through to:

| _ -> failwith "unexpected version restriction"

producing the reported Paket failed with -> unexpected version restriction.

The RemoteGitOrigin (non-local) branch of the same match already supports VersionRequirement by fetching a cache clone and searching git tags for the highest matching version. This PR mirrors that same logic for LocalGitOrigin, operating directly on the local path (no cache clone needed since the repo is already on disk).

Fix

src/Paket.Core/Dependencies/RemoteDownload.fs: for LocalGitOrigin, when the version restriction is a VersionRequirement, list tags via git tag, parse them as SemVer, filter by the requirement range, and resolve the hash of the highest matching tag — the same approach already used for remote git origins.

Trade-offs

  • Minimal, surgical change scoped to the local-git-with-version-range case; no behavior change for NoVersionRestriction/Concrete (branch name) cases.
  • Uses the existing Git.CommandHelper.runFullGitCommand/Git.Handling.getHash helpers already used for the remote case, for consistency.

Test Status

  • ✅ Build succeeded (dotnet build src/Paket.Core/Paket.Core.fsproj, net461 + netstandard2.0).
  • ✅ Unit tests: dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~Git" — 36/36 passed on net9 (net461 host skipped in this sandbox: no mono available to run the net461 test host).
  • No existing automated test covers local git version-range resolution; adding one would require creating a real local git repo with tags inside the test, which the current test suite in this area does not do. Flagging this as a good follow-up for Task 9 (Testing Improvements) if desired.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38

Closes #3422

Root cause: RemoteDownload.getSHA1OfBranch handled the LocalGitOrigin
case with only NoVersionRestriction and Concrete branch names; any
VersionRequirement (e.g. 'git file:///path/to/repo >= 1.0') fell
through to failwith "unexpected version restriction". The
RemoteGitOrigin case already supported VersionRequirement by scanning
git tags for a matching version, so this mirrors that logic for local
repositories using the local path directly instead of a remote cache
clone.

Co-authored-by: Copilot <[email protected]>
@dsyme
dsyme marked this pull request as ready for review August 29, 2026 09:35
@dsyme
dsyme merged commit c99229e into master Aug 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting unexpected version restriction message when referencing local git repo

1 participant