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
5f1b0a35
Commit
5f1b0a35
authored
Sep 17, 2013
by
Nick Albion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for un/protectBranch
parent
f26d72c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+10
-0
GitlabHTTPRequestor.java
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
+4
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
5f1b0a35
...
...
@@ -187,6 +187,16 @@ public class GitlabAPI {
return
dispatch
().
with
(
"body"
,
body
).
to
(
tailUrl
,
GitlabNote
.
class
);
}
public
void
protectBranch
(
GitlabProject
project
,
String
branchName
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/branches"
+
"/"
+
branchName
+
"/protect"
;
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
Void
.
class
);
}
public
void
unprotectBranch
(
GitlabProject
project
,
String
branchName
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/branches"
+
"/"
+
branchName
+
"/unprotect"
;
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
Void
.
class
);
}
private
List
<
GitlabMergeRequest
>
fetchMergeRequests
(
String
tailUrl
)
throws
IOException
{
GitlabMergeRequest
[]
mergeRequests
=
retrieve
().
to
(
tailUrl
,
GitlabMergeRequest
[].
class
);
...
...
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
View file @
5f1b0a35
...
...
@@ -113,6 +113,10 @@ public class GitlabHTTPRequestor {
if
(
hasOutput
())
{
submitData
(
connection
);
}
else
if
(
"PUT"
.
equals
(
_method
)
)
{
// PUT requires Content-Length: 0 even when there is no body (eg: API for protecting a branch)
connection
.
setDoOutput
(
true
);
connection
.
setFixedLengthStreamingMode
(
0
);
}
try
{
...
...
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