Skip to content

Commit 31e2b1b

Browse files
authored
Merge branch 'master' into issue_444_unset_milestone
2 parents fa6f06a + 410bac2 commit 31e2b1b

File tree

37 files changed

+543
-954
lines changed

37 files changed

+543
-954
lines changed

pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.kohsuke</groupId>
44
<artifactId>github-api</artifactId>
5-
<version>1.109-SNAPSHOT</version>
5+
<version>1.110-SNAPSHOT</version>
66
<name>GitHub API for Java</name>
77
<url>https://github-api.kohsuke.org/</url>
88
<description>GitHub API for Java</description>
@@ -572,6 +572,10 @@
572572
</properties>
573573
<build>
574574
<plugins>
575+
<plugin>
576+
<groupId>org.jacoco</groupId>
577+
<artifactId>jacoco-maven-plugin</artifactId>
578+
</plugin>
575579
<plugin>
576580
<groupId>org.apache.maven.plugins</groupId>
577581
<artifactId>maven-gpg-plugin</artifactId>
@@ -621,6 +625,18 @@
621625
</profiles>
622626
<reporting>
623627
<plugins>
628+
<plugin>
629+
<groupId>org.jacoco</groupId>
630+
<artifactId>jacoco-maven-plugin</artifactId>
631+
<reportSets>
632+
<reportSet>
633+
<reports>
634+
<!-- select non-aggregate reports -->
635+
<report>report</report>
636+
</reports>
637+
</reportSet>
638+
</reportSets>
639+
</plugin>
624640
<plugin>
625641
<groupId>org.apache.maven.plugins</groupId>
626642
<artifactId>maven-javadoc-plugin</artifactId>

src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ public GHCreateRepositoryBuilder issues(boolean enabled) {
7979
return this;
8080
}
8181

82+
/**
83+
* Enables projects
84+
*
85+
* @param enabled
86+
* true if enabled
87+
* @return a builder to continue with building
88+
*/
89+
public GHCreateRepositoryBuilder projects(boolean enabled) {
90+
this.builder.with("has_projects", enabled);
91+
return this;
92+
}
93+
8294
/**
8395
* Enables wiki
8496
*

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class GHRepository extends GHObject {
7676

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

8181
private boolean allow_squash_merge;
8282
private boolean allow_merge_commit;
@@ -547,6 +547,15 @@ public boolean hasIssues() {
547547
return has_issues;
548548
}
549549

550+
/**
551+
* Has projects boolean.
552+
*
553+
* @return the boolean
554+
*/
555+
public boolean hasProjects() {
556+
return has_projects;
557+
}
558+
550559
/**
551560
* Has wiki boolean.
552561
*
@@ -988,6 +997,18 @@ public void enableIssueTracker(boolean v) throws IOException {
988997
edit("has_issues", String.valueOf(v));
989998
}
990999

1000+
/**
1001+
* Enables or disables projects for this repository.
1002+
*
1003+
* @param v
1004+
* the v
1005+
* @throws IOException
1006+
* the io exception
1007+
*/
1008+
public void enableProjects(boolean v) throws IOException {
1009+
edit("has_projects", String.valueOf(v));
1010+
}
1011+
9911012
/**
9921013
* Enables or disables Wiki for this repository.
9931014
*

src/test/java/org/kohsuke/github/AppTest.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,40 @@ public void testRepoCRUD() throws Exception {
4040
"a test repository",
4141
"http://github-api.kohsuke.org/",
4242
true);
43+
4344
assertThat(r.hasIssues(), is(true));
45+
assertThat(r.hasWiki(), is(true));
46+
assertThat(r.hasDownloads(), is(true));
47+
assertThat(r.hasProjects(), is(true));
4448

4549
r.enableIssueTracker(false);
4650
r.enableDownloads(false);
4751
r.enableWiki(false);
52+
r.enableProjects(false);
53+
4854
r.renameTo(targetName);
49-
getUser().getRepository(targetName).delete();
55+
56+
// local instance remains unchanged
57+
assertThat(r.getName(), equalTo("github-api-test-rename"));
58+
assertThat(r.hasIssues(), is(true));
59+
assertThat(r.hasWiki(), is(true));
60+
assertThat(r.hasDownloads(), is(true));
61+
assertThat(r.hasProjects(), is(true));
62+
63+
r = gitHub.getMyself().getRepository(targetName);
64+
65+
// values are updated
66+
assertThat(r.hasIssues(), is(false));
67+
assertThat(r.hasWiki(), is(false));
68+
assertThat(r.hasDownloads(), is(false));
69+
assertThat(r.getName(), equalTo(targetName));
70+
71+
// ISSUE: #765
72+
// From what I can tell this is a bug in GithHub.
73+
// updating `has_projects` doesn't seem to do anything
74+
assertThat(r.hasProjects(), is(true));
75+
76+
r.delete();
5077
}
5178

5279
@Test
@@ -58,14 +85,12 @@ public void testRepositoryWithAutoInitializationCRUD() throws Exception {
5885
.homepage("http://github-api.kohsuke.org/")
5986
.autoInit(true)
6087
.create();
61-
r.enableIssueTracker(false);
62-
r.enableDownloads(false);
63-
r.enableWiki(false);
6488
if (mockGitHub.isUseProxy()) {
6589
Thread.sleep(3000);
6690
}
6791
assertNotNull(r.getReadme());
68-
getUser().getRepository(name).delete();
92+
93+
r.delete();
6994
}
7095

7196
private void cleanupUserRepository(final String name) throws IOException {

src/test/java/org/kohsuke/github/GHRateLimitTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public void testGitHubRateLimit() throws Exception {
7474
GHRateLimit headerRateLimit = rateLimit;
7575

7676
// Give this a moment
77-
Thread.sleep(1000);
77+
Thread.sleep(1500);
7878

7979
// ratelimit() uses headerRateLimit if available and headerRateLimit is not expired
8080
assertThat(gitHub.rateLimit(), equalTo(headerRateLimit));
8181

8282
assertThat(mockGitHub.getRequestCount(), equalTo(1));
8383

8484
// Give this a moment
85-
Thread.sleep(1000);
85+
Thread.sleep(1500);
8686

8787
// Always requests new info
8888
rateLimit = gitHub.getRateLimit();
@@ -96,7 +96,7 @@ public void testGitHubRateLimit() throws Exception {
9696
previousLimit = rateLimit;
9797

9898
// Give this a moment
99-
Thread.sleep(1000);
99+
Thread.sleep(1500);
100100

101101
// Always requests new info
102102
rateLimit = gitHub.getRateLimit();
@@ -200,7 +200,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
200200
Date lastReset = new Date(System.currentTimeMillis() / 1000L);
201201

202202
// Give this a moment
203-
Thread.sleep(1000);
203+
Thread.sleep(1500);
204204

205205
// -------------------------------------------------------------
206206
// Before any queries, rate limit starts as null but may be requested
@@ -224,7 +224,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
224224
assertThat(mockGitHub.getRequestCount(), equalTo(1));
225225

226226
// Give this a moment
227-
Thread.sleep(1000);
227+
Thread.sleep(1500);
228228

229229
// -------------------------------------------------------------
230230
// First call to /user gets response without rate limit information
@@ -244,7 +244,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
244244
assertThat(mockGitHub.getRequestCount(), equalTo(3));
245245

246246
// Give this a moment
247-
Thread.sleep(1000);
247+
Thread.sleep(1500);
248248

249249
// Always requests new info
250250
rateLimit = gitHub.getRateLimit();
@@ -256,13 +256,13 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
256256
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1));
257257

258258
// Give this a moment
259-
Thread.sleep(1000);
259+
Thread.sleep(1500);
260260

261261
// last is still null, because it actually means lastHeaderRateLimit
262262
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());
263263

264264
// ratelimit() tries not to make additional requests, uses queried rate limit since header not available
265-
Thread.sleep(1000);
265+
Thread.sleep(1500);
266266
assertThat(gitHub.rateLimit(), sameInstance(rateLimit));
267267

268268
// -------------------------------------------------------------
@@ -283,15 +283,15 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
283283
GHRateLimit headerRateLimit = rateLimit;
284284

285285
// Give this a moment
286-
Thread.sleep(1000);
286+
Thread.sleep(1500);
287287

288288
// ratelimit() uses headerRateLimit if available and headerRateLimit is not expired
289289
assertThat(gitHub.rateLimit(), sameInstance(headerRateLimit));
290290

291291
assertThat(mockGitHub.getRequestCount(), equalTo(5));
292292

293293
// Give this a moment
294-
Thread.sleep(1000);
294+
Thread.sleep(1500);
295295

296296
// Always requests new info
297297
rateLimit = gitHub.getRateLimit();
@@ -308,7 +308,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
308308
assertThat(mockGitHub.getRequestCount(), equalTo(6));
309309

310310
// Wait for the header
311-
Thread.sleep(1000);
311+
Thread.sleep(1500);
312312
}
313313

314314
@Test
@@ -361,7 +361,7 @@ private void executeExpirationTest() throws Exception {
361361
GHRateLimit headerRateLimit = null;
362362

363363
// Give this a moment
364-
Thread.sleep(1000);
364+
Thread.sleep(1500);
365365

366366
// -------------------------------------------------------------
367367
// /user gets response with rate limit information
@@ -380,7 +380,7 @@ private void executeExpirationTest() throws Exception {
380380
sameInstance(headerRateLimit));
381381

382382
// Nothing changes still valid
383-
Thread.sleep(1000);
383+
Thread.sleep(1500);
384384

385385
assertThat("rateLimit() selects header instance when not expired, does not ask server",
386386
gitHub.rateLimit(),
@@ -392,7 +392,7 @@ private void executeExpirationTest() throws Exception {
392392
assertThat(mockGitHub.getRequestCount(), equalTo(1));
393393

394394
// This time, rateLimit() should find an expired record and get a new one.
395-
Thread.sleep(3000);
395+
Thread.sleep(2500);
396396

397397
assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true));
398398

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 212446528,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
2+
"id": 251751384,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
44
"name": "github-api-test-rename",
55
"full_name": "bitwiseman/github-api-test-rename",
66
"private": false,
@@ -64,9 +64,9 @@
6464
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
6565
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
67-
"created_at": "2019-10-02T21:40:00Z",
68-
"updated_at": "2019-10-02T21:40:01Z",
69-
"pushed_at": "2019-10-02T21:40:01Z",
67+
"created_at": "2020-03-31T21:52:44Z",
68+
"updated_at": "2020-03-31T21:52:45Z",
69+
"pushed_at": "2020-03-31T21:52:45Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -99,6 +99,7 @@
9999
"allow_squash_merge": true,
100100
"allow_merge_commit": true,
101101
"allow_rebase_merge": true,
102+
"delete_branch_on_merge": false,
102103
"network_count": 0,
103104
"subscribers_count": 1
104105
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 212446528,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
2+
"id": 251751384,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
44
"name": "github-api-test-rename",
55
"full_name": "bitwiseman/github-api-test-rename",
66
"private": false,
@@ -64,9 +64,9 @@
6464
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
6565
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
67-
"created_at": "2019-10-02T21:40:00Z",
68-
"updated_at": "2019-10-02T21:40:01Z",
69-
"pushed_at": "2019-10-02T21:40:01Z",
67+
"created_at": "2020-03-31T21:52:44Z",
68+
"updated_at": "2020-03-31T21:52:46Z",
69+
"pushed_at": "2020-03-31T21:52:45Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -99,6 +99,7 @@
9999
"allow_squash_merge": true,
100100
"allow_merge_commit": true,
101101
"allow_rebase_merge": true,
102+
"delete_branch_on_merge": false,
102103
"network_count": 0,
103104
"subscribers_count": 1
104105
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 212446528,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0NDY1Mjg=",
2+
"id": 251751384,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
44
"name": "github-api-test-rename",
55
"full_name": "bitwiseman/github-api-test-rename",
66
"private": false,
@@ -64,9 +64,9 @@
6464
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/labels{/name}",
6565
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename/deployments",
67-
"created_at": "2019-10-02T21:40:00Z",
68-
"updated_at": "2019-10-02T21:40:02Z",
69-
"pushed_at": "2019-10-02T21:40:01Z",
67+
"created_at": "2020-03-31T21:52:44Z",
68+
"updated_at": "2020-03-31T21:52:46Z",
69+
"pushed_at": "2020-03-31T21:52:45Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "[email protected]:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -99,6 +99,7 @@
9999
"allow_squash_merge": true,
100100
"allow_merge_commit": true,
101101
"allow_rebase_merge": true,
102+
"delete_branch_on_merge": false,
102103
"network_count": 0,
103104
"subscribers_count": 1
104105
}

0 commit comments

Comments
 (0)