WIP: implement async recipe cloning
Some checks failed
continuous-integration/drone/push Build is failing

See coop-cloud/organising#159.
This commit is contained in:
2021-09-16 16:28:11 +02:00
parent 754fe81e01
commit e00920643e
2 changed files with 73 additions and 11 deletions

View File

@ -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 {