push.go

 1package commands
 2
 3import (
 4	"errors"
 5	"github.com/MichaelMure/git-bug/bug"
 6	"github.com/spf13/cobra"
 7)
 8
 9func runPush(cmd *cobra.Command, args []string) error {
10	if len(args) > 1 {
11		return errors.New("Only pushing to one remote at a time is supported")
12	}
13
14	remote := "origin"
15	if len(args) == 1 {
16		remote = args[0]
17	}
18
19	if err := repo.PushRefs(remote, bug.BugsRefPattern+"*"); err != nil {
20		return err
21	}
22	return nil
23}
24
25// showCmd defines the "push" subcommand.
26var pushCmd = &cobra.Command{
27	Use:   "push [<remote>]",
28	Short: "Push bugs update to a git remote",
29	RunE:  runPush,
30}
31
32func init() {
33	RootCmd.AddCommand(pushCmd)
34}