(cmd *cobra.Command, branch string)
| 70 | } |
| 71 | |
| 72 | func runProtectBranch(cmd *cobra.Command, branch string) error { |
| 73 | opts := new(gitlab.ProtectBranchOptions) |
| 74 | if cmd.Flag("dev-can-push").Changed { |
| 75 | opts.DevelopersCanPush = gitlab.Bool(getFlagBool(cmd, "dev-can-push")) |
| 76 | } |
| 77 | if cmd.Flag("dev-can-merge").Changed { |
| 78 | opts.DevelopersCanMerge = gitlab.Bool(getFlagBool(cmd, "dev-can-merge")) |
| 79 | } |
| 80 | branchInfo, err := protectBranch(branch, getFlagString(cmd, "project"), opts) |
| 81 | if err != nil { |
| 82 | return err |
| 83 | } |
| 84 | printBranchOut(getFlagString(cmd, "out"), branchInfo) |
| 85 | return nil |
| 86 | } |
| 87 | |
| 88 | func protectBranch(branch, project string, opts *gitlab.ProtectBranchOptions) (*gitlab.Branch, error) { |
| 89 | git, err := newGitlabClient() |
no test coverage detected