8000 fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/repo paths by mbwilding · Pull Request #42 · zuqini/zpack.nvim · GitHub
[go: up one dir, main page]

Skip to content

fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/repo paths - #42

Merged
zuqini merged 2 commits into
zuqini:mainfrom
mbwilding:fix/full-url-source
Sep 25, 2026
Merged

zuqini merged 2 commits into
zuqini:mainfrom
mbwilding:fix/full-url-source

Conversation

@mbwilding
@mbwilding mbwilding commented Sep 25, 2026 •
Copy link
Copy Markdown
Contributor

Specs like { 'https://forge.example.com/owner/repo' } were expanded to https://github.com/https://forge.example.com/owner/repo, causing vim.pack to fail with repository not found.

github_url now returns full URLs (any scheme), scp-style git@host:path and local paths (/, ~, .) unchanged, and only expands owner/repo shorthand to GitHub.

Tests added in tests/utils_test.lua and all pass.

@mbwilding mbwilding changed the title fix(utils): use full URL or path from [1] instead of prefixing GitHub fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/user paths Sep 25, 2026
@mbwilding mbwilding changed the title fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/user paths fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/repo paths Sep 25, 2026
@zuqini
zuqini commented Sep 25, 2026
Copy link
Copy Markdown
Owner

LGTM, thank you!

Should note for posterity that this PR is for automatically inferring the URL from the positional argument [1], not conflicting with the existing url parameter from the Spec.

@zuqini
zuqini merged commit a6fdbf5 into zuqini:main Sep 25, 2026
4 checks passed
zuqini added a commit that referenced this pull request Sep 25, 2026
#42 passed `[1]` values starting with `/`, `~`, or `.` through unchanged,
but vim.pack hands `src` to `git clone` verbatim: `{ '~/repo' }` fails
with "repository '~/repo' does not exist", and `{ './repo' }` resolves
against whatever directory nvim was started from. `{ dir = '~/repo' }`
already covers local checkouts and is `vim.fn.expand`ed, so `[1]` now
passes through only URL-shaped values (any `scheme://` and scp-style
`user@host:`); anything else is `owner/repo` shorthand. This is exactly
lazy.nvim's rule, which has no local-path branch for `[1]` at all.
`/abs` in `[1]` never worked in a released version, so nothing depends
on it.

Pin the reported bug end to end: a full URL in `[1]` registers under
that URL instead of `https://github.com/https://...`. Pin the shorthand
outcome for `~`, `./` and `/` with exact assertions instead of `~=`; the
old test passed for any transformation, including a future expansion
branch.
zuqini added a commit that referenced this pull request Sep 25, 2026
`[1]` still read as "always expands to github.com" in the vimdoc, spec.md,
and the LuaLS field annotation after #42 made full URLs pass through.
State the split at each site: `owner/repo` expands, a full git URL (any
`scheme://` or scp-style `user@host:`) is used as-is, and local checkouts
go through `dir`.

Make `dir` read as the local-checkout field rather than a compat alias,
and note on `src` that it is passed to git verbatim, so `~` is not
expanded there either. Otherwise a reader scanning the field list sees
`src` = "local path, highest priority" and `dir` = "compat shim" and
picks the one that does not expand.
zuqini added a commit that referenced this pull request Sep 25, 2026
Since #42 a `[1]` value may be a full URL and is matched before any
concatenation, so the fold_rank and normalize_source comments described
a shape that no longer exists.
zuqini added a commit that referenced this pull request Sep 25, 2026
`[1]` still read as "always expands to github.com" in the vimdoc, spec.md,
and the LuaLS field annotation after #42 made full URLs pass through.
State the split at each site: `owner/repo` expands, a full git URL (any
`scheme://` or scp-style `user@host:`) is used as-is, and local checkouts
go through `dir`.

Make `dir` read as the local-checkout field rather than a compat alias,
and note on `src` that it is passed to git verbatim, so `~` is not
expanded there either. Otherwise a reader scanning the field list sees
`src` = "local path, highest priority" and `dir` = "compat shim" and
picks the one that does not expand.
zuqini added a commit that referenced this pull request Sep 25, 2026
Since #42 a `[1]` value may be a full URL and is matched before any
concatenation, so the fold_rank and normalize_source comments described
a shape that no longer exists.
zuqini added a commit that referenced this pull request Sep 25, 2026
…ate (#44)

Follow-ups to #42, which let a full git URL in `[1]` pass through instead of being prefixed with `https://github.com/`.

#42 also passed `[1]` values starting with `~`, `.` or `/` through unchanged, but vim.pack hands `src` to `git clone` verbatim: `{ '~/repo' }` fails with "repository '~/repo' does not exist", and `{ './repo' }` resolves against whatever directory nvim was started from. `{ dir = '~/repo' }` already covers local checkouts and is `vim.fn.expand`ed, so `[1]` now passes through only URL-shaped values (any `scheme://` and scp-style `user@host:`); anything else is treated as `owner/repo` shorthand. This is exactly lazy.nvim's rule, which has no local-path branch for `[1]` at all.

Because `{ '~/repo' }` would otherwise fail with an equally unhelpful "github.com/~/repo not found", `validate_spec` now flags a `[1]` starting with `~`, `.` or `/` with "looks like a local path — use dir". Advisory only, like every other spec check, and only when no explicit `src`/`url`/`dir` is set — with one of those present `[1]` just feeds the name and never reaches git. A `dev = true` spec is skipped too: it loads from `dev.path`, and `[1]` reaches git only under `dev.fallback = true` with a missing checkout, which validate cannot see.

Also:
- end-to-end regression test for the #42 bug (a full URL in `[1]` registers under that URL, name derives from its basename)
- exact-value unit tests pinning that `~/`, `./` and `/` in `[1]` become shorthand
- docs aligned at every site (vimdoc `[1]`/spec block/dependencies note, `docs/spec.md`, LuaLS `zpack.Spec` annotation): `owner/repo` expands to GitHub, a full git URL is used as-is, use `dir` for local paths
- `dir` docs lead as the local-checkout field instead of a compat alias; `src` docs note that it is passed to git verbatim, so `~` is not expanded there either — use `dir`
- stale comments that assumed `[1]` is always shorthand; test data uses `example.com` hosts

Refs #42
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

0