mirror of
https://gitea.com/gitea/tea.git
synced 2024-12-22 17:15:05 +01:00
58aaa17e7e
``` $ tea issue 230 #230 issue/pull details: show reactions (open) @6543 created 2020-10-22 16:39 since reactions are utf8 now and most terminals too, we can display them nicely :) https://gitea.com/api/v1/repos/gitea/tea/issues/230/reactions -------- 1x 🎉 | 1x 👀 | 1x | 1x 👍 | 1x 👎 | 1x 😆 | 1x 😕 | 1x ❤️ ``` caveats: - reactions are not returned as UTF8 (as was claimed in #230), so they need to be parsed. the library I use doesn't (and can't → ) support all reactions available in gitea - currently only for issues, as reactions for comments mean an additional API request for each comment.. fixes #230 Co-authored-by: Norwin <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/421 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package issues
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
"code.gitea.io/tea/modules/context"
|
|
"code.gitea.io/tea/modules/print"
|
|
"code.gitea.io/tea/modules/utils"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// CmdIssuesClose represents a sub command of issues to close an issue
|
|
var CmdIssuesClose = cli.Command{
|
|
Name: "close",
|
|
Usage: "Change state of an issue to 'closed'",
|
|
Description: `Change state of an issue to 'closed'`,
|
|
ArgsUsage: "<issue index>",
|
|
Action: func(ctx *cli.Context) error {
|
|
var s = gitea.StateClosed
|
|
return editIssueState(ctx, gitea.EditIssueOption{State: &s})
|
|
},
|
|
Flags: flags.AllDefaultFlags,
|
|
}
|
|
|
|
// editIssueState abstracts the arg parsing to edit the given issue
|
|
func editIssueState(cmd *cli.Context, opts gitea.EditIssueOption) error {
|
|
ctx := context.InitCommand(cmd)
|
|
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
|
if ctx.Args().Len() == 0 {
|
|
return fmt.Errorf(ctx.Command.ArgsUsage)
|
|
}
|
|
|
|
index, err := utils.ArgToIndex(ctx.Args().First())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
issue, _, err := ctx.Login.Client().EditIssue(ctx.Owner, ctx.Repo, index, opts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
print.IssueDetails(issue, nil)
|
|
return nil
|
|
}
|