mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-16 08:02:17 +09:00
Since https://github.com/go-gitea/gitea/pull/39607, creating a PR fetches the head commit into the base repo. Gitea's gitconfig sets `fetch.writeCommitGraph=true`, so that fetch also writes a commit-graph and fails with exit 128 when a stale `commit-graph-chain.lock` exists. This adds `--no-write-commit-graph`, the only part of https://github.com/go-gitea/gitea/pull/39583 that v28 needs. Its other flags need git 2.29, while v28 supports git 2.25. Fixes https://github.com/go-gitea/gitea/issues/39795 This PR was written with Claude. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/modules/git/gitcmd"
|
|
"gitea.dev/modules/git/gitrepo"
|
|
)
|
|
|
|
// FetchRemoteCommit fetches a specific commit and its related objects from a remote
|
|
// repository into the managed repository.
|
|
//
|
|
// If no reference (branch, tag, or other ref) points to the fetched commit, it will
|
|
// be treated as unreachable and cleaned up by `git gc` after the default prune
|
|
// expiration period (2 weeks). Ref: https://www.kernel.org/pub/software/scm/git/docs/git-gc.html
|
|
//
|
|
// This behavior is sufficient for temporary operations, such as determining the
|
|
// merge base between commits.
|
|
func FetchRemoteCommit(ctx context.Context, repo, remoteRepo RepositoryFacade, commitID string) error {
|
|
return LockWriteAndDo(ctx, repo, func(ctx context.Context) error {
|
|
return gitcmd.NewCommand("fetch", "--no-tags", "--no-write-commit-graph").
|
|
AddDynamicArguments(gitrepo.RepoLocalPath(remoteRepo)).
|
|
AddDynamicArguments(commitID).
|
|
WithRepo(repo).Run(ctx)
|
|
})
|
|
}
|