Skip to content

Commit

Permalink
Merge branch 'main' into fork-default-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Alaurant authored Jan 10, 2025
2 parents a37cc66 + 8714d1b commit 381931b
Show file tree
Hide file tree
Showing 15 changed files with 1,204 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,25 @@ public List<GHCodeownersError> listCodeownersErrors() throws IOException {
* the io exception
*/
public PagedIterable<Contributor> listContributors() throws IOException {
return root().createRequest().withUrlPath(getApiTailUrl("contributors")).toIterable(Contributor[].class, null);
return listContributors(null);
}

/**
* List contributors paged iterable.
*
* @param includeAnonymous
* whether to include anonymous contributors
* @return the paged iterable
* @throws IOException
* the io exception
* @see <a href="https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors">
* GitHub API - List Repository Contributors</a>
*/
public PagedIterable<Contributor> listContributors(Boolean includeAnonymous) throws IOException {
return root().createRequest()
.withUrlPath(getApiTailUrl("contributors"))
.with("anon", includeAnonymous)
.toIterable(Contributor[].class, null);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/kohsuke/github/GHWorkflowRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public GHWorkflowRun() {

private long runAttempt;
private String runStartedAt;
private GHUser triggeringActor;

private String htmlUrl;
private String jobsUrl;
Expand Down Expand Up @@ -119,6 +120,16 @@ public Date getRunStartedAt() throws IOException {
return GitHubClient.parseDate(runStartedAt);
}

/**
* The actor which triggered the run.
*
* @return the triggering actor
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHUser getTriggeringActor() {
return triggeringActor;
}

/**
* Gets the html url.
*
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/org/kohsuke/github/GHRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,31 @@ public void listContributors() throws IOException {
assertThat(kohsuke, is(true));
}

/**
* List contributors.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void listContributorsAnon() throws IOException {
GHRepository r = gitHub.getOrganization("hub4j").getRepository("github-api");
int i = 0;
boolean kohsuke = false;

for (GHRepository.Contributor c : r.listContributors(true)) {
if (c.getType().equals("Anonymous")) {
assertThat(c.getContributions(), is(3));
kohsuke = true;
}
if (++i > 1) {
break;
}
}

assertThat(kohsuke, is(true));
}

/**
* Gets the permission.
*
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/kohsuke/github/GHWorkflowRunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void testManualRunAndBasicInformation() throws IOException {
assertThat(workflowRun.getStatus(), equalTo(Status.COMPLETED));
assertThat(workflowRun.getConclusion(), equalTo(Conclusion.SUCCESS));
assertThat(workflowRun.getHeadSha(), notNullValue());
assertThat(workflowRun.getTriggeringActor(), hasProperty("login", equalTo("octocat")));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"login": "bitwiseman",
"id": 1958953,
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bitwiseman",
"html_url": "https://github.com/bitwiseman",
"followers_url": "https://api.github.com/users/bitwiseman/followers",
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
"repos_url": "https://api.github.com/users/bitwiseman/repos",
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
"type": "User",
"site_admin": false,
"name": "Liam Newman",
"company": "Cloudbees, Inc.",
"blog": "",
"location": "Seattle, WA, USA",
"email": "[email protected]",
"hireable": null,
"bio": "https://twitter.com/bitwiseman",
"public_repos": 167,
"public_gists": 4,
"followers": 136,
"following": 9,
"created_at": "2012-07-11T20:38:33Z",
"updated_at": "2019-09-24T19:32:29Z",
"private_gists": 7,
"total_private_repos": 9,
"owned_private_repos": 0,
"disk_usage": 33697,
"collaborators": 0,
"two_factor_authentication": true,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"login": "kohsuke",
"id": 50003,
"node_id": "MDQ6VXNlcjUwMDAz",
"avatar_url": "https://avatars.githubusercontent.com/u/50003?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kohsuke",
"html_url": "https://github.com/kohsuke",
"followers_url": "https://api.github.com/users/kohsuke/followers",
"following_url": "https://api.github.com/users/kohsuke/following{/other_user}",
"gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions",
"organizations_url": "https://api.github.com/users/kohsuke/orgs",
"repos_url": "https://api.github.com/users/kohsuke/repos",
"events_url": "https://api.github.com/users/kohsuke/events{/privacy}",
"received_events_url": "https://api.github.com/users/kohsuke/received_events",
"type": "User",
"site_admin": false,
"name": "Kohsuke Kawaguchi",
"company": "@launchableinc ",
"blog": "https://www.kohsuke.org/",
"location": "San Jose, California",
"email": "[email protected]",
"hireable": null,
"bio": null,
"twitter_username": null,
"public_repos": 265,
"public_gists": 113,
"followers": 1999,
"following": 3,
"created_at": "2009-01-28T18:53:21Z",
"updated_at": "2022-04-10T22:58:15Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"login": "hub4j",
"id": 54909825,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
"url": "https://api.github.com/orgs/hub4j",
"repos_url": "https://api.github.com/orgs/hub4j/repos",
"events_url": "https://api.github.com/orgs/hub4j/events",
"hooks_url": "https://api.github.com/orgs/hub4j/hooks",
"issues_url": "https://api.github.com/orgs/hub4j/issues",
"members_url": "https://api.github.com/orgs/hub4j/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j/public_members{/member}",
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
"description": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 1,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j",
"created_at": "2019-09-04T18:12:34Z",
"updated_at": "2019-09-04T18:12:34Z",
"type": "Organization",
"total_private_repos": 0,
"owned_private_repos": 0,
"private_gists": 0,
"disk_usage": 11899,
"collaborators": 0,
"billing_email": "[email protected]",
"default_repository_permission": "read",
"members_can_create_repositories": true,
"two_factor_requirement_enabled": false,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 0,
"filled_seats": 2,
"seats": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"id": 617210,
"node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
"name": "github-api",
"full_name": "hub4j/github-api",
"private": false,
"owner": {
"login": "hub4j",
"id": 54909825,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j",
"html_url": "https://github.com/hub4j",
"followers_url": "https://api.github.com/users/hub4j/followers",
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j/orgs",
"repos_url": "https://api.github.com/users/hub4j/repos",
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/hub4j/github-api",
"description": "Java API for GitHub",
"fork": false,
"url": "https://api.github.com/repos/hub4j/github-api",
"forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
"keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
"hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j/github-api/events",
"assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
"blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
"stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors?anon=true",
"subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
"commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
"archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
"issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
"created_at": "2010-04-19T04:13:03Z",
"updated_at": "2019-10-03T09:41:10Z",
"pushed_at": "2019-10-02T22:27:45Z",
"git_url": "git://github.com/hub4j/github-api.git",
"ssh_url": "[email protected]:hub4j/github-api.git",
"clone_url": "https://github.com/hub4j/github-api.git",
"svn_url": "https://github.com/hub4j/github-api",
"homepage": "http://github-api.kohsuke.org/",
"size": 11899,
"stargazers_count": 557,
"watchers_count": 557,
"language": "Java",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 428,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 90,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 428,
"open_issues": 90,
"watchers": 557,
"default_branch": "main",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"organization": {
"login": "hub4j",
"id": 54909825,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j",
"html_url": "https://github.com/hub4j",
"followers_url": "https://api.github.com/users/hub4j/followers",
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j/orgs",
"repos_url": "https://api.github.com/users/hub4j/repos",
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 428,
"subscribers_count": 50
}
Loading

0 comments on commit 381931b

Please sign in to comment.