Skip to content

Commit 74dffb7

Browse files
committed
new: make query supports "isArchived" argument
fix: #155
1 parent a02fe97 commit 74dffb7

File tree

8 files changed

+43
-27
lines changed

8 files changed

+43
-27
lines changed

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ DATE ?= `date --iso-8601`
55
generate-clear: gen-clear
66
.PHONY: generate-clear
77

8-
gen-clear: clear-sdl
8+
gen-clear:
99
rm -rf ./**/*_gen.go
1010
.PHONY: gen-clear
1111

12+
generate: gen
13+
.PHONY: generate
14+
15+
gen: gen-clear
16+
go generate -x ./...
17+
.PHONY: gen
18+
1219
clear-sdl:
1320
rm -f ./internal/githubv4/schema.graphql
1421
.PHONY: clear-sdl
@@ -17,12 +24,9 @@ get-sdl:
1724
curl -Lo ./internal/githubv4/schema.graphql https://docs.github.com/public/fpt/schema.docs.graphql
1825
.PHONY: get-sdl
1926

20-
generate: gen
21-
.PHONY: generate
22-
23-
gen: gen-clear get-sdl
24-
go generate -x ./...
25-
.PHONY: gen
27+
gen-gql: clear-sdl get-sdl
28+
go generate -tags gengraphql -x ./internal/githubv4
29+
.PHONY: gen-gql
2630

2731
lint: gen
2832
golangci-lint run

cmd/gogh/repos.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ var (
6161
return errors.New("specify only one of `--fork` or `--no-fork`")
6262
}
6363
if reposFlags.Fork {
64-
listOption.IsFork = reposFlags.Fork // &true
64+
listOption.IsFork = &reposFlags.Fork // &true
6565
}
6666
if reposFlags.NotFork {
67-
listOption.IsFork = reposFlags.Fork // &false
67+
listOption.IsFork = &reposFlags.Fork // &false
6868
}
6969
LOOP_CONVERT_RELATION:
7070
for _, r := range reposFlags.Relation {

internal/github/genuine.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (a *genuineAdaptor) RepositoryList(
126126
opts.Privacy,
127127
opts.OwnerAffiliations,
128128
opts.OrderBy,
129+
opts.IsArchived,
129130
)
130131
if err != nil {
131132
return nil, PageInfoFragment{}, err

internal/github/if.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ type RepositoryListOptions struct {
5656
Privacy RepositoryPrivacy
5757
OwnerAffiliations []RepositoryAffiliation
5858
Limit int
59-
IsFork bool
59+
IsFork *bool
60+
IsArchived *bool
6061
}
6162

6263
type Adaptor interface {

internal/githubv4/generated.go

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/githubv4/genqlient.graphql

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,28 @@ query ListRepos(
4444
$first: Int = 30,
4545
# @genqlient(omitempty: true)
4646
$after: String,
47-
# @genqlient(omitempty: true)
47+
# @genqlient(omitempty: true, pointer: true)
4848
$isFork: Boolean,
4949
# @genqlient(omitempty: true)
5050
$privacy: RepositoryPrivacy,
5151
# @genqlient(omitempty: true)
5252
$affiliations: [RepositoryAffiliation],
5353
# @genqlient(omitempty: true)
5454
$orderBy: RepositoryOrder = {field: PUSHED_AT, direction: DESC},
55+
# @genqlient(omitempty: true, pointer: true)
56+
$isArchived: Boolean,
5557
) {
5658
viewer {
57-
repositories(first: $first, after: $after, isFork: $isFork, privacy: $privacy, ownerAffiliations: $affiliations, affiliations: $affiliations, orderBy: $orderBy) {
59+
repositories(
60+
first: $first,
61+
after: $after,
62+
isArchived: $isArchived,
63+
isFork: $isFork,
64+
privacy: $privacy,
65+
ownerAffiliations: $affiliations,
66+
affiliations: $affiliations,
67+
orderBy: $orderBy
68+
) {
5869
edges {
5970
node {
6071
...RepositoryFragment

remote.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,11 @@ var AllOrderDirection = []githubv4.OrderDirection{
104104

105105
type RemoteListOption struct {
106106
Private *bool
107+
IsFork *bool
107108
Order OrderDirection
108109
Sort RepositoryOrderField
109110
Relation []RepositoryRelation
110111
Limit int
111-
IsFork bool
112-
// UNDONE:
113-
// https://github.com/cli/cli/blob/5a2ec54685806a6576bdc185751afc09aba44408/pkg/cmd/repo/list/http.go#L60-L62
114-
// > if filter.Language != "" || filter.Archived || filter.NonArchived {
115-
// > return searchRepos(client, hostname, limit, owner, filter)
116-
// > }
117-
// Language string
118-
// Archived *bool
119112
}
120113

121114
func (o *RemoteListOption) GetOptions() *github.RepositoryListOptions {

remote_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestRemoteListOption_GetOptions(t *testing.T) {
157157
{
158158
title: "fork",
159159
base: &testtarget.RemoteListOption{
160-
IsFork: true,
160+
IsFork: ptr(true),
161161
},
162162
want: &github.RepositoryListOptions{
163163
OrderBy: github.RepositoryOrder{
@@ -166,7 +166,7 @@ func TestRemoteListOption_GetOptions(t *testing.T) {
166166
},
167167
Limit: testtarget.RepositoryListMaxLimitPerPage,
168168
OwnerAffiliations: []github.RepositoryAffiliation{owner},
169-
IsFork: true,
169+
IsFork: ptr(true),
170170
},
171171
},
172172
{

0 commit comments

Comments
 (0)