Files
zeekay 63203f75c2 Take inbound syncs through the push path
The inbound sync moved refs with update-ref, so none of what a push
runs applied: no protected branches or tags, approvals, status checks,
signatures or quota, no Actions, pull request checks or issue
references. It also moved tags, resurrected branches deleted on the
forge, and raised a notice per webhook.

Inbound now fetches into a hidden refs/upstream namespace, records the
tips before and after, and acts only on names whose tip changed. Each
is one non-force git push from the repo to itself, under the pushing
environment of [mirror] SYNC_USER, so pre-receive and post-receive run
as for a person. No sync user, or one without write, or an archived
repo, and nothing runs. A ref the forge refuses is reported and looked
at again next time. Tags are create-only. A notice is raised once per
distinct (ref, forge sha, upstream sha). The first sync of a repo with
content only records upstream, since GitHub keeps every branch the
forge deleted. refs/upstream is hidden from clients and closed to
pushes in pre-receive.

/v1/sync acts only on push, create and delete events, reads up to 25
MiB, and fails a database error rather than calling it "no mirror".
The scheduled sweep also queues an inbound sync for each due push
mirror to GitHub, so a missed event heals. The URL matcher moves to
services/mirror and rejects ports, queries and odd paths.

Push out takes no lock again, so a clone's inline pull never waits on
it, and its LFS upload is bounded by the mirror timeout. The reconcile
and announce split of the pull mirror is undone; only fetchableRemote
is shared.

Claude-Session: https://claude.ai/code/session_015XYKLo5aivJF2MHLneVUYc
2026-11-08 12:43:50 -08:00

20 lines
557 B
Go

// Copyright 2026 Hanzo AI, Inc. All rights reserved.
// SPDX-License-Identifier: MIT
package gitrepo
import (
"context"
"github.com/hanzoai/git/modules/git/gitcmd"
)
func UpdateRef(ctx context.Context, repo Repository, refName, newCommitID string) error {
return RunCmd(ctx, repo, gitcmd.NewCommand("update-ref").AddDynamicArguments(refName, newCommitID))
}
func RemoveRef(ctx context.Context, repo Repository, refName string) error {
return RunCmd(ctx, repo, gitcmd.NewCommand("update-ref", "--no-deref", "-d").
AddDynamicArguments(refName))
}