forked from toolshed/abra
refactor!: simplifying publish logic
This commit is contained in:
@ -47,9 +47,9 @@ func Commit(repoPath, glob, commitMessage string, dryRun bool) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Info("changes commited")
|
||||
logrus.Debug("git changes commited")
|
||||
} else {
|
||||
logrus.Info("dry run: no changes commited")
|
||||
logrus.Debug("dry run: no changes commited")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
// Push pushes the latest changes & optionally tags to the default remote
|
||||
func Push(repoDir string, remote string, tags bool, dryRun bool) error {
|
||||
if dryRun {
|
||||
logrus.Infof("dry run: no git changes pushed in %s", repoDir)
|
||||
logrus.Debugf("dry run: no git changes pushed in %s", repoDir)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ func Push(repoDir string, remote string, tags bool, dryRun bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Info("git changes pushed")
|
||||
logrus.Debugf("git changes pushed")
|
||||
|
||||
if tags {
|
||||
opts.RefSpecs = append(opts.RefSpecs, config.RefSpec("+refs/tags/*:refs/tags/*"))
|
||||
@ -36,7 +36,7 @@ func Push(repoDir string, remote string, tags bool, dryRun bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Info("git tags pushed")
|
||||
logrus.Debugf("git tags pushed")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -34,10 +34,8 @@ func GetRecipeHead(recipeName string) (*plumbing.Reference, error) {
|
||||
}
|
||||
|
||||
// IsClean checks if a repo has unstaged changes
|
||||
func IsClean(recipeName string) (bool, error) {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
repo, err := git.PlainOpen(recipeDir)
|
||||
func IsClean(repoPath string) (bool, error) {
|
||||
repo, err := git.PlainOpen(repoPath)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -62,9 +60,9 @@ func IsClean(recipeName string) (bool, error) {
|
||||
}
|
||||
|
||||
if status.String() != "" {
|
||||
logrus.Debugf("discovered git status for %s repository: %s", recipeName, status.String())
|
||||
logrus.Debugf("discovered git status in %s: %s", repoPath, status.String())
|
||||
} else {
|
||||
logrus.Debugf("discovered clean git status for %s repository", recipeName)
|
||||
logrus.Debugf("discovered clean git status in %s", repoPath)
|
||||
}
|
||||
|
||||
return status.IsClean(), nil
|
||||
|
@ -260,7 +260,7 @@ func EnsureExists(recipeName string) error {
|
||||
func EnsureVersion(recipeName, version string) error {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipeName)
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -325,7 +325,7 @@ func EnsureVersion(recipeName, version string) error {
|
||||
func EnsureLatest(recipeName string) error {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipeName)
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -380,7 +380,8 @@ func ChaosVersion(recipeName string) (string, error) {
|
||||
|
||||
version = head.String()[:8]
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipeName)
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
if err != nil {
|
||||
return version, err
|
||||
}
|
||||
@ -556,7 +557,7 @@ func GetStringInBetween(recipeName, str, start, end string) (result string, err
|
||||
func EnsureUpToDate(recipeName string) error {
|
||||
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipeName)
|
||||
isClean, err := gitPkg.IsClean(recipeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user