Skip to content

Commit

Permalink
Merge pull request #157 from FLuzzi-csw/fluzzi/support_default_main
Browse files Browse the repository at this point in the history
support default branch "main"
  • Loading branch information
viniciussanchez authored Feb 26, 2024
2 parents 69b428b + 1943093 commit 19183e1
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 19183e1

Please sign in to comment.