forked from toolshed/abra
fix: ensure tags & commits are pushed
This commit is contained in:
@ -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
|
||||
}
|
||||
|
22
pkg/git/push.go
Normal file
22
pkg/git/push.go
Normal file
@ -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
|
||||
}
|
Reference in New Issue
Block a user