8000 fix(utils): only pass git URLs through [1]; flag local paths in validate by zuqini · Pull Request #44 · zuqini/zpack.nvim · GitHub
[go: up one dir, main page]

Skip to content

fix(utils): only pass git URLs through [1]; flag local paths in validate - #44

Merged
zuqini merged 4 commits into
mainfrom
zpack-pr42-followup
Sep 25, 2026
Merged

zuqini merged 4 commits into
mainfrom
zpack-pr42-followup

Conversation

@zuqini
@zuqini zuqini commented Sep 25, 2026 •
Copy link
Copy Markdown
Owner

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.expanded, 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 fix(utils): allow non-GitHub URLs while still expanding the short form GitHub owner/repo paths #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

@zuqini zuqini changed the title fix(import): stop treating ~ and ./ paths in [1] as local sources fix(utils): only pass git URLs through [1]; flag local paths in validate 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
zuqini force-pushed the zpack-pr42-followup branch from c8e653b to c32b15b Compare September 25, 2026 19:00
`[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.
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.
`{ '~/repo' }` now fails with "https://github.com/~/repo not found",
which is no more actionable than git's old "repository '~/repo' does
not exist". The prefix is trivially detectable, so have validate_spec
say "use dir" up front. Advisory only, like every other spec check.

Flag it only when `[1]` is actually the source: with an explicit
src/url/dir it just feeds the name, so `{ '~/foo', dir = '~/foo' }`
would otherwise warn on every setup() telling the user to do what they
had already done. 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.

The suggestion does not echo the value: `dir = "./repo"` would resolve
against nvim's start directory, the very hazard that pulled `./` out of
`[1]`.
@zuqini
zuqini force-pushed the zpack-pr42-followup branch from e831f70 to 2504b24 Compare September 25, 2026 19:22
@zuqini
zuqini merged commit 451a0bb into main Sep 25, 2026
4 checks passed
@zuqini
zuqini deleted the zpack-pr42-followup branch November 6, 2026 08:07
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.

1 participant

0