forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor format changes from previous merge.
- Loading branch information
Showing
6 changed files
with
119 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,22 @@ | |
|
||
/** | ||
* This class provides an entry point to all the GitLab API repository files calls. | ||
* | ||
* | ||
* @author lonfee88 <[email protected]> | ||
*/ | ||
public class RepositoryFileApi extends AbstractApi { | ||
|
||
public RepositoryFileApi (GitLabApi gitLabApi) { | ||
super(gitLabApi); | ||
} | ||
|
||
/** | ||
* Get file from repository | ||
* Allows you to receive information about file in repository like name, size, content. | ||
* Note that file content is Base64 encoded. | ||
* | ||
* Note that file content is Base64 encoded. | ||
* | ||
* GET /projects/:id/repository/files | ||
* | ||
* | ||
* @param file_path (required) - Full path to new file. Ex. lib/class.rb | ||
* @param projectId | ||
* @param ref (required) - The name of branch, tag or commit | ||
|
@@ -37,18 +37,18 @@ public RepositoryFile getFile(String filePath, Integer projectId, String ref) th | |
Response response = get(Response.Status.OK, form.asMap(),"projects", projectId, "repository", "files"); | ||
return (response.readEntity(RepositoryFile.class)); | ||
} | ||
|
||
/** | ||
* Create new file in repository | ||
* | ||
* | ||
* POST /projects/:id/repository/files | ||
* | ||
* | ||
* file_path (required) - Full path to new file. Ex. lib/class.rb | ||
* branch_name (required) - The name of branch | ||
* encoding (optional) - 'text' or 'base64'. Text is default. | ||
* content (required) - File content | ||
* commit_message (required) - Commit message | ||
* | ||
* | ||
* @param file | ||
* @param projectId | ||
* @param branchName | ||
|
@@ -61,18 +61,18 @@ public RepositoryFile createFile (RepositoryFile file, Integer projectId, String | |
Response response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files"); | ||
return (response.readEntity(RepositoryFile.class)); | ||
} | ||
|
||
/** | ||
* Update existing file in repository | ||
* | ||
* | ||
* PUT /projects/:id/repository/files | ||
* | ||
* | ||
* file_path (required) - Full path to new file. Ex. lib/class.rb | ||
* branch_name (required) - The name of branch | ||
* encoding (optional) - 'text' or 'base64'. Text is default. | ||
* content (required) - File content | ||
* commit_message (required) - Commit message | ||
* | ||
* | ||
* @param file | ||
* @param projectId | ||
* @param branchName | ||
|
@@ -85,35 +85,35 @@ public RepositoryFile updateFile (RepositoryFile file, Integer projectId, String | |
Response response = put(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files"); | ||
return (response.readEntity(RepositoryFile.class)); | ||
} | ||
|
||
/** | ||
* Delete existing file in repository | ||
* | ||
* | ||
* DELETE /projects/:id/repository/files | ||
* | ||
* file_path (required) - Full path to file. Ex. lib/class.rb | ||
* branch_name (required) - The name of branch | ||
* commit_message (required) - Commit message | ||
* | ||
* | ||
* @param filePath | ||
* @param projectId | ||
* @param branchName | ||
* @param commitMessage | ||
* @throws GitLabApiException | ||
*/ | ||
public void deleteFile (String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException { | ||
|
||
if (filePath == null) { | ||
throw new RuntimeException("filePath cannot be null"); | ||
} | ||
|
||
Form form = new Form(); | ||
addFormParam(form, "file_path", filePath, true); | ||
addFormParam(form, "branch_name", branchName, true); | ||
addFormParam(form, "commit_message", commitMessage, true); | ||
delete(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files"); | ||
} | ||
|
||
private Form file2form(RepositoryFile file, String branchName, String commitMessage){ | ||
Form form = new Form(); | ||
addFormParam(form, "file_path", file.getFilePath(), true); | ||
|
@@ -123,5 +123,4 @@ private Form file2form(RepositoryFile file, String branchName, String commitMess | |
addFormParam(form, "commit_message", commitMessage, true); | ||
return form; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.