forked from plouc/go-gitlab-client
/
rm_project_merged_branches_cmd.go
48 lines (38 loc) · 1.06 KB
/
rm_project_merged_branches_cmd.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
45
46
47
48
package cmd
import (
"fmt"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
func init() {
rmCmd.AddCommand(rmProjectMergedBranchesCmd)
}
var rmProjectMergedBranchesCmd = &cobra.Command{
Use: resourceCmd("project-merged-branches", "project"),
Aliases: []string{"pmb"},
Short: "Remove project merged branches",
RunE: func(cmd *cobra.Command, args []string) error {
ids, err := config.aliasIdsOrArgs(currentAlias, "project", args)
if err != nil {
return err
}
color.Yellow("Removing project merged branch (project id: %s)…", ids["project_id"])
confirmed := confirmAction(
fmt.Sprintf("Are you sure you want to remove project %s merged branches?", ids["project_id"]),
"aborted merged branches removal",
autoConfirmRemoval,
)
if !confirmed {
return nil
}
loader.Start()
message, meta, err := client.RemoveProjectMergedBranches(ids["project_id"])
loader.Stop()
if err != nil {
return err
}
color.Green("✔ Project merged branches were successfully removed: %s", message)
printMeta(meta, false)
return nil
},
}