Skip to content

Commit 166dfad

Browse files
authored
Update repo community profile API (#2084)
1 parent 1b82d08 commit 166dfad

File tree

5 files changed

+199
-20
lines changed

5 files changed

+199
-20
lines changed

github/github-accessors.go

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

github/github-accessors_test.go

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

github/github.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ const (
7676
// https://developer.github.com/changes/2017-02-28-user-blocking-apis-and-webhook/
7777
mediaTypeBlockUsersPreview = "application/vnd.github.giant-sentry-fist-preview+json"
7878

79-
// https://developer.github.com/changes/2017-02-09-community-health/
80-
mediaTypeRepositoryCommunityHealthMetricsPreview = "application/vnd.github.black-panther-preview+json"
81-
8279
// https://developer.github.com/changes/2017-05-23-coc-api/
8380
mediaTypeCodesOfConductPreview = "application/vnd.github.scarlet-witch-preview+json"
8481

github/repos_community_health.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import (
1515
type Metric struct {
1616
Name *string `json:"name"`
1717
Key *string `json:"key"`
18+
SPDXID *string `json:"spdx_id"`
1819
URL *string `json:"url"`
1920
HTMLURL *string `json:"html_url"`
21+
NodeID *string `json:"node_id"`
2022
}
2123

2224
// CommunityHealthFiles represents the different files in the community health metrics response.
2325
type CommunityHealthFiles struct {
2426
CodeOfConduct *Metric `json:"code_of_conduct"`
27+
CodeOfConductFile *Metric `json:"code_of_conduct_file"`
2528
Contributing *Metric `json:"contributing"`
2629
IssueTemplate *Metric `json:"issue_template"`
2730
PullRequestTemplate *Metric `json:"pull_request_template"`
@@ -31,24 +34,24 @@ type CommunityHealthFiles struct {
3134

3235
// CommunityHealthMetrics represents a response containing the community metrics of a repository.
3336
type CommunityHealthMetrics struct {
34-
HealthPercentage *int `json:"health_percentage"`
35-
Files *CommunityHealthFiles `json:"files"`
36-
UpdatedAt *time.Time `json:"updated_at"`
37+
HealthPercentage *int `json:"health_percentage"`
38+
Description *string `json:"description"`
39+
Documentation *string `json:"documentation"`
40+
Files *CommunityHealthFiles `json:"files"`
41+
UpdatedAt *time.Time `json:"updated_at"`
42+
ContentReportsEnabled *bool `json:"content_reports_enabled"`
3743
}
3844

3945
// GetCommunityHealthMetrics retrieves all the community health metrics for a repository.
4046
//
41-
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-community-profile-metrics
47+
// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-community-profile-metrics
4248
func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) {
4349
u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo)
4450
req, err := s.client.NewRequest("GET", u, nil)
4551
if err != nil {
4652
return nil, nil, err
4753
}
4854

49-
// TODO: remove custom Accept header when this API fully launches.
50-
req.Header.Set("Accept", mediaTypeRepositoryCommunityHealthMetricsPreview)
51-
5255
metrics := &CommunityHealthMetrics{}
5356
resp, err := s.client.Do(ctx, req, metrics)
5457
if err != nil {

0 commit comments

Comments
 (0)