fix: dont attempt to clone is local repo is there
continuous-integration/drone/push Build is passing Details

See coop-cloud/organising#247.
This commit is contained in:
decentral1se 2021-11-14 22:54:55 +01:00
parent 9122c0a9b8
commit 486a1717e7
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 10 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package recipe
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
@ -95,13 +96,18 @@ func Get(recipeName string) (Recipe, error) {
return Recipe{Name: recipeName, Config: config}, nil
}
// EnsureExists checks whether a recipe has been cloned locally or not.
// EnsureExists ensures that a recipe is locally cloned
func EnsureExists(recipe string) error {
recipeDir := path.Join(config.ABRA_DIR, "apps", strings.ToLower(recipe))
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, recipe)
if err := gitPkg.Clone(recipeDir, url); err != nil {
return err
if _, err := os.Stat(recipeDir); os.IsNotExist(err) {
logrus.Debugf("%s does not exist, attemmpting to clone", recipeDir)
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, recipe)
if err := gitPkg.Clone(recipeDir, url); err != nil {
return err
}
}
return nil
}