Skip to content

Commit 0abb1d2

Browse files
committed
Changed processing of whitespace on content properties (#136).
1 parent f5a54d5 commit 0abb1d2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/org/gitlab4j/api/GitLabApiForm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected GitLabApiForm withParam(String name, Object value, boolean required) t
4848
return (this);
4949
}
5050

51-
String stringValue = value.toString().trim();
52-
if (required && stringValue.length() == 0) {
51+
String stringValue = value.toString();
52+
if (required && stringValue.trim().length() == 0) {
5353
throw new IllegalArgumentException(name + " cannot be empty or null");
5454
}
5555

src/main/java/org/gitlab4j/api/RepositoryFileApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected RepositoryFile getFileV3(String filePath, Integer projectId, String re
8686
* @throws GitLabApiException if any exception occurs
8787
*/
8888
public RepositoryFile createFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException {
89-
Form formData = file2form(file, branchName, commitMessage);
89+
Form formData = createForm(file, branchName, commitMessage);
9090
Response response;
9191
if (isApiVersion(ApiVersion.V3)) {
9292
response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files");
@@ -116,7 +116,7 @@ public RepositoryFile createFile(RepositoryFile file, Integer projectId, String
116116
* @throws GitLabApiException if any exception occurs
117117
*/
118118
public RepositoryFile updateFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException {
119-
Form formData = file2form(file, branchName, commitMessage);
119+
Form formData = createForm(file, branchName, commitMessage);
120120
Response response;
121121
if (isApiVersion(ApiVersion.V3)) {
122122
response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "files");
@@ -215,7 +215,7 @@ public InputStream getRawFile(Integer projectId, String commitOrBranchName, Stri
215215
return (response.readEntity(InputStream.class));
216216
}
217217

218-
private Form file2form(RepositoryFile file, String branchName, String commitMessage) {
218+
private Form createForm(RepositoryFile file, String branchName, String commitMessage) {
219219

220220
Form form = new Form();
221221
if (isApiVersion(ApiVersion.V3)) {
@@ -228,6 +228,6 @@ private Form file2form(RepositoryFile file, String branchName, String commitMess
228228
addFormParam(form, "encoding", file.getEncoding(), false);
229229
addFormParam(form, "content", file.getContent(), true);
230230
addFormParam(form, "commit_message", commitMessage, true);
231-
return form;
231+
return (form);
232232
}
233233
}

0 commit comments

Comments
 (0)