refactor: try the meta for default branch too
Sometimes the Branch(...) call gets confused with state in the repository. Its more robust to use the default value we get from gitea. See coop-cloud/organising#299.
This commit is contained in:
parent
09ac74d205
commit
2fbdcfb958
@ -615,11 +615,15 @@ func EnsureUpToDate(recipeName string) error {
|
||||
func GetDefaultBranch(repo *git.Repository, recipeName string) (plumbing.ReferenceName, error) {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
meta, _ := GetRecipeMeta(recipeName)
|
||||
if meta.DefaultBranch != "" {
|
||||
return plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", meta.DefaultBranch)), nil
|
||||
}
|
||||
|
||||
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)
|
||||
return "", err
|
||||
return "", fmt.Errorf("failed to select default branch in %s", recipeDir)
|
||||
}
|
||||
branch = "main"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user