forked from zaquestion/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr_close.go
44 lines (38 loc) · 840 Bytes
/
mr_close.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
42
43
44
package cmd
import (
"fmt"
"log"
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
"github.com/zaquestion/lab/internal/action"
lab "github.com/zaquestion/lab/internal/gitlab"
)
var mrCloseCmd = &cobra.Command{
Use: "close [remote] <id>",
Aliases: []string{"delete"},
Short: "Close merge request",
Long: ``,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
rn, id, err := parseArgs(args)
if err != nil {
log.Fatal(err)
}
p, err := lab.FindProject(rn)
if err != nil {
log.Fatal(err)
}
err = lab.MRClose(p.ID, int(id))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d closed\n", id)
},
}
func init() {
mrCmd.AddCommand(mrCloseCmd)
carapace.Gen(mrCloseCmd).PositionalCompletion(
action.Remotes(),
action.MergeRequests(mrList),
)
}