Skip to content

Commit

Permalink
support default branch "main"
Browse files Browse the repository at this point in the history
  • Loading branch information
FLuzzi-csw committed Feb 22, 2024
1 parent 69b428b commit 1943093
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions core/gitWrapper/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ func initSubmodules(dep models.Dependency, repository *git.Repository) {

}

func GetMaster(repository *git.Repository) *config.Branch {

if branch, err := repository.Branch("master"); err != nil {
return nil
} else {
return branch
func GetMaster(repository *git.Repository) (*config.Branch, error) {
branch, err := repository.Branch("master")
if err != nil {
branch, err = repository.Branch("main")
}
return branch, err
}

func GetVersions(repository *git.Repository) []*plumbing.Reference {
Expand Down
2 changes: 1 addition & 1 deletion core/installer/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func ensureModules(rootLock models.PackageLock, pkg *models.Package, deps []mode
worktree, _ := repository.Worktree()

if !hasMatch {
if masterReference := gitWrapper.GetMaster(repository); masterReference != nil {
if masterReference, err := gitWrapper.GetMaster(repository); err == nil {
referenceName = plumbing.NewBranchReferenceName(masterReference.Name)
}
} else {
Expand Down

0 comments on commit 1943093

Please sign in to comment.