Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89164cdc6a |
+12
-3
@@ -8,10 +8,11 @@ import (
|
||||
"os/signal"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
)
|
||||
|
||||
// gitCloneIgnoreErr checks whether we can ignore a git clone error or not.
|
||||
@@ -48,6 +49,7 @@ func Clone(dir, url string) error {
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
log.Debug(i18n.G("git clone: %s", url))
|
||||
|
||||
fmt.Println("here")
|
||||
_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
@@ -56,17 +58,22 @@ func Clone(dir, url string) error {
|
||||
})
|
||||
|
||||
if err != nil && gitCloneIgnoreErr(err) {
|
||||
log.Debug(i18n.G("git clone: %s cloned successfully", dir))
|
||||
fmt.Println("a", err)
|
||||
log.Debug(i18n.G("git clone: %s cloned successfully", url))
|
||||
errCh <- nil
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctx.Err(); err != nil {
|
||||
fmt.Println("b")
|
||||
errCh <- errors.New(i18n.G("git clone %s: cancelled due to interrupt", dir))
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Debug(i18n.G("git clone: main branch failed, attempting master branch"))
|
||||
|
||||
fmt.Println("herehere")
|
||||
_, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
|
||||
URL: url,
|
||||
Tags: git.AllTags,
|
||||
@@ -77,10 +84,12 @@ func Clone(dir, url string) error {
|
||||
if err != nil && gitCloneIgnoreErr(err) {
|
||||
log.Debug(i18n.G("git clone: %s cloned successfully", dir))
|
||||
errCh <- nil
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -8,15 +8,16 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
)
|
||||
|
||||
type EnsureContext struct {
|
||||
@@ -75,7 +76,7 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
|
||||
// EnsureExists ensures that the recipe is locally cloned
|
||||
func (r Recipe) EnsureExists() error {
|
||||
if _, err := os.Stat(r.Dir); os.IsNotExist(err) {
|
||||
if err := gitPkg.Clone(r.Dir, r.GitURL); err != nil {
|
||||
if err := gitPkg.Clone(r.Dir, r.SSHURL); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user