fix: git push hook post receive - #38089
Merged
Merged
Conversation
wxiaoguang
force-pushed
the
fix-git-push
branch
5 times, most recently
from
June 12, 2026 11:51
9b820e2 to
347e0bd
Compare
Merged
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes and hardens the git push / hook post-receive pipeline, with a focus on synchronizing branch/default-branch state between Git and the database, and making repo UI routes behave better when the default branch is missing.
Changes:
- Fix post-receive processing by refactoring
HookPostReceiveinto smaller helpers, improving error responses, and syncing branches/default branch. - Update push/branch handling so default-branch-related cache/license updates occur correctly and branches pages can render without a default branch.
- Simplify hook result payloads and improve hook CLI batching/output handling (including replacing custom discard writer with
io.Discard).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| services/repository/push.go | Sync default-branch-related cache/license update behavior during pushes. |
| services/repository/branch.go | Allow loading branches even when the default branch row is missing in DB. |
| services/context/repo.go | Adjust default-branch commit resolution behavior during repo context initialization. |
| services/context/private.go | Add PrivateError helper for consistent internal API error responses. |
| routers/web/repo/branch.go | Make branches page tolerate missing default branch by using an optional default branch. |
| routers/private/hook_post_receive.go | Refactor and harden post-receive: sync branches/default branch, unify error responses, simplify trailer logic. |
| routers/private/hook_post_receive_test.go | Update test to call the renamed/refactored PR-merge handler. |
| modules/private/hook.go | Simplify HookPostReceiveResult response structure. |
| modules/git/repo_commit.go | Change branch/tag commit resolution to use ref names (tag resolution currently incorrect). |
| cmd/hook.go | Fix delayed writer usage and batch hook-post-receive calls; use io.Discard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wxiaoguang
force-pushed
the
fix-git-push
branch
3 times, most recently
from
June 12, 2026 12:21
7b970fd to
cdc7620
Compare
Contributor
Author
bircni
approved these changes
Jun 12, 2026
lunny
approved these changes
Jun 13, 2026
wxiaoguang
enabled auto-merge (squash)
June 13, 2026 04:40
zeekay
pushed a commit
to hanzoai/forge
that referenced
this pull request
Jul 26, 2026
* fix incorrect delayWriter call (there is already a defer call) * split HookPostReceive into small functions * fix incorrect HookPostReceiveResult response for errors * fix incorrect AddRepoToLicenseUpdaterQueue call * make sure repo home and branches page can work without default branch * make sure default branch is always synchronized between database and git repo, and fix FIXME
richmahn
added a commit
to unfoldingWord/dcs
that referenced
this pull request
Aug 18, 2026
…s/v1.27 Conflict: routers/private/default_branch.go was deleted upstream by go-gitea/gitea#38965 (backport of #38964, "remove dead code SetDefaultBranch"). Accepted the deletion: the DCS ProcessDoor43MetadataForRepo() call it held had been unreachable since go-gitea/gitea#38089 removed the last caller of the internal set-default-branch endpoint, and both default-branch-change paths are already covered by the metadataNotifier ChangeDefaultBranch and PushCommits hooks. Dropped the stale row from dcs-customizations.md. Assisted-by: Claude Code:claude-opus-5[1m]
richmahn
added a commit
to unfoldingWord/dcs
that referenced
this pull request
Aug 18, 2026
Conflicts and DCS adaptations for this upstream sync: routers/private/default_branch.go: deleted upstream by go-gitea/gitea#38964 ("remove dead code SetDefaultBranch"). Accepted the deletion. The DCS ProcessDoor43MetadataForRepo() call it held had been unreachable since go-gitea/gitea#38089 removed the last caller of the internal set-default-branch endpoint; both default-branch-change paths are already covered by the metadataNotifier ChangeDefaultBranch and PushCommits hooks. Dropped the stale row from dcs-customizations.md. modules/gitrepo -> modules/git/gitrepo (go-gitea/gitea#38543), with OpenRepository/UpdateRef/RemoveRef moving to modules/git and OpenRepository gaining a leading ctx: adapted services/gitref, services/convert2sb, services/repository/sbarchiver, services/door43metadata and services/door43healthcheck. Repository.RepoPath() and repo_model.RepoPath() removed (go-gitea/gitea#38601): replaced with gitrepo.RepoLocalPath(x.CodeStorageRepo()). util.RemoveAll renamed to util.RemoveAllWithRetry (go-gitea/gitea#38588). Form validation refactor (go-gitea/gitea#38832, #38873): the DCS Door43Metadata forms did only default validation, so they now embed middleware.FormDefaultValidator instead of defining a Validate method. web.GetForm and cron RegisterTaskFatal became generic: updated the DCS git-ref handlers and DCS cron task registrations. language_stats_gogit.go deleted upstream (gogit build variant removed); git carried the DCS every-file-type language stats into the surviving language_stats_get.go via rename detection. Upstream enabled the forcetypeassert linter, which surfaced 28 unchecked type assertions in pre-existing DCS manifest and langnames parsing. Added modules/dcs/mapvalue.go with checked map accessors and used them throughout, so malformed user-supplied manifest.yaml or langnames data yields zero values instead of panicking. Verified: go build ./..., go vet ./..., golangci-lint run ./... (0 issues), lint-spell, lint-templates, generate-swagger (DCS git-ref endpoints and the new in-catalog/tag_filter params intact, no dangling $refs). Assisted-by: Claude Code:claude-opus-5[1m]
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Uh oh!
There was an error while loading. Please reload this page.