Skip to content

feat: expose fields & extend content builder with commiter and author #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.kohsuke</groupId>
<artifactId>cortexapps-github-api</artifactId>
<version>1.322</version>
<version>1.323</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ public String getSha() {
public static class Parent {

/** The url. */
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
String url;
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "used in backend code")
public String url;

/** The sha. */
String sha;
public String sha;
}

/**
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/org/kohsuke/github/GHContentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public final class GHContentBuilder {
private final Requester req;
private String path;

private static final class UserInfo {
private final String name;
private final String email;

private UserInfo(String name, String email) {
this.name = name;
this.email = email;
}
}

/**
* Instantiates a new GH content builder.
*
Expand Down Expand Up @@ -102,6 +112,34 @@ public GHContentBuilder message(String commitMessage) {
return this;
}

/**
* Configures the author of this content.
*
* @param name
* the name
* @param email
* the email
* @return the gh commit builder
*/
public GHContentBuilder author(String name, String email) {
req.with("author", new UserInfo(name, email));
return this;
}

/**
* Configures the committer of this content.
*
* @param name
* the name
* @param email
* the email
* @return the gh commit builder
*/
public GHContentBuilder committer(String name, String email) {
req.with("committer", new UserInfo(name, email));
return this;
}

/**
* Commits a new content.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GitCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public String getTreeUrl() {
* @return the parents
*/
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "acceptable")
List<GHCommit.Parent> getParents() {
public List<GHCommit.Parent> getParents() {
return parents;
}

Expand Down
Loading