forked from toolshed/abra
@ -17,7 +17,7 @@ func Clone(dir, url string) error {
|
||||
logrus.Debugf("'%s' does not exist, attempting to git clone from '%s'", dir, url)
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{URL: url, Tags: git.AllTags})
|
||||
if err != nil {
|
||||
logrus.Debugf("cloning from default branch failed, attempting from main branch")
|
||||
logrus.Debugf("cloning '%s' default branch failed, attempting from main branch", url)
|
||||
_, err := git.PlainClone(dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
@ -45,12 +45,13 @@ func EnsureUpToDate(dir string) error {
|
||||
branch := "master"
|
||||
if _, err := repo.Branch("master"); err != nil {
|
||||
if _, err := repo.Branch("main"); err != nil {
|
||||
logrus.Debugf("failed to select branch in '%s'", dir)
|
||||
return err
|
||||
}
|
||||
branch = "main"
|
||||
}
|
||||
|
||||
logrus.Debugf("choosing '%s' as main git branch for in '%s'", branch, dir)
|
||||
logrus.Debugf("choosing '%s' as main git branch in '%s'", branch, dir)
|
||||
|
||||
worktree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
@ -65,10 +66,11 @@ func EnsureUpToDate(dir string) error {
|
||||
Branch: plumbing.ReferenceName(refName),
|
||||
}
|
||||
if err := worktree.Checkout(checkOutOpts); err != nil {
|
||||
logrus.Debugf("failed to check out '%s' in '%s'", refName, dir)
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("successfully checked out '%s'", branch)
|
||||
logrus.Debugf("successfully checked out '%s' in '%s'", branch, dir)
|
||||
|
||||
remote, err := repo.Remote("origin")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user