Add conformance tests based on upstream Git#59
Merged
Merged
Conversation
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Adds a regression gate for gogit's path-restore checkout by running upstream Git's own test framework against the gogit binary. - Implements just enough gogit subcommands for t/t2008-checkout-subdir.sh to run end-to-end: init, add, commit -m (with GIT_*_NAME/EMAIL/DATE env honoured), checkout HEAD -- <pathspec> (with worktree-escape rejection and directory expansion), version --build-options. - Root-level --exec-path and --version flags, plus os.Exit(1) on bare invocation; required by test-lib.sh's bootstrap and sanity checks. - All repo opens use PlainOpenWithOptions(DetectDotGit) so commands work from subdirectories (t2008 cd's into dir1). - conformance/run.sh fetches upstream tests via \$GIT_SRC override or a shallow clone of github.com/git/git default branch (no SHA pin -- upstream drift surfaces immediately). Synthesises a minimal GIT_BUILD_DIR with GIT-BUILD-OPTIONS and a test-tool stub so test-lib can bootstrap without an actual upstream build. Supports per-script --run= selection and \$GO_GIT_REF for testing against an in-flight go-git ref (with go.mod/go.sum snapshot/restore). - Interactive runs preserve upstream's coloured output by skipping the per-test TAP tee when stdout is a TTY; CI still captures TAP for artifact upload. - make conformance target plus CI matrix job across ubuntu-latest, macos-latest, windows-latest. Assisted-by: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io>
Extends the conformance gate to cover pack-file processing.
- gogit cat-file: -e <oid> existence check (exit 0/1, no output) and
--batch-check (stdin OIDs -> "<oid> <type> <size>" or "<oid> missing").
- gogit index-pack --stdin [--strict]: reads a pack from stdin and writes
pack-<sha>.{pack,idx} into .git/objects/pack/ via go-git's
WritePackfileToObjectStorage. --strict scans the pack with a
WithScannerObservers-attached observer and rejects packs containing
duplicate object IDs before any state is written.
- Harness test-tool stub gains sha1/sha256 [-b] cases (used by
t/lib-pack.sh to compute pack trailers) and is now rewritten on every
run so script changes take effect without manual cache invalidation.
- conformance/tests.txt: append t5308-pack-detect-duplicates.sh.
Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a conformance-test harness that runs curated upstream git/git test scripts against gogit (go-git–backed CLI), expanding the CLI feature surface to match the needs of the first imported test suites.
Changes:
- Introduces
conformance/run.sh+conformance/tests.txtand amake conformancetarget (with CI job + TAP artifact upload on failure). - Adds minimal
gogitcommands/flags needed by the initial upstream tests (e.g.,init,add,commit,checkout,cat-file,index-pack,version,--exec-path, root no-args exit behavior) plus unit tests. - Updates go-git/go-git-fixtures (and x/net indirect) versions to support the new behavior/tests.
Reviewed changes
Copilot reviewed 23 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Adds conformance target to run the harness. |
| go.mod | Bumps go-git/go-git-fixtures versions; updates x/net indirect. |
| go.sum | Updates dependency sums for the version bumps. |
| conformance/tests.txt | Defines curated upstream test scripts to run. |
| conformance/run.sh | Implements the conformance runner (build gogit, fetch upstream git tests, stub test-tool, run tests, capture TAP). |
| cmd/gogit/main.go | Adds root behavior for conformance (--exec-path, exit code 1 on no subcommand) and sets a version string. |
| cmd/gogit/main_test.go | Adds integration-style tests that execute the built gogit binary. |
| cmd/gogit/version.go | Adds version subcommand with --build-options output. |
| cmd/gogit/version_test.go | Tests version --build-options output. |
| cmd/gogit/init.go | Adds init command (with --template compatibility flag). |
| cmd/gogit/init_test.go | Tests init and ignored --template. |
| cmd/gogit/add.go | Adds add command. |
| cmd/gogit/add_test.go | Tests add behavior. |
| cmd/gogit/commit.go | Adds commit command with env-based identity/date handling. |
| cmd/gogit/commit_test.go | Tests committing with env identity values. |
| cmd/gogit/checkout.go | Adds checkout <tree-ish> -- <pathspec>... restore behavior and directory expansion. |
| cmd/gogit/checkout_test.go | Tests restoring files/dirs and pathspec escape failure. |
| cmd/gogit/checkout_pathspec.go | Implements pathspec resolution relative to worktree root with escape prevention. |
| cmd/gogit/checkout_pathspec_test.go | Unit tests for pathspec resolution. |
| cmd/gogit/cat-file.go | Adds cat-file -e and cat-file --batch-check. |
| cmd/gogit/cat-file_test.go | Tests cat-file existence and batch-check output. |
| cmd/gogit/index-pack.go | Adds index-pack --stdin [--strict] with duplicate detection in strict mode. |
| cmd/gogit/index-pack_test.go | Tests strict/non-strict behavior using constructed pack data. |
| .gitignore | Ignores conformance cache directory. |
| .github/workflows/build.yml | Adds a conformance job (matrix) and an optional go_git_ref workflow input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
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.
Expands the cli featureset mostly so that we can run the same test cases as
git/git, ensuring thatgo-git's behaviour is aligned with upstream.First test suites introduced:
Results:
Thanks @Soph for suggesting this approach. 🙇