mirror of
https://gitea.com/gitea/tea
synced 2024-11-26 14:13:48 +01:00
issues list can show filtered by owner/org instead of repo too (#550)
close #551 Co-authored-by: Sysoev, Vladimir <vladimir.sysoev@sarov-itc.ru> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/550 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: vsysoev <vsysoev@noreply.gitea.com> Co-committed-by: vsysoev <vsysoev@noreply.gitea.com>
This commit is contained in:
parent
b2d845b8c7
commit
c72c6c0679
@ -71,6 +71,10 @@ var IssueListingFlags = append([]cli.Flag{
|
||||
Name: "mentions",
|
||||
Aliases: []string{"M"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "owner",
|
||||
Aliases: []string{"org"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "from",
|
||||
Aliases: []string{"F"},
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
var issueFieldsFlag = flags.FieldsFlag(print.IssueFields, []string{
|
||||
"index", "title", "state", "author", "milestone", "labels",
|
||||
"index", "title", "state", "author", "milestone", "labels", "owner", "repo",
|
||||
})
|
||||
|
||||
// CmdIssuesList represents a sub command of issues to list issues
|
||||
@ -35,7 +35,6 @@ var CmdIssuesList = cli.Command{
|
||||
// RunIssuesList list issues
|
||||
func RunIssuesList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
|
||||
|
||||
state := gitea.StateOpen
|
||||
switch ctx.String("state") {
|
||||
@ -75,12 +74,17 @@ func RunIssuesList(cmd *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
owner := ctx.Owner
|
||||
if ctx.IsSet("owner") {
|
||||
owner = ctx.String("owner")
|
||||
}
|
||||
|
||||
// ignore error, as we don't do any input validation on these flags
|
||||
labels, _ := flags.LabelFilterFlag.GetValues(cmd)
|
||||
milestones, _ := flags.MilestoneFilterFlag.GetValues(cmd)
|
||||
|
||||
issues, _, err := ctx.Login.Client().ListRepoIssues(ctx.Owner, ctx.Repo, gitea.ListIssueOption{
|
||||
var issues []*gitea.Issue
|
||||
if ctx.Repo != "" {
|
||||
issues, _, err = ctx.Login.Client().ListRepoIssues(owner, ctx.Repo, gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
@ -97,6 +101,26 @@ func RunIssuesList(cmd *cli.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
issues, _, err = ctx.Login.Client().ListIssues(gitea.ListIssueOption{
|
||||
ListOptions: ctx.GetListOptions(),
|
||||
State: state,
|
||||
Type: kind,
|
||||
KeyWord: ctx.String("keyword"),
|
||||
CreatedBy: ctx.String("author"),
|
||||
AssignedBy: ctx.String("assigned-to"),
|
||||
MentionedBy: ctx.String("mentions"),
|
||||
Labels: labels,
|
||||
Milestones: milestones,
|
||||
Since: from,
|
||||
Before: until,
|
||||
Owner: owner,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fields, err := issueFieldsFlag.GetValues(cmd)
|
||||
if err != nil {
|
||||
|
@ -70,6 +70,8 @@ var IssueFields = []string{
|
||||
"milestone",
|
||||
"labels",
|
||||
"comments",
|
||||
"owner",
|
||||
"repo",
|
||||
}
|
||||
|
||||
func printIssues(issues []*gitea.Issue, output string, fields []string) {
|
||||
@ -146,6 +148,10 @@ func (x printableIssue) FormatField(field string, machineReadable bool) string {
|
||||
return strings.Join(assignees, " ")
|
||||
case "comments":
|
||||
return fmt.Sprintf("%d", x.Comments)
|
||||
case "owner":
|
||||
return x.Repository.Owner
|
||||
case "repo":
|
||||
return x.Repository.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user