@@ -78,8 +78,34 @@ type GithubRepository struct {
78
78
IsDisabled bool `graphql:"isDisabled"`
79
79
IsEmpty bool `graphql:"isEmpty"`
80
80
IsTemplate bool `graphql:"isTemplate"`
81
+ IsArchived bool `graphql:"isArchived"`
81
82
StargazerCount int `graphql:"stargazerCount"`
82
83
ForkCount int `graphql:"forkCount"`
84
+ Owner struct {
85
+ Organization struct {
86
+ DatabaseId int `graphql:"databaseId"`
87
+ } `graphql:"... on Organization"`
88
+ User struct {
89
+ DatabaseId int `graphql:"databaseId"`
90
+ } `graphql:"... on User"`
91
+ } `graphql:"owner"`
92
+ DatabaseId int `graphql:"databaseId"`
93
+ RepoSize int `graphql:"diskUsage"` // kilobytes
94
+ DefaultBranchRef struct {
95
+ Name string `graphql:"name"`
96
+ } `graphql:"defaultBranchRef"`
97
+ HasIssues bool `graphql:"hasIssuesEnabled"`
98
+ HasWiki bool `graphql:"hasWikiEnabled"`
99
+ HasDiscussions bool `graphql:"hasDiscussionsEnabled"`
100
+ PrimaryLanguage struct {
101
+ Name string `graphql:"name"`
102
+ } `graphql:"primaryLanguage"`
103
+ License struct {
104
+ Name string `graphql:"name"`
105
+ } `graphql:"licenseInfo"`
106
+ Issues struct {
107
+ TotalCount int `graphql:"totalCount"`
108
+ } `graphql:"issues"`
83
109
}
84
110
85
111
func (gh GithubRepository ) GetProviderName () string {
@@ -127,6 +153,62 @@ func (gh GithubRepository) GetIsFork() bool {
127
153
return gh .IsFork
128
154
}
129
155
156
+ func (gh GithubRepository ) GetHasIssues () bool {
157
+ return gh .HasIssues
158
+ }
159
+
160
+ func (gh GithubRepository ) GetHasWiki () bool {
161
+ return gh .HasWiki
162
+ }
163
+
164
+ func (gh GithubRepository ) GetHasDiscussion () bool {
165
+ return gh .HasDiscussions
166
+ }
167
+
168
+ func (gh GithubRepository ) GetPrimaryLanguage () string {
169
+ return gh .PrimaryLanguage .Name
170
+ }
171
+
172
+ func (gh GithubRepository ) GetSize () int {
173
+ return gh .RepoSize
174
+ }
175
+
176
+ func (gh GithubRepository ) GetDefaultBranch () string {
177
+ return gh .DefaultBranchRef .Name
178
+ }
179
+
180
+ func (gh GithubRepository ) GetLicense () string {
181
+ return gh .License .Name
182
+ }
183
+
184
+ func (gh GithubRepository ) GetIsTemplate () bool {
185
+ return gh .IsTemplate
186
+ }
187
+
188
+ func (gh GithubRepository ) GetOrganizationID () int {
189
+ return gh .Owner .Organization .DatabaseId // even if it's a user, the organization will be filled with the same id
190
+ }
191
+
192
+ func (gh GithubRepository ) GetRepositoryID () int {
193
+ return gh .DatabaseId
194
+ }
195
+
196
+ func (gh GithubRepository ) GetForksCount () int {
197
+ return gh .ForkCount
198
+ }
199
+
200
+ func (gh GithubRepository ) GetStarsCount () int {
201
+ return gh .StargazerCount
202
+ }
203
+
204
+ func (gh GithubRepository ) GetOpenIssuesCount () int {
205
+ return gh .Issues .TotalCount
206
+ }
207
+
208
+ func (gh GithubRepository ) GetIsEmpty () bool {
209
+ return gh .IsEmpty
210
+ }
211
+
130
212
type Client struct {
131
213
restClient * github.Client
132
214
graphQLClient * githubv4.Client
@@ -139,14 +221,19 @@ func NewClient(ctx context.Context, token string, domain string) (*Client, error
139
221
return nil , err
140
222
}
141
223
224
+ oauth2Client := http.Client {
225
+ Transport : & retryTransport {},
226
+ }
227
+ oauth2Context := context .WithValue (ctx , oauth2 .HTTPClient , & oauth2Client )
228
+
142
229
var (
143
230
// REST client
144
231
restClient = github .NewClient (rateLimiter ).WithAuthToken (token )
145
232
// GraphQL client
146
233
src = oauth2 .StaticTokenSource (
147
234
& oauth2.Token {AccessToken : token },
148
235
)
149
- httpClient = oauth2 .NewClient (ctx , src )
236
+ httpClient = oauth2 .NewClient (oauth2Context , src )
150
237
graphQLClient * githubv4.Client
151
238
)
152
239
0 commit comments