mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-21 18:11:36 +01:00
Prefer origin if there are multiple remotes (#458)
Usually, `origin` is the name of a default remote, which corresponds with upstream. This change improves remote selection when non of `main`, `master` nor `trunk` local branches is present. Co-authored-by: Petr Vaněk <arkamar@atlas.cz> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/458 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: arkamar <arkamar@noreply.gitea.io> Co-committed-by: arkamar <arkamar@noreply.gitea.io>
This commit is contained in:
parent
0e24009fe9
commit
fb3e1f75e9
@ -164,6 +164,11 @@ func contextFromLocalRepo(repoPath, remoteValue string) (*git.TeaRepo, *config.L
|
||||
remoteValue = remote
|
||||
}
|
||||
if len(gitConfig.Remotes) > 1 {
|
||||
// prefer origin if there is multiple remotes
|
||||
_, ok := gitConfig.Remotes["origin"]
|
||||
if ok {
|
||||
remoteValue = "origin"
|
||||
}
|
||||
// if master branch is present, use it as the default remote
|
||||
mainBranches := []string{"main", "master", "trunk"}
|
||||
for _, b := range mainBranches {
|
||||
|
Loading…
Reference in New Issue
Block a user