Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
a913a19b
Commit
a913a19b
authored
Feb 28, 2014
by
Greg Messner
Browse files
Added a few merge request related calls.
parent
ba09289c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/GitLabApi.java
View file @
a913a19b
...
@@ -141,11 +141,12 @@ public class GitLabApi {
...
@@ -141,11 +141,12 @@ public class GitLabApi {
* @param sourceBranch the source branch, required
* @param sourceBranch the source branch, required
* @param targetBranch the target branch, required
* @param targetBranch the target branch, required
* @param title the title for the merge request, required
* @param title the title for the merge request, required
* @param description the description of the merge request
* @param assigneeId the Assignee user ID, optional
* @param assigneeId the Assignee user ID, optional
* @return the created MergeRequest instance
* @return the created MergeRequest instance
* @throws IOException
* @throws IOException
*/
*/
public
MergeRequest
createMergeRequest
(
Integer
projectId
,
String
sourceBranch
,
String
targetBranch
,
String
title
,
Integer
assigneeId
)
public
MergeRequest
createMergeRequest
(
Integer
projectId
,
String
sourceBranch
,
String
targetBranch
,
String
title
,
String
description
,
Integer
assigneeId
)
throws
IOException
{
throws
IOException
{
/*
/*
...
@@ -161,16 +162,19 @@ public class GitLabApi {
...
@@ -161,16 +162,19 @@ public class GitLabApi {
}
}
Form
formData
=
new
Form
();
Form
formData
=
new
Form
();
formData
.
add
(
"id"
,
projectId
);
formData
.
add
(
"source_branch"
,
sourceBranch
);
formData
.
add
(
"source_branch"
,
sourceBranch
);
formData
.
add
(
"target_branch"
,
targetBranch
);
formData
.
add
(
"target_branch"
,
targetBranch
);
formData
.
add
(
"title"
,
title
);
formData
.
add
(
"title"
,
title
);
if
(
description
!=
null
)
{
formData
.
add
(
"description"
,
description
);
}
if
(
assigneeId
!=
null
)
{
if
(
assigneeId
!=
null
)
{
formData
.
add
(
"assignee_id"
,
assigneeId
);
formData
.
add
(
"assignee_id"
,
assigneeId
);
}
}
ClientResponse
response
=
apiClient
.
post
(
formData
,
"projects"
,
projectId
,
"merge
-
requests"
);
ClientResponse
response
=
apiClient
.
post
(
formData
,
"projects"
,
projectId
,
"merge
_
requests"
);
if
(
response
.
getStatus
()
!=
ClientResponse
.
Status
.
CREATED
.
getStatusCode
())
{
if
(
response
.
getStatus
()
!=
ClientResponse
.
Status
.
CREATED
.
getStatusCode
())
{
ErrorMessage
errorMessage
=
response
.
getEntity
(
ErrorMessage
.
class
);
ErrorMessage
errorMessage
=
response
.
getEntity
(
ErrorMessage
.
class
);
throw
new
RuntimeException
(
errorMessage
.
getMessage
());
throw
new
RuntimeException
(
errorMessage
.
getMessage
());
...
@@ -180,6 +184,28 @@ public class GitLabApi {
...
@@ -180,6 +184,28 @@ public class GitLabApi {
}
}
/**
* POST /projects/:id/merge_request/:merge_request_id/comments
*
* @param projectId
* @param mergeRequestId
* @param comments
* @throws IOException
*/
public
MergeRequestComment
addMergeRequestComment
(
Integer
projectId
,
Integer
mergeRequestId
,
String
comments
)
throws
IOException
{
Form
formData
=
new
Form
();
formData
.
add
(
"note"
,
comments
);
ClientResponse
response
=
apiClient
.
post
(
formData
,
"projects"
,
projectId
,
"merge_request"
,
mergeRequestId
,
"comments"
);
if
(
response
.
getStatus
()
!=
ClientResponse
.
Status
.
CREATED
.
getStatusCode
())
{
ErrorMessage
errorMessage
=
response
.
getEntity
(
ErrorMessage
.
class
);
throw
new
RuntimeException
(
errorMessage
.
getMessage
());
}
return
(
response
.
getEntity
(
MergeRequestComment
.
class
));
}
/**
/**
* GET /projects/:id/repository/branches/:branch
* GET /projects/:id/repository/branches/:branch
*
*
...
@@ -191,7 +217,20 @@ public class GitLabApi {
...
@@ -191,7 +217,20 @@ public class GitLabApi {
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
IOException
{
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
IOException
{
ClientResponse
response
=
apiClient
.
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
ClientResponse
response
=
apiClient
.
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
return
(
response
.
getEntity
(
Branch
.
class
));
return
(
response
.
getEntity
(
Branch
.
class
));
}
}
/**
* GET /projects/:id/repository/commits/branch
*
* @param branch
* @return
*/
public
List
<
Commit
>
getCommits
(
int
projectId
,
String
branch
)
throws
IOException
{
ClientResponse
response
=
apiClient
.
get
(
null
,
"projects"
,
projectId
,
"repository"
,
"commits"
,
branch
);
return
(
response
.
getEntity
(
new
GenericType
<
List
<
Commit
>>()
{}));
}
/**
/**
* GET /users/:id
* GET /users/:id
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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