Skip to content

make getProject take unescaped group id, like getGroup #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/main/java/org/gitlab/api/GitlabAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public GitlabProject getProject(Serializable projectId) throws IOException {
* use namespace & project name to get project
*/
public GitlabProject getProject(String namespace, String projectName) throws IOException{
String tailUrl = GitlabProject.URL + "/" + namespace + "%2F" + projectName;
String tailUrl = GitlabProject.URL + "/" + sanitizeGroupId(namespace) + "%2F" + sanitizeProjectId(projectName);
return retrieve().to(tailUrl, GitlabProject.class);
}

Expand Down Expand Up @@ -1131,7 +1131,7 @@ public GitlabCommit cherryPick(GitlabProject project, String sha, String targetB
* @throws IOException on gitlab api call error
*/
public GitlabMergeRequest getMergeRequestByIid(Serializable projectId, Integer mergeRequestIid) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabMergeRequest.URL + "/" + mergeRequestIid;
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + "/" + mergeRequestIid;
return retrieve().to(tailUrl, GitlabMergeRequest.class);
}

Expand Down Expand Up @@ -1283,7 +1283,7 @@ public List<GitlabCommit> getCommits(GitlabMergeRequest mergeRequest, Pagination

query.mergeWith(pagination.asQuery());

String tailUrl = GitlabProject.URL + "/" + projectId +
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) +
"/repository" + GitlabCommit.URL + query.toString();

GitlabCommit[] commits = retrieve().to(tailUrl, GitlabCommit[].class);
Expand Down Expand Up @@ -1808,7 +1808,7 @@ public List<GitlabNote> getNotes(GitlabIssue issue) throws IOException {
}

public GitlabNote createNote(Serializable projectId, Integer issueId, String message) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabIssue.URL
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabIssue.URL
+ "/" + issueId + GitlabNote.URL;
return dispatch().with("body", message).to(tailUrl, GitlabNote.class);
}
Expand All @@ -1826,8 +1826,9 @@ public GitlabNote createNote(GitlabIssue issue, String message) throws IOExcepti
* @throws IOException on gitlab api call error
*/
public void deleteNote(Serializable projectId, Integer issueId, GitlabNote noteToDelete) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabIssue.URL + "/"
+ issueId + GitlabNote.URL + "/" + noteToDelete.getId();
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId)
+ GitlabIssue.URL + "/" + issueId + GitlabNote.URL
+ "/" + noteToDelete.getId();
retrieve().method("DELETE").to(tailUrl, GitlabNote.class);
}

Expand All @@ -1850,7 +1851,7 @@ public void deleteNote(GitlabIssue issue, GitlabNote noteToDelete) throws IOExce
*/
public List<GitlabLabel> getLabels(Serializable projectId)
throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
GitlabLabel[] labels = retrieve().to(tailUrl, GitlabLabel[].class);
return Arrays.asList(labels);
}
Expand Down Expand Up @@ -1878,7 +1879,7 @@ public GitlabLabel createLabel(
Serializable projectId,
String name,
String color) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
return dispatch().with("name", name)
.with("color", color)
.to(tailUrl, GitlabLabel.class);
Expand Down Expand Up @@ -1908,7 +1909,7 @@ public void deleteLabel(Serializable projectId, String name)
Query query = new Query();
query.append("name", name);
String tailUrl = GitlabProject.URL + "/" +
projectId +
sanitizeProjectId(projectId) +
GitlabLabel.URL +
query.toString();
retrieve().method("DELETE").to(tailUrl, Void.class);
Expand Down Expand Up @@ -1938,7 +1939,7 @@ public GitlabLabel updateLabel(Serializable projectId,
String name,
String newName,
String newColor) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
GitlabHTTPRequestor requestor = retrieve().method("PUT");
requestor.with("name", name);
if (newName != null) {
Expand Down Expand Up @@ -1984,7 +1985,7 @@ public GitlabMilestone createMilestone(
String description,
Date dueDate,
Date startDate) throws IOException {
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabMilestone.URL;
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMilestone.URL;
GitlabHTTPRequestor requestor = dispatch().with("title", title);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
if (description != null) {
Expand Down Expand Up @@ -2038,7 +2039,7 @@ public GitlabMilestone updateMilestone(
Date startDate,
String stateEvent) throws IOException {
String tailUrl = GitlabProject.URL + "/" +
projectId +
sanitizeProjectId(projectId) +
GitlabMilestone.URL + "/" +
milestoneId;
GitlabHTTPRequestor requestor = retrieve().method("PUT");
Expand Down