Skip to content

Commit f58f32a

Browse files
authored
Merge branch 'master' into create-tree-null-sha-field
2 parents 2c80e07 + 28d8fb6 commit f58f32a

29 files changed

Lines changed: 2236 additions & 5 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
<dependency>
267267
<groupId>junit</groupId>
268268
<artifactId>junit</artifactId>
269-
<version>4.12</version>
269+
<version>4.13</version>
270270
<scope>test</scope>
271271
</dependency>
272272
<dependency>
@@ -537,7 +537,7 @@
537537
<plugin>
538538
<groupId>org.apache.maven.plugins</groupId>
539539
<artifactId>maven-source-plugin</artifactId>
540-
<version>3.2.0</version>
540+
<version>3.2.1</version>
541541
</plugin>
542542
</plugins>
543543
</build>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public GHBlobBuilder textContent(String content) {
3636
* @return a GHBlobBuilder
3737
*/
3838
public GHBlobBuilder binaryContent(byte[] content) {
39-
String base64Content = Base64.getMimeEncoder().encodeToString(content);
39+
String base64Content = Base64.getEncoder().encodeToString(content);
4040
req.with("content", base64Content);
4141
req.with("encoding", "base64");
4242
return this;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa
306306
*/
307307
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
308308
throws IOException {
309-
String encodedContent = Base64.getMimeEncoder().encodeToString(newContentBytes);
309+
String encodedContent = Base64.getEncoder().encodeToString(newContentBytes);
310310

311311
Requester requester = root.createRequest()
312312
.method("POST")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public GHContentBuilder sha(String sha) {
6868
* @return the gh content builder
6969
*/
7070
public GHContentBuilder content(byte[] content) {
71-
req.with("content", Base64.getMimeEncoder().encodeToString(content));
71+
req.with("content", Base64.getEncoder().encodeToString(content));
7272
return this;
7373
}
7474

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,36 @@ public void testCRUDContent() throws Exception {
125125
equalTo("{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/contents/#get-contents\"}"));
126126
}
127127
}
128+
129+
@Test
130+
public void testMIMESmall() throws IOException {
131+
GHRepository ghRepository = getTempRepository();
132+
GHContentBuilder ghContentBuilder = ghRepository.createContent();
133+
ghContentBuilder.message("Some commit msg");
134+
ghContentBuilder.path("MIME-Small.md");
135+
ghContentBuilder.content("123456789012345678901234567890123456789012345678901234567");
136+
ghContentBuilder.commit();
137+
}
138+
139+
@Test
140+
public void testMIMELong() throws IOException {
141+
GHRepository ghRepository = getTempRepository();
142+
GHContentBuilder ghContentBuilder = ghRepository.createContent();
143+
ghContentBuilder.message("Some commit msg");
144+
ghContentBuilder.path("MIME-Long.md");
145+
ghContentBuilder.content("1234567890123456789012345678901234567890123456789012345678");
146+
ghContentBuilder.commit();
147+
}
148+
@Test
149+
public void testMIMELonger() throws IOException {
150+
GHRepository ghRepository = getTempRepository();
151+
GHContentBuilder ghContentBuilder = ghRepository.createContent();
152+
ghContentBuilder.message("Some commit msg");
153+
ghContentBuilder.path("MIME-Long.md");
154+
ghContentBuilder.content("123456789012345678901234567890123456789012345678901234567890"
155+
+ "123456789012345678901234567890123456789012345678901234567890"
156+
+ "123456789012345678901234567890123456789012345678901234567890"
157+
+ "123456789012345678901234567890123456789012345678901234567890");
158+
ghContentBuilder.commit();
159+
}
128160
}

src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testMIMELong/__files/repos_github-api-test-org_ghcontentintegrationtest-558c17cf-aa4d-452c-8791-7b2f196ef7e1.json

Lines changed: 313 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"id": 229372064,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkyMjkzNzIwNjQ=",
4+
"name": "temp-testMIMELong",
5+
"full_name": "github-api-test-org/temp-testMIMELong",
6+
"private": false,
7+
"owner": {
8+
"login": "github-api-test-org",
9+
"id": 7544739,
10+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
11+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/github-api-test-org",
14+
"html_url": "https://github.com/github-api-test-org",
15+
"followers_url": "https://api.github.com/users/github-api-test-org/followers",
16+
"following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions",
20+
"organizations_url": "https://api.github.com/users/github-api-test-org/orgs",
21+
"repos_url": "https://api.github.com/users/github-api-test-org/repos",
22+
"events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/github-api-test-org/received_events",
24+
"type": "Organization",
25+
"site_admin": false
26+
},
27+
"html_url": "https://github.com/github-api-test-org/temp-testMIMELong",
28+
"description": "A test repository for testing the github-api project: temp-testMIMELong",
29+
"fork": false,
30+
"url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong",
31+
"forks_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/forks",
32+
"keys_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/keys{/key_id}",
33+
"collaborators_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/collaborators{/collaborator}",
34+
"teams_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/teams",
35+
"hooks_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/hooks",
36+
"issue_events_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/issues/events{/number}",
37+
"events_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/events",
38+
"assignees_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/assignees{/user}",
39+
"branches_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/branches{/branch}",
40+
"tags_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/tags",
41+
"blobs_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/blobs{/sha}",
42+
"git_tags_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/tags{/sha}",
43+
"git_refs_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/refs{/sha}",
44+
"trees_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/trees{/sha}",
45+
"statuses_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/statuses/{sha}",
46+
"languages_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/languages",
47+
"stargazers_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/stargazers",
48+
"contributors_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/contributors",
49+
"subscribers_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/subscribers",
50+
"subscription_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/subscription",
51+
"commits_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/commits{/sha}",
52+
"git_commits_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/commits{/sha}",
53+
"comments_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/comments{/number}",
54+
"issue_comment_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/issues/comments{/number}",
55+
"contents_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/contents/{+path}",
56+
"compare_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/compare/{base}...{head}",
57+
"merges_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/merges",
58+
"archive_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/{archive_format}{/ref}",
59+
"downloads_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/downloads",
60+
"issues_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/issues{/number}",
61+
"pulls_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/pulls{/number}",
62+
"milestones_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/milestones{/number}",
63+
"notifications_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/notifications{?since,all,participating}",
64+
"labels_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/labels{/name}",
65+
"releases_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/releases{/id}",
66+
"deployments_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/deployments",
67+
"created_at": "2019-12-21T03:42:26Z",
68+
"updated_at": "2019-12-21T03:42:30Z",
69+
"pushed_at": "2019-12-21T03:42:28Z",
70+
"git_url": "git://github.com/github-api-test-org/temp-testMIMELong.git",
71+
"ssh_url": "git@github.com:github-api-test-org/temp-testMIMELong.git",
72+
"clone_url": "https://github.com/github-api-test-org/temp-testMIMELong.git",
73+
"svn_url": "https://github.com/github-api-test-org/temp-testMIMELong",
74+
"homepage": "http://github-api.kohsuke.org/",
75+
"size": 0,
76+
"stargazers_count": 0,
77+
"watchers_count": 0,
78+
"language": null,
79+
"has_issues": true,
80+
"has_projects": true,
81+
"has_downloads": true,
82+
"has_wiki": true,
83+
"has_pages": false,
84+
"forks_count": 0,
85+
"mirror_url": null,
86+
"archived": false,
87+
"disabled": false,
88+
"open_issues_count": 0,
89+
"license": null,
90+
"forks": 0,
91+
"open_issues": 0,
92+
"watchers": 0,
93+
"default_branch": "master",
94+
"permissions": {
95+
"admin": true,
96+
"push": true,
97+
"pull": true
98+
},
99+
"temp_clone_token": "",
100+
"allow_squash_merge": true,
101+
"allow_merge_commit": true,
102+
"allow_rebase_merge": true,
103+
"organization": {
104+
"login": "github-api-test-org",
105+
"id": 7544739,
106+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
107+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
108+
"gravatar_id": "",
109+
"url": "https://api.github.com/users/github-api-test-org",
110+
"html_url": "https://github.com/github-api-test-org",
111+
"followers_url": "https://api.github.com/users/github-api-test-org/followers",
112+
"following_url": "https://api.github.com/users/github-api-test-org/following{/other_user}",
113+
"gists_url": "https://api.github.com/users/github-api-test-org/gists{/gist_id}",
114+
"starred_url": "https://api.github.com/users/github-api-test-org/starred{/owner}{/repo}",
115+
"subscriptions_url": "https://api.github.com/users/github-api-test-org/subscriptions",
116+
"organizations_url": "https://api.github.com/users/github-api-test-org/orgs",
117+
"repos_url": "https://api.github.com/users/github-api-test-org/repos",
118+
"events_url": "https://api.github.com/users/github-api-test-org/events{/privacy}",
119+
"received_events_url": "https://api.github.com/users/github-api-test-org/received_events",
120+
"type": "Organization",
121+
"site_admin": false
122+
},
123+
"network_count": 0,
124+
"subscribers_count": 6
125+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"content": {
3+
"name": "MIME-Long.md",
4+
"path": "MIME-Long.md",
5+
"sha": "e6a493cf0e30d4fc2d3cc60f690d96fec005a170",
6+
"size": 58,
7+
"url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/contents/MIME-Long.md?ref=master",
8+
"html_url": "https://github.com/github-api-test-org/temp-testMIMELong/blob/master/MIME-Long.md",
9+
"git_url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/blobs/e6a493cf0e30d4fc2d3cc60f690d96fec005a170",
10+
"download_url": "https://raw.githubusercontent.com/github-api-test-org/temp-testMIMELong/master/MIME-Long.md",
11+
"type": "file",
12+
"_links": {
13+
"self": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/contents/MIME-Long.md?ref=master",
14+
"git": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/blobs/e6a493cf0e30d4fc2d3cc60f690d96fec005a170",
15+
"html": "https://github.com/github-api-test-org/temp-testMIMELong/blob/master/MIME-Long.md"
16+
}
17+
},
18+
"commit": {
19+
"sha": "bc198978c7012926287e95064ec992caceff2834",
20+
"node_id": "MDY6Q29tbWl0MjI5MzcyMDY0OmJjMTk4OTc4YzcwMTI5MjYyODdlOTUwNjRlYzk5MmNhY2VmZjI4MzQ=",
21+
"url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/commits/bc198978c7012926287e95064ec992caceff2834",
22+
"html_url": "https://github.com/github-api-test-org/temp-testMIMELong/commit/bc198978c7012926287e95064ec992caceff2834",
23+
"author": {
24+
"name": "Liam Newman",
25+
"email": "bitwiseman@gmail.com",
26+
"date": "2019-12-21T03:42:31Z"
27+
},
28+
"committer": {
29+
"name": "Liam Newman",
30+
"email": "bitwiseman@gmail.com",
31+
"date": "2019-12-21T03:42:31Z"
32+
},
33+
"tree": {
34+
"sha": "f36282123bcb22ebda37370be4a9979c26818327",
35+
"url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/trees/f36282123bcb22ebda37370be4a9979c26818327"
36+
},
37+
"message": "Some commit msg",
38+
"parents": [
39+
{
40+
"sha": "9f75c8798e50499575231b3e322249824e92f83d",
41+
"url": "https://api.github.com/repos/github-api-test-org/temp-testMIMELong/git/commits/9f75c8798e50499575231b3e322249824e92f83d",
42+
"html_url": "https://github.com/github-api-test-org/temp-testMIMELong/commit/9f75c8798e50499575231b3e322249824e92f83d"
43+
}
44+
],
45+
"verification": {
46+
"verified": false,
47+
"reason": "unsigned",
48+
"signature": null,
49+
"payload": null
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"login": "bitwiseman",
3+
"id": 1958953,
4+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
5+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/bitwiseman",
8+
"html_url": "https://github.com/bitwiseman",
9+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
10+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
14+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
15+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
16+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": "Liam Newman",
21+
"company": "Cloudbees, Inc.",
22+
"blog": "",
23+
"location": "Seattle, WA, USA",
24+
"email": "bitwiseman@gmail.com",
25+
"hireable": null,
26+
"bio": "https://twitter.com/bitwiseman",
27+
"public_repos": 178,
28+
"public_gists": 7,
29+
"followers": 144,
30+
"following": 9,
31+
"created_at": "2012-07-11T20:38:33Z",
32+
"updated_at": "2019-12-18T01:26:55Z",
33+
"private_gists": 7,
34+
"total_private_repos": 10,
35+
"owned_private_repos": 0,
36+
"disk_usage": 33697,
37+
"collaborators": 0,
38+
"two_factor_authentication": true,
39+
"plan": {
40+
"name": "free",
41+
"space": 976562499,
42+
"collaborators": 0,
43+
"private_repos": 10000
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "558c17cf-aa4d-452c-8791-7b2f196ef7e1",
3+
"name": "repos_github-api-test-org_ghcontentintegrationtest",
4+
"request": {
5+
"url": "/repos/github-api-test-org/GHContentIntegrationTest",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "repos_github-api-test-org_ghcontentintegrationtest-558c17cf-aa4d-452c-8791-7b2f196ef7e1.json",
16+
"headers": {
17+
"Date": "Sat, 21 Dec 2019 03:42:25 GMT",
18+
"Content-Type": "application/json; charset=utf-8",
19+
"Server": "GitHub.com",
20+
"Status": "200 OK",
21+
"X-RateLimit-Limit": "5000",
22+
"X-RateLimit-Remaining": "4967",
23+
"X-RateLimit-Reset": "1576903221",
24+
"Cache-Control": "private, max-age=60, s-maxage=60",
25+
"Vary": [
26+
"Accept, Authorization, Cookie, X-GitHub-OTP",
27+
"Accept-Encoding"
28+
],
29+
"ETag": "W/\"1e430d4199aa33f3d4673fee6fee2709\"",
30+
"Last-Modified": "Tue, 26 Nov 2019 01:09:49 GMT",
31+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
32+
"X-Accepted-OAuth-Scopes": "repo",
33+
"X-GitHub-Media-Type": "unknown, github.v3",
34+
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type",
35+
"Access-Control-Allow-Origin": "*",
36+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
37+
"X-Frame-Options": "deny",
38+
"X-Content-Type-Options": "nosniff",
39+
"X-XSS-Protection": "1; mode=block",
40+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
41+
"Content-Security-Policy": "default-src 'none'",
42+
"X-GitHub-Request-Id": "C989:1F58:E9F71A:11C8906:5DFD94A0"
43+
}
44+
},
45+
"uuid": "558c17cf-aa4d-452c-8791-7b2f196ef7e1",
46+
"persistent": true,
47+
"insertionIndex": 2
48+
}

0 commit comments

Comments
 (0)