Skip to content

Commit c0c2ec2

Browse files
committed
make various methods which take project and group ids take the
unescaped versions, just like getGroup()
1 parent 62b45f4 commit c0c2ec2

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/main/java/org/gitlab/api/GitlabAPI.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ public GitlabProject getProject(Serializable projectId) throws IOException {
615615
* use namespace & project name to get project
616616
*/
617617
public GitlabProject getProject(String namespace, String projectName) throws IOException{
618-
String tailUrl = GitlabProject.URL + "/" + namespace + "%2F" + projectName;
618+
String tailUrl = GitlabProject.URL + "/" + sanitizeGroupId(namespace) + "%2F" + sanitizeProjectId(projectName);
619619
return retrieve().to(tailUrl, GitlabProject.class);
620620
}
621621

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

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

12841284
query.mergeWith(pagination.asQuery());
12851285

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

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

18101810
public GitlabNote createNote(Serializable projectId, Integer issueId, String message) throws IOException {
1811-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabIssue.URL
1811+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabIssue.URL
18121812
+ "/" + issueId + GitlabNote.URL;
18131813
return dispatch().with("body", message).to(tailUrl, GitlabNote.class);
18141814
}
@@ -1826,8 +1826,9 @@ public GitlabNote createNote(GitlabIssue issue, String message) throws IOExcepti
18261826
* @throws IOException on gitlab api call error
18271827
*/
18281828
public void deleteNote(Serializable projectId, Integer issueId, GitlabNote noteToDelete) throws IOException {
1829-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabIssue.URL + "/"
1830-
+ issueId + GitlabNote.URL + "/" + noteToDelete.getId();
1829+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId)
1830+
+ GitlabIssue.URL + "/" + issueId + GitlabNote.URL
1831+
+ "/" + noteToDelete.getId();
18311832
retrieve().method("DELETE").to(tailUrl, GitlabNote.class);
18321833
}
18331834

@@ -1850,7 +1851,7 @@ public void deleteNote(GitlabIssue issue, GitlabNote noteToDelete) throws IOExce
18501851
*/
18511852
public List<GitlabLabel> getLabels(Serializable projectId)
18521853
throws IOException {
1853-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
1854+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
18541855
GitlabLabel[] labels = retrieve().to(tailUrl, GitlabLabel[].class);
18551856
return Arrays.asList(labels);
18561857
}
@@ -1878,7 +1879,7 @@ public GitlabLabel createLabel(
18781879
Serializable projectId,
18791880
String name,
18801881
String color) throws IOException {
1881-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
1882+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
18821883
return dispatch().with("name", name)
18831884
.with("color", color)
18841885
.to(tailUrl, GitlabLabel.class);
@@ -1908,7 +1909,7 @@ public void deleteLabel(Serializable projectId, String name)
19081909
Query query = new Query();
19091910
query.append("name", name);
19101911
String tailUrl = GitlabProject.URL + "/" +
1911-
projectId +
1912+
sanitizeProjectId(projectId) +
19121913
GitlabLabel.URL +
19131914
query.toString();
19141915
retrieve().method("DELETE").to(tailUrl, Void.class);
@@ -1938,7 +1939,7 @@ public GitlabLabel updateLabel(Serializable projectId,
19381939
String name,
19391940
String newName,
19401941
String newColor) throws IOException {
1941-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabLabel.URL;
1942+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabLabel.URL;
19421943
GitlabHTTPRequestor requestor = retrieve().method("PUT");
19431944
requestor.with("name", name);
19441945
if (newName != null) {
@@ -1984,7 +1985,7 @@ public GitlabMilestone createMilestone(
19841985
String description,
19851986
Date dueDate,
19861987
Date startDate) throws IOException {
1987-
String tailUrl = GitlabProject.URL + "/" + projectId + GitlabMilestone.URL;
1988+
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMilestone.URL;
19881989
GitlabHTTPRequestor requestor = dispatch().with("title", title);
19891990
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
19901991
if (description != null) {
@@ -2038,7 +2039,7 @@ public GitlabMilestone updateMilestone(
20382039
Date startDate,
20392040
String stateEvent) throws IOException {
20402041
String tailUrl = GitlabProject.URL + "/" +
2041-
projectId +
2042+
sanitizeProjectId(projectId) +
20422043
GitlabMilestone.URL + "/" +
20432044
milestoneId;
20442045
GitlabHTTPRequestor requestor = retrieve().method("PUT");

0 commit comments

Comments
 (0)