Catalogue package had to be merged into the recipe package due to too many circular import errors. Also, use https url for cloning, assume folks don't have ssh setup by default (the whole reason for the refactor).
39 lines
763 B
Go
39 lines
763 B
Go
package git
|
|
|
|
import (
|
|
"path"
|
|
|
|
configPkg "coopcloud.tech/abra/pkg/config"
|
|
"github.com/go-git/go-git/v5"
|
|
"github.com/go-git/go-git/v5/config"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Push pushes the latest changes
|
|
func Push(recipeName string, tags bool) error {
|
|
recipeDir := path.Join(configPkg.RECIPES_DIR, recipeName)
|
|
commitRepo, err := git.PlainOpen(recipeDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := commitRepo.Push(&git.PushOptions{}); err != nil {
|
|
return err
|
|
}
|
|
logrus.Info("git changes pushed")
|
|
|
|
if tags {
|
|
pushOpts := &git.PushOptions{
|
|
RefSpecs: []config.RefSpec{
|
|
config.RefSpec("+refs/tags/*:refs/tags/*"),
|
|
},
|
|
}
|
|
if err := commitRepo.Push(pushOpts); err != nil {
|
|
return err
|
|
}
|
|
logrus.Info("git tags pushed")
|
|
}
|
|
|
|
return nil
|
|
}
|