Implement support for packages not backed by Git repos#236
Open
bbannier wants to merge 11 commits into
Open
Conversation
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.
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.
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 installorzkg testagainst 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
versionentry inzkg.metafor them. Down the line this will help implement #211 since we can decouple per-package versions from Git tags on the monorepo.