forked from toolshed/abra
fix: get branch is now more robust
This commit is contained in:
@ -15,6 +15,7 @@ import (
|
||||
"coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/abra/pkg/web"
|
||||
"github.com/docker/distribution/reference"
|
||||
@ -600,20 +601,15 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
return versions, err
|
||||
}
|
||||
|
||||
branch := "master"
|
||||
if _, err := repo.Branch("master"); err != nil {
|
||||
if _, err := repo.Branch("main"); err != nil {
|
||||
logrus.Debugf("failed to select branch in %s", recipeDir)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
branch = "main"
|
||||
branch, err := gitPkg.GetCurrentBranch(repo)
|
||||
if err != nil {
|
||||
return versions, err
|
||||
}
|
||||
|
||||
refName := fmt.Sprintf("refs/heads/%s", branch)
|
||||
checkOutOpts := &git.CheckoutOptions{
|
||||
Create: false,
|
||||
Force: true,
|
||||
Branch: plumbing.ReferenceName(refName),
|
||||
Branch: plumbing.ReferenceName(branch),
|
||||
}
|
||||
if err := worktree.Checkout(checkOutOpts); err != nil {
|
||||
logrus.Debugf("failed to check out %s in %s", branch, recipeDir)
|
||||
|
Reference in New Issue
Block a user