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
5a4138da
Commit
5a4138da
authored
Dec 03, 2014
by
Greg Messner
Browse files
Added createBranch support for 6.8.x
parent
04c0dd1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/RepositoryApi.java
View file @
5a4138da
...
@@ -36,7 +36,7 @@ public class RepositoryApi extends AbstractApi {
...
@@ -36,7 +36,7 @@ public class RepositoryApi extends AbstractApi {
return
(
response
.
getEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
return
(
response
.
getEntity
(
new
GenericType
<
List
<
Branch
>>()
{}));
}
}
/**
/**
* Get a single project repository branch.
* Get a single project repository branch.
*
*
...
@@ -47,10 +47,30 @@ public class RepositoryApi extends AbstractApi {
...
@@ -47,10 +47,30 @@ public class RepositoryApi extends AbstractApi {
* @return the branch info for the specified project ID/branch name pair
* @return the branch info for the specified project ID/branch name pair
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
public
Branch
getBranch
(
Integer
projectId
,
String
branchName
)
throws
GitLabApiException
{
ClientResponse
response
=
get
(
ClientResponse
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
ClientResponse
response
=
get
(
ClientResponse
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"repository"
,
"branches"
,
branchName
);
return
(
response
.
getEntity
(
Branch
.
class
));
return
(
response
.
getEntity
(
Branch
.
class
));
}
}
/**
* Creates a branch for the project. Support as of version 6.8.x
*
* POST /projects/:id/repository/branches
*
* @param projectId the project to create the branch for
* @param branchName the name of the branch to create
* @param ref Source to create the branch from, can be an existing branch, tag or commit SHA
* @return the branch info for the created branch
* @throws GitLabApiException
*/
public
Branch
createBranch
(
Integer
projectId
,
String
branchName
,
String
ref
)
throws
GitLabApiException
{
Form
formData
=
new
Form
();
formData
.
add
(
"branch_name "
,
branchName
);
formData
.
add
(
"ref "
,
ref
);
ClientResponse
response
=
post
(
ClientResponse
.
Status
.
OK
,
formData
,
"projects"
,
projectId
,
"repository"
,
"branches"
);
return
(
response
.
getEntity
(
Branch
.
class
));
}
/**
/**
...
...
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