Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
3d4071c3
Commit
3d4071c3
authored
Jul 23, 2014
by
caguilar187
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sanitizing slugs for urls
parent
35cff092
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+15
-11
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
3d4071c3
...
...
@@ -92,8 +92,8 @@ public class GitlabAPI {
// Get single project
// GET /projects/:id
public
GitlabProject
getProject
(
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
;
public
GitlabProject
getProject
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
;
return
retrieve
().
to
(
tailUrl
,
GitlabProject
.
class
);
}
...
...
@@ -124,8 +124,8 @@ public class GitlabAPI {
// Get list of project hooks for a project
// GET /projects/:id/hooks
public
List
<
GitlabProjectHook
>
getProjectHooks
(
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabProjectHook
.
URL
;
public
List
<
GitlabProjectHook
>
getProjectHooks
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
GitlabProjectHook
.
URL
;
GitlabProjectHook
[]
hooks
=
retrieve
().
to
(
tailUrl
,
GitlabProjectHook
[].
class
);
return
Arrays
.
asList
(
hooks
);
...
...
@@ -133,8 +133,8 @@ public class GitlabAPI {
// Create a new project hook
// POST /projects/:id/hooks
public
GitlabProjectHook
createProjectHook
(
Integer
projectId
,
String
url
,
boolean
pushEvents
,
boolean
issuesEvents
,
boolean
mergeRequestEvents
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabProjectHook
.
URL
;
public
GitlabProjectHook
createProjectHook
(
String
projectId
,
String
url
,
boolean
pushEvents
,
boolean
issuesEvents
,
boolean
mergeRequestEvents
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
GitlabProjectHook
.
URL
;
return
dispatch
()
.
with
(
"url"
,
url
)
...
...
@@ -174,8 +174,8 @@ public class GitlabAPI {
// List merge requests for a project id
// GET /projects/:id/merge_requests
public
List
<
GitlabMergeRequest
>
getMergeRequests
(
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabMergeRequest
.
URL
;
public
List
<
GitlabMergeRequest
>
getMergeRequests
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
GitlabMergeRequest
.
URL
;
return
fetchMergeRequests
(
tailUrl
);
}
...
...
@@ -265,7 +265,7 @@ public class GitlabAPI {
// Get a specific commit identified by the commit hash or name of a branch or tag
// GET /projects/:id/repository/commits/:sha
public
GitlabCommit
getCommit
(
String
projectId
,
String
commitHash
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
"/repository/commits/"
+
commitHash
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
"/repository/commits/"
+
commitHash
;
GitlabCommit
commit
=
retrieve
().
to
(
tailUrl
,
GitlabCommit
.
class
);
return
commit
;
}
...
...
@@ -283,7 +283,7 @@ public class GitlabAPI {
// List commit diffs for a project ID and commit hash
// GET /projects/:id/repository/commits/:sha/diff
public
List
<
GitlabCommitDiff
>
getCommitDiffs
(
String
projectId
,
String
commitHash
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
"/repository/commits/"
+
commitHash
+
GitlabCommitDiff
.
URL
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
"/repository/commits/"
+
commitHash
+
GitlabCommitDiff
.
URL
;
GitlabCommitDiff
[]
diffs
=
retrieve
().
to
(
tailUrl
,
GitlabCommitDiff
[].
class
);
return
Arrays
.
asList
(
diffs
);
}
...
...
@@ -291,7 +291,7 @@ public class GitlabAPI {
// Get a list of repository branches from a project, sorted by name alphabetically.
// GET /projects/:id/repository/branches
public
List
<
GitlabBranch
>
getBranches
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
"/repository"
+
GitlabBranch
.
URL
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
"/repository"
+
GitlabBranch
.
URL
;
GitlabBranch
[]
branches
=
retrieve
().
to
(
tailUrl
,
GitlabBranch
[].
class
);
return
Arrays
.
asList
(
branches
);
}
...
...
@@ -344,4 +344,8 @@ public class GitlabAPI {
GitlabUser
user
=
retrieve
().
to
(
tailUrl
,
GitlabUser
.
class
);
return
user
;
}
private
String
sanitizeProjectId
(
String
projectId
)
{
return
projectId
.
replace
(
"/"
,
"%2F"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment