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
50adeacf
Commit
50adeacf
authored
Aug 27, 2015
by
Matej Spiller-Muys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added methods:
getRawFileContent getRawBlobContent getFileArchive getRepositoryTree
parent
71927310
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
2 deletions
+104
-2
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+57
-0
GitlabHTTPRequestor.java
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
+3
-1
GitlabRepositoryTree.java
...main/java/org/gitlab/api/models/GitlabRepositoryTree.java
+43
-0
GitlabAPIT.java
src/test/java/org/gitlab/api/GitlabAPIT.java
+1
-1
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
50adeacf
...
...
@@ -691,6 +691,63 @@ public class GitlabAPI {
return
Arrays
.
asList
(
diffs
);
}
/**
* Get raw file content
*
* @param project Project
* @param sha The commit or branch name
* @param filepath The path the file
* @throws IOException
*/
public
byte
[]
getRawFileContent
(
GitlabProject
project
,
String
sha
,
String
filepath
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/blobs/"
+
sha
+
"?filepath="
+
filepath
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
/**
* Get the raw file contents for a blob by blob SHA.
*
* @param project Project
* @param sha The commit or branch name
* @throws IOException
*/
public
byte
[]
getRawBlobContent
(
GitlabProject
project
,
String
sha
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/raw_blobs/"
+
sha
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
/**
* Get an archive of the repository
*
* @param project Project
* @throws IOException
*/
public
byte
[]
getFileArchive
(
GitlabProject
project
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository/archive"
;
return
retrieve
().
to
(
tailUrl
,
byte
[].
class
);
}
/**
* Get an archive of the repository
*
* @param project Project
* @param path The path inside repository. Used to get contend of subdirectories (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @throws IOException
*/
public
List
<
GitlabRepositoryTree
>
getRepositoryTree
(
GitlabProject
project
,
String
path
,
String
ref_name
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabRepositoryTree
.
URL
;
if
(
path
!=
null
)
{
tailUrl
=
tailUrl
+
(
tailUrl
.
indexOf
(
'?'
)
>
0
?
'&'
:
'?'
)
+
"path="
+
path
;
}
if
(
ref_name
!=
null
)
{
tailUrl
=
tailUrl
+
(
tailUrl
.
indexOf
(
'?'
)
>
0
?
'&'
:
'?'
)
+
"ref_name="
+
ref_name
;
}
GitlabRepositoryTree
[]
tree
=
retrieve
().
to
(
tailUrl
,
GitlabRepositoryTree
[].
class
);
return
Arrays
.
asList
(
tree
);
}
public
GitlabNote
createNote
(
GitlabMergeRequest
mergeRequest
,
String
body
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
+
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
+
GitlabNote
.
URL
;
...
...
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
View file @
50adeacf
...
...
@@ -285,8 +285,10 @@ public class GitlabHTTPRequestor {
InputStreamReader
reader
=
null
;
try
{
reader
=
new
InputStreamReader
(
wrapStream
(
connection
,
connection
.
getInputStream
()),
"UTF-8"
);
if
(
byte
[].
class
==
type
)
{
return
type
.
cast
(
IOUtils
.
toByteArray
(
reader
));
}
String
data
=
IOUtils
.
toString
(
reader
);
if
(
type
!=
null
)
{
return
GitlabAPI
.
MAPPER
.
readValue
(
data
,
type
);
}
else
if
(
instance
!=
null
)
{
...
...
src/main/java/org/gitlab/api/models/GitlabRepositoryTree.java
0 → 100644
View file @
50adeacf
package
org
.
gitlab
.
api
.
models
;
public
class
GitlabRepositoryTree
{
public
static
String
URL
=
"/tree"
;
private
String
name
;
private
String
type
;
private
String
mode
;
private
String
id
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getMode
()
{
return
mode
;
}
public
void
setMode
(
String
mode
)
{
this
.
mode
=
mode
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
src/test/java/org/gitlab/api/GitlabAPIT.java
View file @
50adeacf
...
...
@@ -89,7 +89,7 @@ public class GitlabAPIT {
api
.
updateUser
(
gitUser
.
getId
(),
gitUser
.
getEmail
(),
password
,
gitUser
.
getUsername
(),
gitUser
.
getName
(),
"newSkypeId"
,
gitUser
.
getLinkedin
(),
gitUser
.
getTwitter
(),
gitUser
.
getWebsiteUrl
(),
10
/* project limit does not come back on GET */
,
gitUser
.
getExternUid
(),
gitUser
.
getExternProviderName
(),
gitUser
.
getBio
(),
gitUser
.
isAdmin
(),
gitUser
.
isCanCreateGroup
()
,
false
);
gitUser
.
getBio
(),
gitUser
.
isAdmin
(),
gitUser
.
isCanCreateGroup
());
GitlabUser
postUpdate
=
api
.
getUserViaSudo
(
gitUser
.
getUsername
());
...
...
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