Add isDraft to search prs json options, matching pr view (#6704)
This commit is contained in:
parent
4fd56ac7c1
commit
eadc8e8372
3 changed files with 34 additions and 14 deletions
|
|
@ -122,7 +122,7 @@ func NewCmdPrs(f *cmdutil.Factory, runF func(*shared.IssuesOptions) error) *cobr
|
|||
}
|
||||
|
||||
// Output flags
|
||||
cmdutil.AddJSONFlags(cmd, &opts.Exporter, search.IssueFields)
|
||||
cmdutil.AddJSONFlags(cmd, &opts.Exporter, search.PullRequestFields)
|
||||
cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the search query in the web browser")
|
||||
|
||||
// Query parameter flags
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ var IssueFields = []string{
|
|||
"url",
|
||||
}
|
||||
|
||||
var PullRequestFields = append(IssueFields,
|
||||
"isDraft",
|
||||
)
|
||||
|
||||
type RepositoriesResult struct {
|
||||
IncompleteResults bool `json:"incomplete_results"`
|
||||
Items []Repository `json:"items"`
|
||||
|
|
@ -124,19 +128,22 @@ func (u *User) IsBot() bool {
|
|||
}
|
||||
|
||||
type Issue struct {
|
||||
Assignees []User `json:"assignees"`
|
||||
Author User `json:"user"`
|
||||
AuthorAssociation string `json:"author_association"`
|
||||
Body string `json:"body"`
|
||||
ClosedAt time.Time `json:"closed_at"`
|
||||
CommentsCount int `json:"comments"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID string `json:"node_id"`
|
||||
Labels []Label `json:"labels"`
|
||||
IsLocked bool `json:"locked"`
|
||||
Number int `json:"number"`
|
||||
PullRequest PullRequest `json:"pull_request"`
|
||||
RepositoryURL string `json:"repository_url"`
|
||||
Assignees []User `json:"assignees"`
|
||||
Author User `json:"user"`
|
||||
AuthorAssociation string `json:"author_association"`
|
||||
Body string `json:"body"`
|
||||
ClosedAt time.Time `json:"closed_at"`
|
||||
CommentsCount int `json:"comments"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID string `json:"node_id"`
|
||||
Labels []Label `json:"labels"`
|
||||
// This is a PullRequest field which does not appear in issue results,
|
||||
// but lives outside the PullRequest object.
|
||||
IsDraft *bool `json:"draft,omitempty"`
|
||||
IsLocked bool `json:"locked"`
|
||||
Number int `json:"number"`
|
||||
PullRequest PullRequest `json:"pull_request"`
|
||||
RepositoryURL string `json:"repository_url"`
|
||||
// StateInternal should not be used directly. Use State() instead.
|
||||
StateInternal string `json:"state"`
|
||||
StateReason string `json:"state_reason"`
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ func TestRepositoryExportData(t *testing.T) {
|
|||
|
||||
func TestIssueExportData(t *testing.T) {
|
||||
var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC)
|
||||
trueValue := true
|
||||
tests := []struct {
|
||||
name string
|
||||
fields []string
|
||||
|
|
@ -88,6 +89,18 @@ func TestIssueExportData(t *testing.T) {
|
|||
},
|
||||
output: `{"isPullRequest":true,"state":"merged"}`,
|
||||
},
|
||||
{
|
||||
name: "isDraft when pull request",
|
||||
fields: []string{"isDraft", "state"},
|
||||
issue: Issue{
|
||||
PullRequest: PullRequest{
|
||||
URL: "a-url",
|
||||
},
|
||||
StateInternal: "open",
|
||||
IsDraft: &trueValue,
|
||||
},
|
||||
output: `{"isDraft":true,"state":"open"}`,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue