mirror of https://gitlab.com/gitlab-org/cli.git
Compare commits
2 Commits
148864a125
...
43386c0110
Author | SHA1 | Date |
---|---|---|
Erran Carey | 43386c0110 | |
Erran Carey | 4a0e82370c |
13
api/issue.go
13
api/issue.go
|
@ -129,6 +129,19 @@ var DeleteIssue = func(client *gitlab.Client, projectID interface{}, issueID int
|
|||
return nil
|
||||
}
|
||||
|
||||
var CreateIssueAwardEmoji = func(client *gitlab.Client, projectID interface{}, mrID int, opts *gitlab.CreateAwardEmojiOptions) (*gitlab.AwardEmoji, error) {
|
||||
if client == nil {
|
||||
client = apiClient.Lab()
|
||||
}
|
||||
|
||||
emoji, _, err := client.AwardEmoji.CreateIssueAwardEmoji(projectID, mrID, opts)
|
||||
if err != nil {
|
||||
return emoji, err
|
||||
}
|
||||
|
||||
return emoji, nil
|
||||
}
|
||||
|
||||
var CreateIssueNote = func(client *gitlab.Client, projectID interface{}, mrID int, opts *gitlab.CreateIssueNoteOptions) (*gitlab.Note, error) {
|
||||
if client == nil {
|
||||
client = apiClient.Lab()
|
||||
|
|
|
@ -195,6 +195,19 @@ var GetMRLinkedIssues = func(client *gitlab.Client, projectID interface{}, mrID
|
|||
return mrIssues, nil
|
||||
}
|
||||
|
||||
var CreateMRAwardEmoji = func(client *gitlab.Client, projectID interface{}, mrID int, opts *gitlab.CreateAwardEmojiOptions) (*gitlab.AwardEmoji, error) {
|
||||
if client == nil {
|
||||
client = apiClient.Lab()
|
||||
}
|
||||
|
||||
emoji, _, err := client.AwardEmoji.CreateMergeRequestAwardEmoji(projectID, mrID, opts)
|
||||
if err != nil {
|
||||
return emoji, err
|
||||
}
|
||||
|
||||
return emoji, nil
|
||||
}
|
||||
|
||||
var CreateMRNote = func(client *gitlab.Client, projectID interface{}, mrID int, opts *gitlab.CreateMergeRequestNoteOptions) (*gitlab.Note, error) {
|
||||
if client == nil {
|
||||
client = apiClient.Lab()
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package award_emoji
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gitlab.com/gitlab-org/cli/commands/issue/issueutils"
|
||||
|
||||
"gitlab.com/gitlab-org/cli/api"
|
||||
"gitlab.com/gitlab-org/cli/commands/cmdutils"
|
||||
"gitlab.com/gitlab-org/cli/pkg/utils"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
gitlab "github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
func NewCmdAwardEmoji(f *cmdutils.Factory) *cobra.Command {
|
||||
issueAwardEmojiCreateCmd := &cobra.Command{
|
||||
Use: "award-emoji <issue-id>",
|
||||
Aliases: []string{"comment"},
|
||||
Short: "Award an emoji to an issue on GitLab",
|
||||
Long: ``,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
out := f.IO.StdOut
|
||||
|
||||
apiClient, err := f.HttpClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
issue, repo, err := issueutils.IssueFromArg(apiClient, f.BaseRepo, args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name, _ := cmd.Flags().GetString("name")
|
||||
|
||||
if name == "" {
|
||||
name = utils.Editor(utils.EditorOptions{
|
||||
Label: "Award Emoji Name:",
|
||||
Help: "Enter the award emoji's name. ",
|
||||
FileName: "ISSUE_AWARD_EMOJI_EDITMSG",
|
||||
})
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
return errors.New("aborted... Award Emoji name is empty")
|
||||
}
|
||||
|
||||
emoji, err := api.CreateIssueAwardEmoji(apiClient, repo.FullName(), issue.IID, &gitlab.CreateAwardEmojiOptions{
|
||||
Name: name,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "Added award emoji %d\n", emoji.AwardableID)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
issueAwardEmojiCreateCmd.Flags().StringP("name", "n", "", "Award Emoji name")
|
||||
|
||||
return issueAwardEmojiCreateCmd
|
||||
}
|
|
@ -3,6 +3,7 @@ package issue
|
|||
import (
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"gitlab.com/gitlab-org/cli/commands/cmdutils"
|
||||
issueAwardEmojiCmd "gitlab.com/gitlab-org/cli/commands/issue/award-emoji"
|
||||
issueBoardCmd "gitlab.com/gitlab-org/cli/commands/issue/board"
|
||||
issueCloseCmd "gitlab.com/gitlab-org/cli/commands/issue/close"
|
||||
issueCreateCmd "gitlab.com/gitlab-org/cli/commands/issue/create"
|
||||
|
@ -40,6 +41,7 @@ func NewCmdIssue(f *cmdutils.Factory) *cobra.Command {
|
|||
|
||||
cmdutils.EnableRepoOverride(issueCmd, f)
|
||||
|
||||
issueCmd.AddCommand(issueAwardEmojiCmd.NewCmdAwardEmoji(f))
|
||||
issueCmd.AddCommand(issueCloseCmd.NewCmdClose(f))
|
||||
issueCmd.AddCommand(issueBoardCmd.NewCmdBoard(f))
|
||||
issueCmd.AddCommand(issueCreateCmd.NewCmdCreate(f))
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package award_emoji
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gitlab.com/gitlab-org/cli/commands/mr/mrutils"
|
||||
|
||||
"gitlab.com/gitlab-org/cli/api"
|
||||
"gitlab.com/gitlab-org/cli/commands/cmdutils"
|
||||
"gitlab.com/gitlab-org/cli/pkg/utils"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
gitlab "github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
func NewCmdAwardEmoji(f *cmdutils.Factory) *cobra.Command {
|
||||
mrAwardEmojiCreateCmd := &cobra.Command{
|
||||
Use: "award-emoji <id>",
|
||||
Aliases: []string{"comment"},
|
||||
Short: "Award an emoji to an merge request on GitLab",
|
||||
Long: ``,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
out := f.IO.StdOut
|
||||
|
||||
apiClient, err := f.HttpClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mr, repo, err := mrutils.MRFromArgs(f, args, "any")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name, _ := cmd.Flags().GetString("name")
|
||||
|
||||
if name == "" {
|
||||
name = utils.Editor(utils.EditorOptions{
|
||||
Label: "Award Emoji Name:",
|
||||
Help: "Enter the award emoji's name. ",
|
||||
FileName: "MR_AWARD_EMOJI_EDITMSG",
|
||||
})
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
return errors.New("aborted... Award Emoji name is empty")
|
||||
}
|
||||
|
||||
emoji, err := api.CreateMRAwardEmoji(apiClient, repo.FullName(), mr.IID, &gitlab.CreateAwardEmojiOptions{
|
||||
Name: name,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "Added award emoji %d\n", emoji.AwardableID)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
mrAwardEmojiCreateCmd.Flags().StringP("name", "n", "", "Award Emoji name")
|
||||
|
||||
return mrAwardEmojiCreateCmd
|
||||
}
|
|
@ -5,6 +5,7 @@ import (
|
|||
"gitlab.com/gitlab-org/cli/commands/cmdutils"
|
||||
mrApproveCmd "gitlab.com/gitlab-org/cli/commands/mr/approve"
|
||||
mrApproversCmd "gitlab.com/gitlab-org/cli/commands/mr/approvers"
|
||||
mrAwardEmojiCmd "gitlab.com/gitlab-org/cli/commands/mr/award-emoji"
|
||||
mrCheckoutCmd "gitlab.com/gitlab-org/cli/commands/mr/checkout"
|
||||
mrCloseCmd "gitlab.com/gitlab-org/cli/commands/mr/close"
|
||||
mrCreateCmd "gitlab.com/gitlab-org/cli/commands/mr/create"
|
||||
|
@ -50,6 +51,7 @@ func NewCmdMR(f *cmdutils.Factory) *cobra.Command {
|
|||
|
||||
mrCmd.AddCommand(mrApproveCmd.NewCmdApprove(f))
|
||||
mrCmd.AddCommand(mrApproversCmd.NewCmdApprovers(f))
|
||||
mrCmd.AddCommand(mrAwardEmojiCmd.NewCmdAwardEmoji(f))
|
||||
mrCmd.AddCommand(mrCheckoutCmd.NewCmdCheckout(f))
|
||||
mrCmd.AddCommand(mrCloseCmd.NewCmdClose(f))
|
||||
mrCmd.AddCommand(mrCreateCmd.NewCmdCreate(f, nil))
|
||||
|
|
Loading…
Reference in New Issue