mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-21 22:05:17 +02:00
before: gitrepo vs git packages after: git package fully handle all git operations by the way, use `WithRepo(repo)` instead of `WithDir(repo.Path)` to hide path details. benefits: 1. remove all unnecessary wrappers, developers no need to struggle with "which package should be used" 2. simplify code, RepositoryFacade can (will) be used everywhere, all "path" details are (will be) hidden
28 lines
922 B
Go
28 lines
922 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/modules/git/gitcmd"
|
|
)
|
|
|
|
// PushToExternal pushes a managed repository to an external remote.
|
|
func PushToExternal(ctx context.Context, repo RepositoryFacade, opts PushOptions) error {
|
|
return Push(ctx, gitcmd.RepoLocalPath(repo), opts)
|
|
}
|
|
|
|
// PushManaged pushes from one managed repository to another managed repository.
|
|
func PushManaged(ctx context.Context, fromRepo, toRepo RepositoryFacade, opts PushOptions) error {
|
|
opts.Remote = gitcmd.RepoLocalPath(toRepo)
|
|
return Push(ctx, gitcmd.RepoLocalPath(fromRepo), opts)
|
|
}
|
|
|
|
// PushFromLocal pushes from a local path to a managed repository.
|
|
func PushFromLocal(ctx context.Context, fromLocalPath string, toRepo RepositoryFacade, opts PushOptions) error {
|
|
opts.Remote = gitcmd.RepoLocalPath(toRepo)
|
|
return Push(ctx, fromLocalPath, opts)
|
|
}
|