/
fix.go
41 lines (34 loc) · 959 Bytes
/
fix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cmd
import (
"github.com/meinto/glow"
"github.com/meinto/glow/pkg/cli/cmd/internal/command"
"github.com/meinto/glow/pkg/cli/cmd/internal/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
type FixCommand struct {
command.Service
}
func (cmd *FixCommand) PostSetup(parent command.Service) command.Service {
parent.Add(cmd)
return cmd
}
var fixCmd = SetupFixCommand(RootCmd)
func SetupFixCommand(parent command.Service) command.Service {
return command.Setup(&FixCommand{
&command.Command{
Command: &cobra.Command{
Use: "fix",
Short: "create a fix branch",
Args: cobra.MinimumNArgs(1),
},
Run: func(cmd command.Service, args []string) {
fixName := args[0]
fix, err := glow.NewFix(viper.GetString("author"), fixName)
util.ExitOnError(err)
util.ExitOnError(cmd.GitClient().Create(fix, RootCmdOptions.SkipChecks))
util.ExitOnError(cmd.GitClient().Checkout(fix))
},
},
}, parent)
}