Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit052bb2b

Browse files
authored
List Github App repositories (#156)
1 parent82b7206 commit052bb2b

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

‎vcsclient/github.go‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,15 +1555,30 @@ func encryptSecret(publicKey *github.PublicKey, secretValue string) (string, err
15551555
func (client*GitHubClient)ListAppRepositories(ctx context.Context) ([]AppRepositoryInfo,error) {
15561556
varresults []AppRepositoryInfo
15571557

1558-
response,_,err:=client.ghClient.Apps.ListRepos(ctx,nil)
1559-
iferr!=nil {
1560-
returnnil,err
1558+
varallRepositories []*github.Repository
1559+
fornextPage:=1; ;nextPage++ {
1560+
varrepositoriesInPage*github.ListRepositories
1561+
varghResponse*github.Response
1562+
varerrerror
1563+
err=client.runWithRateLimitRetries(func() (*github.Response,error) {
1564+
repositoriesInPage,ghResponse,err=client.ghClient.Apps.ListRepos(ctx,&github.ListOptions{Page:nextPage})
1565+
returnghResponse,err
1566+
})
1567+
iferr!=nil {
1568+
returnnil,err
1569+
}
1570+
allRepositories=append(allRepositories,repositoriesInPage.Repositories...)
1571+
ifnextPage+1>ghResponse.LastPage {
1572+
break
1573+
}
15611574
}
1562-
for_,repo:=rangeresponse.Repositories {
1575+
1576+
for_,repo:=rangeallRepositories {
15631577
ifrepo==nil||repo.Owner==nil||repo.Owner.Login==nil||repo.Name==nil {
15641578
continue
15651579
}
15661580
repoInfo:=AppRepositoryInfo{
1581+
ID:repo.GetID(),
15671582
Name:vcsutils.DefaultIfNotNil(repo.Name),
15681583
FullName:vcsutils.DefaultIfNotNil(repo.FullName),
15691584
Owner:vcsutils.DefaultIfNotNil(repo.Owner.Login),

‎vcsclient/github_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ func TestGitHubClient_ListAppRepositories(t *testing.T) {
15001500
vcsutils.GitHub,
15011501
false,
15021502
[]byte(response),
1503-
"/installation/repositories",
1503+
"/installation/repositories?page=1",
15041504
createGitHubHandler,
15051505
)
15061506
defercleanUp()
@@ -1509,6 +1509,7 @@ func TestGitHubClient_ListAppRepositories(t *testing.T) {
15091509
assert.NoError(t,err)
15101510
assert.Len(t,repos,1)
15111511
repoInfo:=repos[0]
1512+
assert.Equal(t,int64(1296269),repoInfo.ID)
15121513
assert.Equal(t,"Hello-World",repoInfo.Name)
15131514
assert.Equal(t,"octocat/Hello-World",repoInfo.FullName)
15141515
assert.Equal(t,"octocat",repoInfo.Owner)

‎vcsclient/vcsclient.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type CommitStatusInfo struct {
7878
}
7979

8080
// AppRepositoryInfo contains information about an application repository
81+
// ID - The unique identifier of the repository
8182
// Name - The repository name
8283
// FullName - The full name of the repository (including owner/namespace)
8384
// Owner - The owner of the repository
@@ -88,6 +89,7 @@ type CommitStatusInfo struct {
8889
// SSHURL - The SSH clone URL of the repository
8990
// DefaultBranch - The default branch of the repository
9091
typeAppRepositoryInfostruct {
92+
IDint64
9193
Namestring
9294
FullNamestring
9395
Ownerstring

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp