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
7b72baf6
Commit
7b72baf6
authored
Oct 18, 2015
by
Tim Olshansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77 from matto1990/feature_commit_status_api
Add methods for the new commit status API
parents
11ab77bb
342bb943
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
0 deletions
+152
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+21
-0
GitlabCommitStatus.java
src/main/java/org/gitlab/api/models/GitlabCommitStatus.java
+131
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
7b72baf6
...
...
@@ -708,6 +708,27 @@ public class GitlabAPI {
return
Arrays
.
asList
(
diffs
);
}
// List commit statuses for a project ID and commit hash
// GET /projects/:id/repository/commits/:sha/statuses
public
List
<
GitlabCommitStatus
>
getCommitStatuses
(
GitlabProject
project
,
String
commitHash
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabCommit
.
URL
+
"/"
+
commitHash
+
GitlabCommitStatus
.
URL
;
GitlabCommitStatus
[]
statuses
=
retrieve
().
to
(
tailUrl
,
GitlabCommitStatus
[].
class
);
return
Arrays
.
asList
(
statuses
);
}
// Submit new commit statuses for a project ID and commit hash
// GET /projects/:id/statuses/:sha
public
GitlabCommitStatus
createCommitStatus
(
GitlabProject
project
,
String
commitHash
,
String
state
,
String
ref
,
String
name
,
String
targetUrl
,
String
description
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
GitlabCommitStatus
.
URL
+
"/"
+
commitHash
;
return
dispatch
()
.
with
(
"state"
,
state
)
.
with
(
"ref"
,
ref
)
.
with
(
"name"
,
name
)
.
with
(
"target_url"
,
targetUrl
)
.
with
(
"description"
,
description
)
.
to
(
tailUrl
,
GitlabCommitStatus
.
class
);
}
/**
* Get raw file content
*
...
...
src/main/java/org/gitlab/api/models/GitlabCommitStatus.java
0 → 100644
View file @
7b72baf6
package
org
.
gitlab
.
api
.
models
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.Date
;
public
class
GitlabCommitStatus
{
public
final
static
String
URL
=
"/statuses"
;
private
String
id
;
private
String
sha
;
private
String
ref
;
private
String
status
;
private
String
name
;
private
String
description
;
private
GitlabUser
author
;
@JsonProperty
(
"target_url"
)
private
String
targetUrl
;
@JsonProperty
(
"created_at"
)
private
Date
createdAt
;
@JsonProperty
(
"started_at"
)
private
Date
startedAt
;
@JsonProperty
(
"finished_at"
)
private
Date
finishedAt
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getSha
()
{
return
sha
;
}
public
void
setSha
(
String
sha
)
{
this
.
sha
=
sha
;
}
public
String
getRef
()
{
return
ref
;
}
public
void
setRef
(
String
ref
)
{
this
.
ref
=
ref
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
GitlabUser
getAuthor
()
{
return
author
;
}
public
void
setAuthor
(
GitlabUser
author
)
{
this
.
author
=
author
;
}
public
String
getTargetUrl
()
{
return
targetUrl
;
}
public
void
setTargetUrl
(
String
targetUrl
)
{
this
.
targetUrl
=
targetUrl
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getStartedAt
()
{
return
startedAt
;
}
public
void
setStartedAt
(
Date
startedAt
)
{
this
.
startedAt
=
startedAt
;
}
public
Date
getFinishedAt
()
{
return
finishedAt
;
}
public
void
setFinishedAt
(
Date
finishedAt
)
{
this
.
finishedAt
=
finishedAt
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
// we say that two commit objects are equal iff they have the same ID
// this prevents us from having to do clever workarounds for
// https://gitlab.com/gitlab-org/gitlab-ce/issues/759
try
{
GitlabCommitStatus
commitObj
=
(
GitlabCommitStatus
)
obj
;
return
(
this
.
getId
().
compareTo
(
commitObj
.
getId
())
==
0
);
}
catch
(
ClassCastException
e
)
{
return
false
;
}
}
}
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