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
7c0cf5e8
Unverified
Commit
7c0cf5e8
authored
Apr 11, 2021
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
Apr 11, 2021
Browse files
Merge pull request #664 from ojacquemart/feature/generate-changelog-data
feat: add generate changelog api support
parents
57a7cc54
eb9bdb92
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/RepositoryApi.java
View file @
7c0cf5e8
...
...
@@ -18,6 +18,7 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.ChangelogPayload
;
import
org.gitlab4j.api.models.Commit
;
import
org.gitlab4j.api.models.CompareResults
;
import
org.gitlab4j.api.models.Contributor
;
...
...
@@ -749,4 +750,32 @@ public class RepositoryApi extends AbstractApi {
delete
(
Response
.
Status
.
NO_CONTENT
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"merged_branches"
);
}
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param version the version to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public
void
generateChangelog
(
Object
projectIdOrPath
,
String
version
)
throws
GitLabApiException
{
generateChangelog
(
projectIdOrPath
,
new
ChangelogPayload
(
version
));
}
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param payload the payload to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public
void
generateChangelog
(
Object
projectIdOrPath
,
ChangelogPayload
payload
)
throws
GitLabApiException
{
post
(
Response
.
Status
.
OK
,
payload
.
getFormData
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"changelog"
);
}
}
src/main/java/org/gitlab4j/api/models/ChangelogPayload.java
0 → 100644
View file @
7c0cf5e8
package
org.gitlab4j.api.models
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
java.util.Date
;
public
class
ChangelogPayload
{
private
String
version
;
private
String
from
;
private
String
to
;
private
Date
date
;
private
String
branch
;
private
String
trailer
;
private
String
file
;
private
String
message
;
public
ChangelogPayload
(
String
version
)
{
this
.
version
=
version
;
}
@JsonIgnore
public
GitLabApiForm
getFormData
()
{
return
new
GitLabApiForm
()
.
withParam
(
"version"
,
version
,
true
)
.
withParam
(
"from"
,
from
)
.
withParam
(
"to"
,
to
)
.
withParam
(
"date"
,
ISO8601
.
dateOnly
(
date
))
.
withParam
(
"branch"
,
branch
)
.
withParam
(
"trailer"
,
trailer
)
.
withParam
(
"file"
,
file
)
.
withParam
(
"message"
,
message
);
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getFrom
()
{
return
from
;
}
public
void
setFrom
(
String
from
)
{
this
.
from
=
from
;
}
public
String
getTo
()
{
return
to
;
}
public
void
setTo
(
String
to
)
{
this
.
to
=
to
;
}
public
Date
getDate
()
{
return
date
;
}
public
void
setDate
(
Date
date
)
{
this
.
date
=
date
;
}
public
String
getBranch
()
{
return
branch
;
}
public
void
setBranch
(
String
branch
)
{
this
.
branch
=
branch
;
}
public
String
getTrailer
()
{
return
trailer
;
}
public
void
setTrailer
(
String
trailer
)
{
this
.
trailer
=
trailer
;
}
public
String
getFile
()
{
return
file
;
}
public
void
setFile
(
String
file
)
{
this
.
file
=
file
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
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