fix: ensure tags & commits are pushed
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
a7894cbda9
commit
014d32112e
|
@ -236,9 +236,16 @@ A new catalogue copy can be published to the recipes repository by passing the
|
|||
}
|
||||
|
||||
cataloguePath := path.Join(config.ABRA_DIR, "catalogue")
|
||||
if err := gitPkg.Commit(cataloguePath, "**.json", internal.CommitMessage, internal.Dry, internal.Push); err != nil {
|
||||
if err := gitPkg.Commit(cataloguePath, "**.json", internal.CommitMessage, internal.Dry); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if internal.Push {
|
||||
if err := gitPkg.Push(cataloguePath); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -230,7 +230,7 @@ func btoi(b bool) int {
|
|||
func getTagCreateOptions() (git.CreateTagOptions, error) {
|
||||
if internal.TagMessage == "" && !internal.NoInput {
|
||||
prompt := &survey.Input{
|
||||
Message: "git tag message",
|
||||
Message: "git tag message?",
|
||||
Default: "chore: publish new release",
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ func commitRelease(recipe recipe.Recipe) error {
|
|||
|
||||
if internal.CommitMessage == "" && !internal.NoInput && internal.Commit {
|
||||
prompt := &survey.Input{
|
||||
Message: "commit message",
|
||||
Message: "git commit message?",
|
||||
Default: "chore: publish new version",
|
||||
}
|
||||
if err := survey.AskOne(prompt, &internal.CommitMessage); err != nil {
|
||||
|
@ -270,7 +270,7 @@ func commitRelease(recipe recipe.Recipe) error {
|
|||
|
||||
if internal.Commit {
|
||||
repoPath := path.Join(config.APPS_DIR, recipe.Name)
|
||||
if err := gitPkg.Commit(repoPath, "compose.**yml", internal.CommitMessage, internal.Dry, false); err != nil {
|
||||
if err := gitPkg.Commit(repoPath, "compose.**yml", internal.CommitMessage, internal.Dry); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +322,10 @@ func pushRelease(tagString string, repo *git.Repository) error {
|
|||
}
|
||||
|
||||
if internal.Push {
|
||||
if err := repo.Push(&git.PushOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tagRef := fmt.Sprintf("+refs/tags/%s:refs/tags/%s", tagString, tagString)
|
||||
pushOpts := &git.PushOptions{
|
||||
RefSpecs: []configPkg.RefSpec{
|
||||
|
@ -331,6 +335,7 @@ func pushRelease(tagString string, repo *git.Repository) error {
|
|||
if err := repo.Push(pushOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Info(fmt.Sprintf("pushed tag %s to remote", tagString))
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
// Commit runs a git commit
|
||||
func Commit(repoPath, glob, commitMessage string, dryRun, push bool) error {
|
||||
func Commit(repoPath, glob, commitMessage string, dryRun bool) error {
|
||||
if commitMessage == "" {
|
||||
return fmt.Errorf("no commit message specified?")
|
||||
}
|
||||
|
@ -52,14 +52,5 @@ func Commit(repoPath, glob, commitMessage string, dryRun, push bool) error {
|
|||
logrus.Info("dry run: no changes commited")
|
||||
}
|
||||
|
||||
if !dryRun && push {
|
||||
if err := commitRepo.Push(&git.PushOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Info("changes pushed")
|
||||
} else {
|
||||
logrus.Info("dry run: no changes pushed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Push pushes the latest changes
|
||||
func Push(repoPath string) error {
|
||||
commitRepo, err := git.PlainOpen(repoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := commitRepo.Push(&git.PushOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Info("changes pushed")
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue