0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-21 08:50:51 +02:00
This commit is contained in:
Lunny Xiao 2026-01-13 19:12:52 -08:00
parent e4a568141b
commit 75c62ce562
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -7,7 +7,6 @@ import (
"context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/globallock"
)
// PushToExternal pushes a managed repository to an external remote.
@ -17,16 +16,12 @@ func PushToExternal(ctx context.Context, repo Repository, opts git.PushOptions)
// Push pushes from one managed repository to another managed repository.
func Push(ctx context.Context, fromRepo, toRepo Repository, opts git.PushOptions) error {
return globallock.LockAndDo(ctx, getRepoWriteLockKey(toRepo.RelativePath()), func(ctx context.Context) error {
opts.Remote = repoPath(toRepo)
return git.Push(ctx, repoPath(fromRepo), opts)
})
opts.Remote = repoPath(toRepo)
return git.Push(ctx, repoPath(fromRepo), opts)
}
// PushFromLocal pushes from a local path to a managed repository.
func PushFromLocal(ctx context.Context, fromLocalPath string, toRepo Repository, opts git.PushOptions) error {
return globallock.LockAndDo(ctx, getRepoWriteLockKey(toRepo.RelativePath()), func(ctx context.Context) error {
opts.Remote = repoPath(toRepo)
return git.Push(ctx, fromLocalPath, opts)
})
opts.Remote = repoPath(toRepo)
return git.Push(ctx, fromLocalPath, opts)
}