mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
29 lines
1.1 KiB
Go
29 lines
1.1 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package gitrepo
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/git/modules/git/gitcmd"
|
|
"github.com/hanzoai/git/modules/globallock"
|
|
)
|
|
|
|
// 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 Repository, commitID string) error {
|
|
return globallock.LockAndDo(ctx, getRepoWriteLockKey(repo.RelativePath()), func(ctx context.Context) error {
|
|
return RunCmd(ctx, repo, gitcmd.NewCommand("fetch", "--no-tags").
|
|
AddDynamicArguments(repoPath(remoteRepo)).
|
|
AddDynamicArguments(commitID))
|
|
})
|
|
}
|