forked from coop-cloud/abra
feat: add a flag to commit your changes before creating a tag
This commit is contained in:
parent
2076c566bb
commit
c4c76f4848
@ -10,6 +10,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/tagcmp"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
@ -56,6 +57,22 @@ var PatchFlag = &cli.BoolFlag{
|
||||
Destination: &Patch,
|
||||
}
|
||||
|
||||
var CommitMessage string
|
||||
var CommitMessageFlag = &cli.StringFlag{
|
||||
Name: "commit-message",
|
||||
Usage: "commit message",
|
||||
Aliases: []string{"cm"},
|
||||
Destination: &CommitMessage,
|
||||
}
|
||||
|
||||
var Commit bool
|
||||
var CommitFlag = &cli.BoolFlag{
|
||||
Name: "commit",
|
||||
Value: false,
|
||||
Aliases: []string{"c"},
|
||||
Destination: &Commit,
|
||||
}
|
||||
|
||||
var recipeReleaseCommand = &cli.Command{
|
||||
Name: "release",
|
||||
Usage: "tag a recipe",
|
||||
@ -67,6 +84,8 @@ var recipeReleaseCommand = &cli.Command{
|
||||
MinorFlag,
|
||||
MajorFlag,
|
||||
PushFlag,
|
||||
CommitFlag,
|
||||
CommitMessageFlag,
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
@ -79,6 +98,29 @@ var recipeReleaseCommand = &cli.Command{
|
||||
logrus.Fatal("Main app's version is empty.")
|
||||
}
|
||||
|
||||
if Commit || (CommitMessage != "") {
|
||||
commitRepo, err := git.PlainOpen(directory)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
commitWorktree, err := commitRepo.Worktree()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if CommitMessage == "" {
|
||||
prompt := &survey.Input{
|
||||
Message: "commit message",
|
||||
}
|
||||
survey.AskOne(prompt, &CommitMessage)
|
||||
}
|
||||
_, err = commitWorktree.Commit(CommitMessage, &git.CommitOptions{})
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Info("changes commited")
|
||||
}
|
||||
|
||||
repo, err := git.PlainOpen(directory)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user