Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 865a49d

Browse filesBrowse files
committed
Update GHRepository method to use Setter
It appears that the correct way to pass these booleans is as booleans not as strings. Fixes hub4j#765
1 parent 4fca68c commit 865a49d
Copy full SHA for 865a49d

File tree

Expand file treeCollapse file tree

35 files changed

+219
-205
lines changed
Filter options
Expand file treeCollapse file tree

35 files changed

+219
-205
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+24-24Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,14 +1087,6 @@ public void setEmailServiceHook(String address) throws IOException {
10871087
.send();
10881088
}
10891089

1090-
private void edit(String key, String value) throws IOException {
1091-
Requester requester = root.createRequest();
1092-
if (!key.equals("name")) {
1093-
requester.with("name", name); // even when we don't change the name, we need to send it in
1094-
}
1095-
requester.with(key, value).method("PATCH").withUrlPath(getApiTailUrl("")).send();
1096-
}
1097-
10981090
/**
10991091
* Enables or disables the issue tracker for this repository.
11001092
*
@@ -1104,7 +1096,7 @@ private void edit(String key, String value) throws IOException {
11041096
* the io exception
11051097
*/
11061098
public void enableIssueTracker(boolean v) throws IOException {
1107-
edit("has_issues", String.valueOf(v));
1099+
set().issues(v);
11081100
}
11091101

11101102
/**
@@ -1116,7 +1108,7 @@ public void enableIssueTracker(boolean v) throws IOException {
11161108
* the io exception
11171109
*/
11181110
public void enableProjects(boolean v) throws IOException {
1119-
edit("has_projects", String.valueOf(v));
1111+
set().projects(v);
11201112
}
11211113

11221114
/**
@@ -1128,7 +1120,7 @@ public void enableProjects(boolean v) throws IOException {
11281120
* the io exception
11291121
*/
11301122
public void enableWiki(boolean v) throws IOException {
1131-
edit("has_wiki", String.valueOf(v));
1123+
set().wiki(v);
11321124
}
11331125

11341126
/**
@@ -1140,7 +1132,7 @@ public void enableWiki(boolean v) throws IOException {
11401132
* the io exception
11411133
*/
11421134
public void enableDownloads(boolean v) throws IOException {
1143-
edit("has_downloads", String.valueOf(v));
1135+
set().downloads(v);
11441136
}
11451137

11461138
/**
@@ -1152,7 +1144,7 @@ public void enableDownloads(boolean v) throws IOException {
11521144
* the io exception
11531145
*/
11541146
public void renameTo(String name) throws IOException {
1155-
edit("name", name);
1147+
set().name(name);
11561148
}
11571149

11581150
/**
@@ -1164,7 +1156,7 @@ public void renameTo(String name) throws IOException {
11641156
* the io exception
11651157
*/
11661158
public void setDescription(String value) throws IOException {
1167-
edit("description", value);
1159+
set().description(value);
11681160
}
11691161

11701162
/**
@@ -1176,7 +1168,7 @@ public void setDescription(String value) throws IOException {
11761168
* the io exception
11771169
*/
11781170
public void setHomepage(String value) throws IOException {
1179-
edit("homepage", value);
1171+
set().homepage(value);
11801172
}
11811173

11821174
/**
@@ -1188,7 +1180,7 @@ public void setHomepage(String value) throws IOException {
11881180
* the io exception
11891181
*/
11901182
public void setDefaultBranch(String value) throws IOException {
1191-
edit("default_branch", value);
1183+
set().defaultBranch(value);
11921184
}
11931185

11941186
/**
@@ -1200,7 +1192,7 @@ public void setDefaultBranch(String value) throws IOException {
12001192
* the io exception
12011193
*/
12021194
public void setPrivate(boolean value) throws IOException {
1203-
edit("private", Boolean.toString(value));
1195+
set().private_(value);
12041196
}
12051197

12061198
/**
@@ -1212,7 +1204,7 @@ public void setPrivate(boolean value) throws IOException {
12121204
* the io exception
12131205
*/
12141206
public void allowSquashMerge(boolean value) throws IOException {
1215-
edit("allow_squash_merge", Boolean.toString(value));
1207+
set().allowSquashMerge(value);
12161208
}
12171209

12181210
/**
@@ -1224,7 +1216,7 @@ public void allowSquashMerge(boolean value) throws IOException {
12241216
* the io exception
12251217
*/
12261218
public void allowMergeCommit(boolean value) throws IOException {
1227-
edit("allow_merge_commit", Boolean.toString(value));
1219+
set().allowMergeCommit(value);
12281220
}
12291221

12301222
/**
@@ -1236,7 +1228,7 @@ public void allowMergeCommit(boolean value) throws IOException {
12361228
* the io exception
12371229
*/
12381230
public void allowRebaseMerge(boolean value) throws IOException {
1239-
edit("allow_rebase_merge", Boolean.toString(value));
1231+
set().allowRebaseMerge(value);
12401232
}
12411233

12421234
/**
@@ -1248,7 +1240,7 @@ public void allowRebaseMerge(boolean value) throws IOException {
12481240
* the io exception
12491241
*/
12501242
public void deleteBranchOnMerge(boolean value) throws IOException {
1251-
edit("delete_branch_on_merge", Boolean.toString(value));
1243+
set().deleteBranchOnMerge(value);
12521244
}
12531245

12541246
/**
@@ -1285,9 +1277,9 @@ public void delete() throws IOException {
12851277
* In case of any networking error or error from the server.
12861278
*/
12871279
public void archive() throws IOException {
1288-
edit("archived", "true");
1289-
// Generall would not update this record,
1290-
// but do so here since this will result in any other update actions failing
1280+
set().archive();
1281+
// Generally would not update this record,
1282+
// but doing so here since this will result in any other update actions failing
12911283
archived = true;
12921284
}
12931285

@@ -3013,6 +3005,10 @@ void populate() throws IOException {
30133005
public static class Updater extends GHRepositoryBuilder<Updater> {
30143006
protected Updater(@Nonnull GHRepository repository) {
30153007
super(Updater.class, repository.root, null);
3008+
// even when we don't change the name, we need to send it in
3009+
// this requirement may be out-of-date, but we do not want to break it
3010+
requester.with("name", repository.name);
3011+
30163012
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
30173013
}
30183014
}
@@ -3027,6 +3023,10 @@ protected Updater(@Nonnull GHRepository repository) {
30273023
public static class Setter extends GHRepositoryBuilder<GHRepository> {
30283024
protected Setter(@Nonnull GHRepository repository) {
30293025
super(GHRepository.class, repository.root, null);
3026+
// even when we don't change the name, we need to send it in
3027+
// this requirement may be out-of-date, but we do not want to break it
3028+
requester.with("name", repository.name);
3029+
30303030
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
30313031
}
30323032
}

‎src/main/java/org/kohsuke/github/GHRepositoryBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepositoryBuilder.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public GHRepository done() throws IOException {
208208
}
209209

210210
S archive() throws IOException {
211-
return with("archived", "true");
211+
return with("archived", true);
212212
}
213213

214214
S name(String name) throws IOException {

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AppTest.java
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public void testRepoCRUD() throws Exception {
6969
assertThat(r.hasDownloads(), is(false));
7070
assertThat(r.getName(), equalTo(targetName));
7171

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

7774
r.delete();
7875
}

‎src/test/java/org/kohsuke/github/GHRepositoryTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHRepositoryTest.java
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public void testGetters() throws IOException {
5555

5656
@Test
5757
public void archive() throws Exception {
58+
// Archive is a one-way action in the API.
59+
// After taking snapshot, manual state reset is required.
5860
snapshotNotAllowed();
5961

60-
// Archive is a one-way action in the API.
61-
// We do thi this one
6262
GHRepository repo = getRepository();
6363

6464
assertThat(repo.isArchived(), is(false));
@@ -197,11 +197,7 @@ public void testUpdateRepository() throws Exception {
197197
assertEquals(description, updated.getDescription());
198198

199199
// test the other merge option and making the repo public again
200-
GHRepository redux = updated.update()
201-
.allowMergeCommit(false)
202-
.allowRebaseMerge(true)
203-
.private_(false)
204-
.done();
200+
GHRepository redux = updated.update().allowMergeCommit(false).allowRebaseMerge(true).private_(false).done();
205201

206202
assertFalse(redux.isAllowMergeCommit());
207203
assertTrue(redux.isAllowRebaseMerge());

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-3.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-3.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 251751384,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
2+
"id": 325161462,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkzMjUxNjE0NjI=",
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": "2020-03-31T21:52:44Z",
68-
"updated_at": "2020-03-31T21:52:45Z",
69-
"pushed_at": "2020-03-31T21:52:45Z",
67+
"created_at": "2020-12-29T02:01:46Z",
68+
"updated_at": "2020-12-29T02:01:48Z",
69+
"pushed_at": "2020-12-29T02:01:48Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "git@github.com:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -90,7 +90,7 @@
9090
"forks": 0,
9191
"open_issues": 0,
9292
"watchers": 0,
93-
"default_branch": "master",
93+
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
9696
"push": true,

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-4.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-4.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 251751384,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
2+
"id": 325161462,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkzMjUxNjE0NjI=",
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": "2020-03-31T21:52:44Z",
68-
"updated_at": "2020-03-31T21:52:46Z",
69-
"pushed_at": "2020-03-31T21:52:45Z",
67+
"created_at": "2020-12-29T02:01:46Z",
68+
"updated_at": "2020-12-29T02:01:49Z",
69+
"pushed_at": "2020-12-29T02:01:48Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "git@github.com:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -90,7 +90,7 @@
9090
"forks": 0,
9191
"open_issues": 0,
9292
"watchers": 0,
93-
"default_branch": "master",
93+
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
9696
"push": true,

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-5.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-5.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 251751384,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
2+
"id": 325161462,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkzMjUxNjE0NjI=",
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": "2020-03-31T21:52:44Z",
68-
"updated_at": "2020-03-31T21:52:46Z",
69-
"pushed_at": "2020-03-31T21:52:45Z",
67+
"created_at": "2020-12-29T02:01:46Z",
68+
"updated_at": "2020-12-29T02:01:49Z",
69+
"pushed_at": "2020-12-29T02:01:48Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "git@github.com:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -90,7 +90,7 @@
9090
"forks": 0,
9191
"open_issues": 0,
9292
"watchers": 0,
93-
"default_branch": "master",
93+
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
9696
"push": true,

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-6.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-6.json
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 251751384,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
2+
"id": 325161462,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkzMjUxNjE0NjI=",
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": "2020-03-31T21:52:44Z",
68-
"updated_at": "2020-03-31T21:52:47Z",
69-
"pushed_at": "2020-03-31T21:52:45Z",
67+
"created_at": "2020-12-29T02:01:46Z",
68+
"updated_at": "2020-12-29T02:01:49Z",
69+
"pushed_at": "2020-12-29T02:01:48Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename.git",
7171
"ssh_url": "git@github.com:bitwiseman/github-api-test-rename.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename.git",
@@ -77,7 +77,7 @@
7777
"watchers_count": 0,
7878
"language": null,
7979
"has_issues": false,
80-
"has_projects": true,
80+
"has_projects": false,
8181
"has_downloads": false,
8282
"has_wiki": false,
8383
"has_pages": false,
@@ -90,7 +90,7 @@
9090
"forks": 0,
9191
"open_issues": 0,
9292
"watchers": 0,
93-
"default_branch": "master",
93+
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
9696
"push": true,

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-7.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/__files/repos_bitwiseman_github-api-test-rename-7.json
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 251751384,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyNTE3NTEzODQ=",
2+
"id": 325161462,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkzMjUxNjE0NjI=",
44
"name": "github-api-test-rename2",
55
"full_name": "bitwiseman/github-api-test-rename2",
66
"private": false,
@@ -64,9 +64,9 @@
6464
"labels_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/labels{/name}",
6565
"releases_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/bitwiseman/github-api-test-rename2/deployments",
67-
"created_at": "2020-03-31T21:52:44Z",
68-
"updated_at": "2020-03-31T21:52:47Z",
69-
"pushed_at": "2020-03-31T21:52:45Z",
67+
"created_at": "2020-12-29T02:01:46Z",
68+
"updated_at": "2020-12-29T02:01:50Z",
69+
"pushed_at": "2020-12-29T02:01:48Z",
7070
"git_url": "git://github.com/bitwiseman/github-api-test-rename2.git",
7171
"ssh_url": "git@github.com:bitwiseman/github-api-test-rename2.git",
7272
"clone_url": "https://github.com/bitwiseman/github-api-test-rename2.git",
@@ -77,7 +77,7 @@
7777
"watchers_count": 0,
7878
"language": null,
7979
"has_issues": false,
80-
"has_projects": true,
80+
"has_projects": false,
8181
"has_downloads": false,
8282
"has_wiki": false,
8383
"has_pages": false,
@@ -90,7 +90,7 @@
9090
"forks": 0,
9191
"open_issues": 0,
9292
"watchers": 0,
93-
"default_branch": "master",
93+
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
9696
"push": true,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.