0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-10-12 14:41:34 +02:00
gitea/modules/git/repo_branch.go
Lunny Xiao 69f5ee970c
Move some functions to gitrepo package (#35543)
Refactor Git command functions to use WithXXX methods instead of
exposing RunOpts.
This change simplifies reuse across gitrepo and improves consistency,
encapsulation, and maintainability of command options.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-07 17:06:51 +08:00

25 lines
632 B
Go

// Copyright 2015 The Gogs Authors. All rights reserved.
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package git
import (
"code.gitea.io/gitea/modules/git/gitcmd"
)
// BranchPrefix base dir of the branch information file store on git
const BranchPrefix = "refs/heads/"
// AddRemote adds a new remote to repository.
func (repo *Repository) AddRemote(name, url string, fetch bool) error {
cmd := gitcmd.NewCommand("remote", "add")
if fetch {
cmd.AddArguments("-f")
}
_, _, err := cmd.AddDynamicArguments(name, url).
WithDir(repo.Path).
RunStdString(repo.Ctx)
return err
}