forked from coop-cloud/abra
parent
299faa1adf
commit
4a245c3e02
|
@ -0,0 +1,14 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// EnsureGitRepo ensures a git repo .git folder exists
|
||||
func EnsureGitRepo(repoPath string) error {
|
||||
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
|
||||
return fmt.Errorf("no .git directory in %s?", repoPath)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -108,6 +108,10 @@ func EnsureExists(recipe string) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := gitPkg.EnsureGitRepo(recipeDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -124,6 +128,10 @@ func EnsureVersion(recipeName, version string) error {
|
|||
return fmt.Errorf("'%s' has locally unstaged changes", recipeName)
|
||||
}
|
||||
|
||||
if err := gitPkg.EnsureGitRepo(recipeDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -184,6 +192,10 @@ func EnsureLatest(recipeName string) error {
|
|||
return fmt.Errorf("'%s' has locally unstaged changes", recipeName)
|
||||
}
|
||||
|
||||
if err := gitPkg.EnsureGitRepo(recipeDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("attempting to open git repository in '%s'", recipeDir)
|
||||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
|
|
Loading…
Reference in New Issue