Skip to content

Commit c6da5ea

Browse files
committed
fix: get repository parameter in PullRequests
1 parent b318793 commit c6da5ea

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

provider/describer/pull_request.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,31 @@ func GetAllPullRequests(ctx context.Context, githubClient GitHubClient, organiza
2020
}
2121
}
2222

23-
repositories, err := getRepositories(ctx, githubClient.RestClient, organizationName)
24-
if err != nil {
25-
return nil, nil
26-
}
2723
var values []models.Resource
28-
for _, repo := range repositories {
29-
repoValues, err := ListRepositoryPullRequests(ctx, githubClient, stream, organizationName, repo.GetName())
24+
repoParam := ctx.Value("repository")
25+
if repoParam != nil {
26+
repoName := repoParam.(string)
27+
if repoName != "" {
28+
repoValues, err := ListRepositoryPullRequests(ctx, githubClient, stream, organizationName, repoName)
29+
if err != nil {
30+
return nil, err
31+
}
32+
values = append(values, repoValues...)
33+
}
34+
} else {
35+
repositories, err := getRepositories(ctx, githubClient.RestClient, organizationName)
3036
if err != nil {
31-
return nil, err
37+
return nil, nil
38+
}
39+
for _, repo := range repositories {
40+
repoValues, err := ListRepositoryPullRequests(ctx, githubClient, stream, organizationName, repo.GetName())
41+
if err != nil {
42+
return nil, err
43+
}
44+
values = append(values, repoValues...)
3245
}
33-
values = append(values, repoValues...)
3446
}
47+
3548
return values, nil
3649
}
3750

0 commit comments

Comments
 (0)