@@ -78,8 +78,34 @@ type GithubRepository struct {
7878 IsDisabled bool `graphql:"isDisabled"`
7979 IsEmpty bool `graphql:"isEmpty"`
8080 IsTemplate bool `graphql:"isTemplate"`
81+ IsArchived bool `graphql:"isArchived"`
8182 StargazerCount int `graphql:"stargazerCount"`
8283 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"`
83109}
84110
85111func (gh GithubRepository ) GetProviderName () string {
@@ -127,6 +153,62 @@ func (gh GithubRepository) GetIsFork() bool {
127153 return gh .IsFork
128154}
129155
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+
130212type Client struct {
131213 restClient * github.Client
132214 graphQLClient * githubv4.Client
@@ -139,14 +221,19 @@ func NewClient(ctx context.Context, token string, domain string) (*Client, error
139221 return nil , err
140222 }
141223
224+ oauth2Client := http.Client {
225+ Transport : & retryTransport {},
226+ }
227+ oauth2Context := context .WithValue (ctx , oauth2 .HTTPClient , & oauth2Client )
228+
142229 var (
143230 // REST client
144231 restClient = github .NewClient (rateLimiter ).WithAuthToken (token )
145232 // GraphQL client
146233 src = oauth2 .StaticTokenSource (
147234 & oauth2.Token {AccessToken : token },
148235 )
149- httpClient = oauth2 .NewClient (ctx , src )
236+ httpClient = oauth2 .NewClient (oauth2Context , src )
150237 graphQLClient * githubv4.Client
151238 )
152239
0 commit comments