Skip to content

Commit

Permalink
Merge pull request #741 from sladyn98/add_has_projects
Browse files Browse the repository at this point in the history
Add has_projects field to github repository
  • Loading branch information
bitwiseman authored Apr 1, 2020
2 parents 5fe2817 + 279df00 commit c5ee07a
Show file tree
Hide file tree
Showing 35 changed files with 512 additions and 939 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ public GHCreateRepositoryBuilder issues(boolean enabled) {
return this;
}

/**
* Enables projects
*
* @param enabled
* true if enabled
* @return a builder to continue with building
*/
public GHCreateRepositoryBuilder projects(boolean enabled) {
this.builder.with("has_projects", enabled);
return this;
}

/**
* Enables wiki
*
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class GHRepository extends GHObject {

private String git_url, ssh_url, clone_url, svn_url, mirror_url;
private GHUser owner; // not fully populated. beware.
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived;
private boolean has_issues, has_wiki, fork, has_downloads, has_pages, archived, has_projects;

private boolean allow_squash_merge;
private boolean allow_merge_commit;
Expand Down Expand Up @@ -547,6 +547,15 @@ public boolean hasIssues() {
return has_issues;
}

/**
* Has projects boolean.
*
* @return the boolean
*/
public boolean hasProjects() {
return has_projects;
}

/**
* Has wiki boolean.
*
Expand Down Expand Up @@ -988,6 +997,18 @@ public void enableIssueTracker(boolean v) throws IOException {
edit("has_issues", String.valueOf(v));
}

/**
* Enables or disables projects for this repository.
*
* @param v
* the v
* @throws IOException
* the io exception
*/
public void enableProjects(boolean v) throws IOException {
edit("has_projects", String.valueOf(v));
}

/**
* Enables or disables Wiki for this repository.
*
Expand Down
35 changes: 30 additions & 5 deletions src/test/java/org/kohsuke/github/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,40 @@ public void testRepoCRUD() throws Exception {
"a test repository",
"http://github-api.kohsuke.org/",
true);

assertThat(r.hasIssues(), is(true));
assertThat(r.hasWiki(), is(true));
assertThat(r.hasDownloads(), is(true));
assertThat(r.hasProjects(), is(true));

r.enableIssueTracker(false);
r.enableDownloads(false);
r.enableWiki(false);
r.enableProjects(false);

r.renameTo(targetName);
getUser().getRepository(targetName).delete();

// local instance remains unchanged
assertThat(r.getName(), equalTo("github-api-test-rename"));
assertThat(r.hasIssues(), is(true));
assertThat(r.hasWiki(), is(true));
assertThat(r.hasDownloads(), is(true));
assertThat(r.hasProjects(), is(true));

r = gitHub.getMyself().getRepository(targetName);

// values are updated
assertThat(r.hasIssues(), is(false));
assertThat(r.hasWiki(), is(false));
assertThat(r.hasDownloads(), is(false));
assertThat(r.getName(), equalTo(targetName));

// ISSUE: #765
// From what I can tell this is a bug in GithHub.
// updating `has_projects` doesn't seem to do anything
assertThat(r.hasProjects(), is(true));

r.delete();
}

@Test
Expand All @@ -58,14 +85,12 @@ public void testRepositoryWithAutoInitializationCRUD() throws Exception {
.homepage("http://github-api.kohsuke.org/")
.autoInit(true)
.create();
r.enableIssueTracker(false);
r.enableDownloads(false);
r.enableWiki(false);
if (mockGitHub.isUseProxy()) {
Thread.sleep(3000);
}
assertNotNull(r.getReadme());
getUser().getRepository(name).delete();

r.delete();
}

private void cleanupUserRepository(final String name) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": 212446528,
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename",
"full_name": "bitwiseman/github-api-test-rename",
"private": false,
Expand Down Expand Up @@ -64,9 +64,9 @@
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
"created_at": "2019-10-02T21:40:00Z",
"updated_at": "2019-10-02T21:40:01Z",
"pushed_at": "2019-10-02T21:40:01Z",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:45Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
Expand Down Expand Up @@ -99,6 +99,7 @@
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": 212446528,
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename",
"full_name": "bitwiseman/github-api-test-rename",
"private": false,
Expand Down Expand Up @@ -64,9 +64,9 @@
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
"created_at": "2019-10-02T21:40:00Z",
"updated_at": "2019-10-02T21:40:01Z",
"pushed_at": "2019-10-02T21:40:01Z",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:46Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
Expand Down Expand Up @@ -99,6 +99,7 @@
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": 212446528,
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename",
"full_name": "bitwiseman/github-api-test-rename",
"private": false,
Expand Down Expand Up @@ -64,9 +64,9 @@
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
"created_at": "2019-10-02T21:40:00Z",
"updated_at": "2019-10-02T21:40:02Z",
"pushed_at": "2019-10-02T21:40:01Z",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:46Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
Expand Down Expand Up @@ -99,6 +99,7 @@
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename",
"full_name": "bitwiseman/github-api-test-rename",
"private": false,
"owner": {
"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
},
"html_url": "https://github.com/bitwiseman/github-api-test-rename",
"description": "a test repository",
"fork": false,
"url": "https://api.github.com/repos/bitwiseman/github-api-test-rename",
"forks_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/forks",
"keys_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/teams",
"hooks_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/hooks",
"issue_events_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/issues/events{/number}",
"events_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/events",
"assignees_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/assignees{/user}",
"branches_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/branches{/branch}",
"tags_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/tags",
"blobs_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/statuses/{sha}",
"languages_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/languages",
"stargazers_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/stargazers",
"contributors_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/contributors",
"subscribers_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/subscribers",
"subscription_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/subscription",
"commits_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/contents/{+path}",
"compare_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/merges",
"archive_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/downloads",
"issues_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/issues{/number}",
"pulls_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/pulls{/number}",
"milestones_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/milestones{/number}",
"notifications_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:47Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
"svn_url": "https://github.com/bitwiseman/github-api-test-rename",
"homepage": "http://github-api.kohsuke.org/",
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": false,
"has_projects": true,
"has_downloads": false,
"has_wiki": false,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": null,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": 212446528,
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename2",
"full_name": "bitwiseman/github-api-test-rename2",
"private": false,
Expand Down Expand Up @@ -64,9 +64,9 @@
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/deployments",
"created_at": "2019-10-02T21:40:00Z",
"updated_at": "2019-10-02T21:40:02Z",
"pushed_at": "2019-10-02T21:40:01Z",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:47Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename2.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename2.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename2.git",
Expand Down Expand Up @@ -99,6 +99,7 @@
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": 212446528,
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
"id": 251751384,
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
"name": "github-api-test-rename2",
"full_name": "bitwiseman/github-api-test-rename2",
"private": false,
Expand Down Expand Up @@ -64,9 +64,9 @@
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/labels{/name}",
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/releases{/id}",
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/deployments",
"created_at": "2019-10-02T21:40:00Z",
"updated_at": "2019-10-02T21:40:02Z",
"pushed_at": "2019-10-02T21:40:01Z",
"created_at": "2020-03-31T21:52:44Z",
"updated_at": "2020-03-31T21:52:47Z",
"pushed_at": "2020-03-31T21:52:45Z",
"git_url": "git://github.com/bitwiseman/github-api-test-rename2.git",
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename2.git",
"clone_url": "https://github.com/bitwiseman/github-api-test-rename2.git",
Expand Down Expand Up @@ -96,9 +96,11 @@
"push": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"network_count": 0,
"subscribers_count": 1
}
Loading

0 comments on commit c5ee07a

Please sign in to comment.