0
0
forked from toolshed/abra

feat: diff on release flow

Also, don't commit unstaged files.
This commit is contained in:
2023-10-15 13:39:04 +02:00
parent f96bf9a8ac
commit 7f7f7224c6
8 changed files with 107 additions and 38 deletions

View File

@ -1,29 +1,16 @@
package recipe
import (
"fmt"
"os/exec"
"path"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/config"
gitPkg "coopcloud.tech/abra/pkg/git"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
// getGitDiffArgs builds the `git diff` invocation args
func getGitDiffArgs(repoPath string) []string {
return []string{
"-C",
repoPath,
"--no-pager",
"-c",
"color.diff=always",
"diff",
}
}
var recipeDiffCommand = cli.Command{
Name: "diff",
Usage: "Show unstaged changes in recipe config",
@ -43,19 +30,11 @@ var recipeDiffCommand = cli.Command{
internal.ValidateRecipe(c)
}
_, err := exec.LookPath("git")
if err != nil {
logrus.Fatal("unable to locate 'git' command?")
}
gitDiffArgs := getGitDiffArgs(path.Join(config.RECIPES_DIR, recipeName))
diff, err := exec.Command("git", gitDiffArgs...).Output()
if err != nil {
recipeDir := path.Join(config.RECIPES_DIR, recipeName)
if err := gitPkg.DiffUnstaged(recipeDir); err != nil {
logrus.Fatal(err)
}
fmt.Print(string(diff))
return nil
},
}