feat: allow passing a comment when closing an issue
This commit is contained in:
parent
fc699e9718
commit
900bd4ea97
3 changed files with 74 additions and 0 deletions
11
cmd/issue.go
11
cmd/issue.go
|
|
@ -87,6 +87,7 @@ func init() {
|
|||
issueCommentCmd.Flags().StringP("body", "b", "", "Comment body")
|
||||
|
||||
issueCloseCmd.Flags().StringP("repo", "R", "", "Repository in owner/name format")
|
||||
issueCloseCmd.Flags().StringP("comment", "c", "", "Comment body to add before closing")
|
||||
|
||||
issueEditCmd.Flags().StringP("repo", "R", "", "Repository in owner/name format")
|
||||
issueEditCmd.Flags().StringP("title", "t", "", "New title for the issue")
|
||||
|
|
@ -281,6 +282,7 @@ func runIssueComment(cmd *cobra.Command, args []string) error {
|
|||
|
||||
func runIssueClose(cmd *cobra.Command, args []string) error {
|
||||
repo, _ := cmd.Flags().GetString("repo")
|
||||
commentBody, _ := cmd.Flags().GetString("comment")
|
||||
issueNumber, err := strconv.ParseInt(args[0], 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid issue number: %w", err)
|
||||
|
|
@ -301,6 +303,15 @@ func runIssueClose(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if commentBody != "" {
|
||||
_, _, err = client.CreateIssueComment(owner, name, issueNumber, gitea.CreateIssueCommentOption{
|
||||
Body: commentBody,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create comment: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
stateClosed := gitea.StateClosed
|
||||
_, _, err = client.EditIssue(owner, name, issueNumber, gitea.EditIssueOption{
|
||||
State: &stateClosed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue