forked from coop-cloud/abra
fix: dont attempt to clone is local repo is there
See coop-cloud/organising#247.
This commit is contained in:
parent
9122c0a9b8
commit
486a1717e7
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue