Skip to content

Implement support for packages not backed by Git repos#236

Open
bbannier wants to merge 11 commits into
masterfrom
topic/bbannier/non-git-packages
Open

Implement support for packages not backed by Git repos#236
bbannier wants to merge 11 commits into
masterfrom
topic/bbannier/non-git-packages

Conversation

@bbannier

@bbannier bbannier commented Jul 17, 2026

Copy link
Copy Markdown
Member

Caution

The most offensive bit upfront: This PR was fully generated with Claude Sonnet 4.6 (all code, tests, even commit messages). This PR description is written by me. I started this out with a design doc written by me which captures some points from #231 (full of grammar errors and typos, human!). I added lots of instructions to make sure the LLM-generated commits are up to our standards and are fit for human review, and to keep it from falling back to its default, unacceptable coding style. I also requested good unit test coverage for new code, something which we currently do not have. If not automatically generated, I requested BTest integration tests as well.

Part of my instructions was to create self-contained commits which are easy to review. I did a review of all changes in this branch, so I can be and am fully accountable for anything happening here.

What this accomplishes is that we now support running operations like zkg install or zkg test against plain directories. This lifts the requirement to always commit stuff to Git before e.g., being able to run tests, and on the side also closes #158. For directories we do not clone into the local staging area, but instead work directly from it. This means that if e.g., a package requires a build step this can be shared across multiple invocations.

Since we do not require network access for such "directory packages" local directories also improve on #176 (I did not make this explicit with a flag though). The design here should also work for in the future adding support to install from tarballs which would allow users to e.g., bundle up pre-compiled artifacts without having to commit them to Git; I could imagine tarball support to extract to a tempdir, and install from that.

Since directory packages have no Git tag to determine its version, we require an explicit version entry in zkg.meta for them. Down the line this will help implement #211 since we can decouple per-package versions from Git tags on the monorepo.

bbannier added 11 commits July 17, 2026 11:45
We consolidate version-tag lookup, branch detection, commit-hash
recognition, checkout, and outdated-check into one function that
returns a `GitResolution` dataclass. Call sites in `test()` and
`_install()` are updated to use it. This prepares for upcoming
non-Git package sources by making the resolution boundary explicit.
Unit tests are cheap and catch logic errors quickly; BTest integration
tests are slow. Running them in this order surfaces most failures
without waiting for the full end-to-end suite.
`_pick_version` selects the version string and tracking method from
the clone's available refs; `_resolve_git_version` reads the resulting
HEAD state after checkout. Callers are now responsible for checking
out the desired ref before calling `_resolve_git_version`.

This prepares for upcoming directory-backed package support, where
version selection happens outside the snapshot abstraction.
Decouple package-info gathering from Git operations so Git and directory
sources can be handled uniformly by downstream install, test, and info paths.
The function now takes a `PackageSnapshot` rather than a `git.Repo`;
the new name reflects that.
Extend install, test, info, refresh, and upgrade to support
directory-backed packages alongside Git-backed ones, using the snapshot
abstraction from the previous commit.
Catch a mismatch between the `version` field in `zkg.meta` and the Git
tag being installed before the install completes. Provide an opt-out for
cases where the mismatch is expected.
… path

A directory package passed to `bundle()` with `prefer_existing_clones=True`
would crash trying to open its path as a `git.Repo`. Guard against this by
rejecting directory packages early and skipping the existing-clone fast path
for non-Git installed packages.
Expose the `skip_version_validation` parameter added to `Manager.install()`
via a new `--skip-version-validation` flag on `zkg install`, so users can
opt out of version-field validation on the command line.
\`zkg install\`, \`zkg test\`, and \`zkg bundle\` now accept plain local
directories in addition to Git repos. A local path starting with \`.\`
or \`/\` that is not a Git repo is routed to the directory backend
introduced in the previous commit.

For directory-backed packages, \`best_version()\` returns nothing since
there is no Git history. Fall back to \`metadata_version\` instead, which
reads the \`version\` field from \`zkg.meta\`.
The function now accepts plain directories in addition to Git repos;
the new name reflects the broader scope.
@bbannier bbannier self-assigned this Jul 17, 2026
@bbannier
bbannier marked this pull request as ready for review July 17, 2026 11:03
@bbannier
bbannier requested a review from ckreibich July 17, 2026 11:03
@bbannier bbannier mentioned this pull request Jul 20, 2026
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.

add flag to ignore dirty local git clone

1 participant