forked from toolshed/abra
refactor: centralise git commit machinery
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
abraFormatter "coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||
"coopcloud.tech/tagcmp"
|
||||
@ -140,15 +141,6 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
}
|
||||
|
||||
if internal.Commit || internal.CommitMessage != "" {
|
||||
commitRepo, err := git.PlainOpen(directory)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
commitWorktree, err := commitRepo.Worktree()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if internal.CommitMessage == "" && !internal.NoInput {
|
||||
prompt := &survey.Input{
|
||||
Message: "commit message",
|
||||
@ -159,21 +151,14 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||
}
|
||||
}
|
||||
|
||||
err = commitWorktree.AddGlob("compose.**yml")
|
||||
if err != nil {
|
||||
if internal.CommitMessage == "" {
|
||||
logrus.Fatal("no commit message specified?")
|
||||
}
|
||||
|
||||
if err := gitPkg.Commit("compose.**yml", internal.CommitMessage, internal.Dry); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Debug("staged compose.**yml for commit")
|
||||
|
||||
if !internal.Dry {
|
||||
_, err = commitWorktree.Commit(internal.CommitMessage, &git.CommitOptions{})
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
logrus.Info("changes commited")
|
||||
} else {
|
||||
logrus.Info("dry run only: NOT committing changes")
|
||||
}
|
||||
}
|
||||
|
||||
repo, err := git.PlainOpen(directory)
|
||||
|
Reference in New Issue
Block a user