feat(git): implement Git repository operations #136
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!136
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/git-operations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement the
GitServiceinterface from task #32 onServiceininternal/gitusing go-git v5.19.2:Depth: 1, single branch) including all tags, into a temp directory. Shallow clones prevent disk-space abuse on the server.+refs/*:refs/*) so new tags/branches appear on webhook push.ResolveRevision, which correctly peels annotated tags) and checks out detached.index.htmlexists in the worktree.BasicAuthauth when a token is configured.var _ GitService = (*Service)(nil)compile-time assertion.Dependency: added
github.com/go-git/go-git/v5 v5.19.2and vendored its dependency tree per THWAP policy (vendor grows 79MB → 83MB).Tests: exercise the real go-git SDK against local repositories in
t.TempDir()— clone + asset verification, tag checkout (annotated tag peeled to commit), fetch picking up a newly created tag, missing assets, and unknown refs.Why
Phase 3 task #46 — completes the Forgejo Integration phase. This is the build step used by the webhook receiver (#72) and rollback (#90).
Testing
go mod tidygo mod vendorgo build ./...go vet ./...go test -race ./internal/git/— 5 tests passgofmt -l ./cmd ./internal ./pkgcleangolangci-lint run— 0 issuesBreaking Changes
None.
Notes
depth 1), so older tags not present in the shallow clone are handled by a fresh clone.Closes #42
Closes #43
Closes #44
Closes #45
Closes #46
Review Summary
Verified locally on the PR head (
10ec49e):go build,go vet,go mod verify,gofmt(incl../pkg),golangci-lint runall clean; all 5 git tests pass with-race. Re-ran the full release cross-compile matrix (linux/freebsd/openbsd × amd64/arm64,CGO_ENABLED=0) with the new go-git dependency — all six targets build.Implementation is solid.
Clone(shallow, single-branch, all tags),Fetch(all refs, correctly short-circuitsNoErrAlreadyUpToDate),Checkout(ResolveRevision+ detached checkout, which peels annotated tags — verified byTestCheckoutTag), andVerifyAssetsare all correct. TokenBasicAuthmatches Forgejo's HTTPS auth scheme. The tests exercise the real go-git SDK against local repos, including the fetch-picks-up-new-tag flow.No blocking issues.
Non-blocking observations:
Checkoutclaims tag-or-branch support in the interface doc, but only tag checkout is tested — a branch-checkout test (e.g. afterFetch) would close the gap.Service.CloneURLis only used for theFetcherror message (Clone takescloneURLas an argument) — effectively dead state otherwise. Consider dropping it or using it to make Fetch's error message reliable.VerifyAssetschecks onlyindex.html— fine for now, but subdirectory-rooted sites may need a configurable asset path later.Approving.