WIP: feat: translation support
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
See #483
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/leonelquinteros/gotext"
|
||||
)
|
||||
|
||||
// Check if a branch exists in a repo. Use this and not repository.Branch(),
|
||||
@ -63,7 +65,7 @@ func GetDefaultBranch(repo *git.Repository, repoPath string) (plumbing.Reference
|
||||
|
||||
if !HasBranch(repo, "master") {
|
||||
if !HasBranch(repo, "main") {
|
||||
return "", fmt.Errorf("failed to select default branch in %s", repoPath)
|
||||
return "", errors.New(gotext.Get("failed to select default branch in %s", repoPath))
|
||||
}
|
||||
branch = "main"
|
||||
}
|
||||
@ -90,11 +92,11 @@ func CheckoutDefaultBranch(repo *git.Repository, repoPath string) (plumbing.Refe
|
||||
}
|
||||
|
||||
if err := worktree.Checkout(checkOutOpts); err != nil {
|
||||
log.Debugf("failed to check out %s in %s", branch, repoPath)
|
||||
log.Debug(gotext.Get("failed to check out %s in %s", branch, repoPath))
|
||||
return branch, err
|
||||
}
|
||||
|
||||
log.Debugf("successfully checked out %v in %s", branch, repoPath)
|
||||
log.Debug(gotext.Get("successfully checked out %v in %s", branch, repoPath))
|
||||
|
||||
return branch, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user