getEvents() {
+ return events.stream()
+ .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
+ .collect(Collectors.toList());
}
/**
- * Gets name.
+ * Gets external url.
*
- * @return the name
+ * @return the external url
*/
- public String getName() {
- return name;
+ public String getExternalUrl() {
+ return externalUrl;
}
/**
- * Gets the slug name of the GitHub app.
+ * Gets the html url.
*
- * @return the slug name of the GitHub app
+ * @return the html url
*/
- public String getSlug() {
- return slug;
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * Gets description.
+ * Obtain an installation associated with this app.
+ *
+ * You must use a JWT to access this endpoint.
*
- * @return the description
+ * @param id
+ * Installation Id
+ * @return a GHAppInstallation
+ * @throws IOException
+ * on error
+ * @see Get an installation
*/
- public String getDescription() {
- return description;
+ public GHAppInstallation getInstallationById(long id) throws IOException {
+ return root().createRequest()
+ .withUrlPath(String.format("/app/installations/%d", id))
+ .fetch(GHAppInstallation.class);
}
/**
- * Gets external url.
+ * Obtain an organization installation associated with this app.
+ *
+ * You must use a JWT to access this endpoint.
*
- * @return the external url
+ * @param name
+ * Organization name
+ * @return a GHAppInstallation
+ * @throws IOException
+ * on error
+ * @see Get an organization
+ * installation
*/
- public String getExternalUrl() {
- return externalUrl;
+ public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
+ return root().createRequest()
+ .withUrlPath(String.format("/orgs/%s/installation", name))
+ .fetch(GHAppInstallation.class);
}
/**
- * Gets events.
+ * Obtain an repository installation associated with this app.
+ *
+ * You must use a JWT to access this endpoint.
*
- * @return the events
+ * @param ownerName
+ * Organization or user name
+ * @param repositoryName
+ * Repository name
+ * @return a GHAppInstallation
+ * @throws IOException
+ * on error
+ * @see Get a repository
+ * installation
*/
- public List getEvents() {
- return events.stream()
- .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
- .collect(Collectors.toList());
+ public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
+ return root().createRequest()
+ .withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
+ .fetch(GHAppInstallation.class);
+ }
+
+ /**
+ * Obtain a user installation associated with this app.
+ *
+ * You must use a JWT to access this endpoint.
+ *
+ * @param name
+ * user name
+ * @return a GHAppInstallation
+ * @throws IOException
+ * on error
+ * @see Get a user installation
+ */
+ public GHAppInstallation getInstallationByUser(String name) throws IOException {
+ return root().createRequest()
+ .withUrlPath(String.format("/users/%s/installation", name))
+ .fetch(GHAppInstallation.class);
}
/**
@@ -104,12 +161,22 @@ public long getInstallationsCount() {
}
/**
- * Gets the html url.
+ * Gets name.
*
- * @return the html url
+ * @return the name
*/
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets owner.
+ *
+ * @return the owner
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHUser getOwner() {
+ return owner;
}
/**
@@ -121,6 +188,15 @@ public Map getPermissions() {
return Collections.unmodifiableMap(permissions);
}
+ /**
+ * Gets the slug name of the GitHub app.
+ *
+ * @return the slug name of the GitHub app
+ */
+ public String getSlug() {
+ return slug;
+ }
+
/**
* Obtains all the installation requests associated with this app.
*
@@ -183,80 +259,4 @@ public PagedIterable listInstallations(final Instant since) {
return requester.toIterable(GHAppInstallation[].class, null);
}
- /**
- * Obtain an installation associated with this app.
- *
- * You must use a JWT to access this endpoint.
- *
- * @param id
- * Installation Id
- * @return a GHAppInstallation
- * @throws IOException
- * on error
- * @see Get an installation
- */
- public GHAppInstallation getInstallationById(long id) throws IOException {
- return root().createRequest()
- .withUrlPath(String.format("/app/installations/%d", id))
- .fetch(GHAppInstallation.class);
- }
-
- /**
- * Obtain an organization installation associated with this app.
- *
- * You must use a JWT to access this endpoint.
- *
- * @param name
- * Organization name
- * @return a GHAppInstallation
- * @throws IOException
- * on error
- * @see Get an organization
- * installation
- */
- public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
- return root().createRequest()
- .withUrlPath(String.format("/orgs/%s/installation", name))
- .fetch(GHAppInstallation.class);
- }
-
- /**
- * Obtain an repository installation associated with this app.
- *
- * You must use a JWT to access this endpoint.
- *
- * @param ownerName
- * Organization or user name
- * @param repositoryName
- * Repository name
- * @return a GHAppInstallation
- * @throws IOException
- * on error
- * @see Get a repository
- * installation
- */
- public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
- return root().createRequest()
- .withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
- .fetch(GHAppInstallation.class);
- }
-
- /**
- * Obtain a user installation associated with this app.
- *
- * You must use a JWT to access this endpoint.
- *
- * @param name
- * user name
- * @return a GHAppInstallation
- * @throws IOException
- * on error
- * @see Get a user installation
- */
- public GHAppInstallation getInstallationByUser(String name) throws IOException {
- return root().createRequest()
- .withUrlPath(String.format("/users/%s/installation", name))
- .fetch(GHAppInstallation.class);
- }
-
}
diff --git a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
index edab276e90..54c5228257 100644
--- a/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
@@ -14,9 +14,9 @@
*/
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
+ private final String apiUrlTail;
/** The builder. */
protected final Requester builder;
- private final String apiUrlTail;
/**
* Instantiates a new GH app create token builder.
@@ -34,17 +34,33 @@ public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
}
/**
- * By default the installation token has access to all repositories that the installation can access. To restrict
- * the access to specific repositories, you can provide the repository_ids when creating the token. When you omit
- * repository_ids, the response does not contain neither the repositories nor the permissions key.
+ * Creates an app token with all the parameters.
+ *
+ * You must use a JWT to access this endpoint.
*
- * @param repositoryIds
- * Array containing the repositories Ids
+ * @return a GHAppInstallationToken
+ * @throws IOException
+ * on error
+ */
+ public GHAppInstallationToken create() throws IOException {
+ return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHAppInstallationToken.class);
+ }
+
+ /**
+ * Set the permissions granted to the access token. The permissions object includes the permission names and their
+ * access type.
+ *
+ * @param permissions
+ * Map containing the permission names and types.
* @return a GHAppCreateTokenBuilder
*/
@BetaApi
- public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) {
- this.builder.with("repository_ids", repositoryIds);
+ public GHAppCreateTokenBuilder permissions(Map permissions) {
+ Map retMap = new HashMap<>();
+ for (Map.Entry entry : permissions.entrySet()) {
+ retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
+ }
+ builder.with("permissions", retMap);
return this;
}
@@ -63,34 +79,18 @@ public GHAppCreateTokenBuilder repositories(List repositories) {
}
/**
- * Set the permissions granted to the access token. The permissions object includes the permission names and their
- * access type.
+ * By default the installation token has access to all repositories that the installation can access. To restrict
+ * the access to specific repositories, you can provide the repository_ids when creating the token. When you omit
+ * repository_ids, the response does not contain neither the repositories nor the permissions key.
*
- * @param permissions
- * Map containing the permission names and types.
+ * @param repositoryIds
+ * Array containing the repositories Ids
* @return a GHAppCreateTokenBuilder
*/
@BetaApi
- public GHAppCreateTokenBuilder permissions(Map permissions) {
- Map retMap = new HashMap<>();
- for (Map.Entry entry : permissions.entrySet()) {
- retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
- }
- builder.with("permissions", retMap);
+ public GHAppCreateTokenBuilder repositoryIds(List repositoryIds) {
+ this.builder.with("repository_ids", repositoryIds);
return this;
}
- /**
- * Creates an app token with all the parameters.
- *
- * You must use a JWT to access this endpoint.
- *
- * @return a GHAppInstallationToken
- * @throws IOException
- * on error
- */
- public GHAppInstallationToken create() throws IOException {
- return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHAppInstallationToken.class);
- }
-
}
diff --git a/src/main/java/org/kohsuke/github/GHAppFromManifest.java b/src/main/java/org/kohsuke/github/GHAppFromManifest.java
index 3d6c4cdf20..2fa5e3998c 100644
--- a/src/main/java/org/kohsuke/github/GHAppFromManifest.java
+++ b/src/main/java/org/kohsuke/github/GHAppFromManifest.java
@@ -8,17 +8,17 @@
*/
public class GHAppFromManifest extends GHApp {
+ private String clientId;
+
+ private String clientSecret;
+ private String pem;
+ private String webhookSecret;
/**
* Create default GHAppFromManifest instance
*/
public GHAppFromManifest() {
}
- private String clientId;
- private String clientSecret;
- private String webhookSecret;
- private String pem;
-
/**
* Gets the client id
*
@@ -38,20 +38,20 @@ public String getClientSecret() {
}
/**
- * Gets the webhook secret
+ * Gets the pem
*
- * @return the webhook secret
+ * @return the pem
*/
- public String getWebhookSecret() {
- return webhookSecret;
+ public String getPem() {
+ return pem;
}
/**
- * Gets the pem
+ * Gets the webhook secret
*
- * @return the pem
+ * @return the webhook secret
*/
- public String getPem() {
- return pem;
+ public String getWebhookSecret() {
+ return webhookSecret;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallation.java b/src/main/java/org/kohsuke/github/GHAppInstallation.java
index 7764458d5a..e92c744e99 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallation.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallation.java
@@ -27,98 +27,103 @@
*/
public class GHAppInstallation extends GHObject {
- /**
- * Create default GHAppInstallation instance
- */
- public GHAppInstallation() {
- }
+ private static class GHAppInstallationRepositoryResult extends SearchResult {
+ private GHRepository[] repositories;
- private GHUser account;
+ @Override
+ GHRepository[] getItems(GitHub root) {
+ return repositories;
+ }
+ }
@JsonProperty("access_tokens_url")
private String accessTokenUrl;
- @JsonProperty("repositories_url")
- private String repositoriesUrl;
+
+ private GHUser account;
@JsonProperty("app_id")
private long appId;
- @JsonProperty("target_id")
- private long targetId;
- @JsonProperty("target_type")
- private GHTargetType targetType;
- private Map permissions;
private List events;
- @JsonProperty("single_file_name")
- private String singleFileName;
+ private String htmlUrl;
+ private Map permissions;
+ @JsonProperty("repositories_url")
+ private String repositoriesUrl;
@JsonProperty("repository_selection")
private GHRepositorySelection repositorySelection;
- private String htmlUrl;
+ @JsonProperty("single_file_name")
+ private String singleFileName;
private String suspendedAt;
private GHUser suspendedBy;
+ @JsonProperty("target_id")
+ private long targetId;
+ @JsonProperty("target_type")
+ private GHTargetType targetType;
/**
- * Gets the html url.
- *
- * @return the html url
+ * Create default GHAppInstallation instance
*/
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
+ public GHAppInstallation() {
}
/**
- * Gets account.
+ * Starts a builder that creates a new App Installation Token.
*
- * @return the account
+ *
+ * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
+ * finally create an access token.
+ *
+ * @return a GHAppCreateTokenBuilder instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHUser getAccount() {
- return account;
+ public GHAppCreateTokenBuilder createToken() {
+ return new GHAppCreateTokenBuilder(root(), String.format("/app/installations/%d/access_tokens", getId()));
}
/**
- * Gets access token url.
+ * Starts a builder that creates a new App Installation Token.
*
- * @return the access token url
+ *
+ * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
+ * finally create an access token.
+ *
+ * @param permissions
+ * map of permissions for the created token
+ * @return a GHAppCreateTokenBuilder instance
+ * @deprecated Use {@link GHAppInstallation#createToken()} instead.
*/
- public String getAccessTokenUrl() {
- return accessTokenUrl;
+ @Deprecated
+ public GHAppCreateTokenBuilder createToken(Map permissions) {
+ return createToken().permissions(permissions);
}
/**
- * Gets repositories url.
+ * Delete a Github App installation
+ *
+ * You must use a JWT to access this endpoint.
*
- * @return the repositories url
+ * @throws IOException
+ * on error
+ * @see Delete an installation
*/
- public String getRepositoriesUrl() {
- return repositoriesUrl;
+ public void deleteInstallation() throws IOException {
+ root().createRequest().method("DELETE").withUrlPath(String.format("/app/installations/%d", getId())).send();
}
/**
- * List repositories that this app installation can access.
+ * Gets access token url.
*
- * @return the paged iterable
- * @deprecated This method cannot work on a {@link GHAppInstallation} retrieved from
- * {@link GHApp#listInstallations()} (for example), except when resorting to unsupported hacks involving
- * setRoot(GitHub) to switch from an application client to an installation client. This method will be
- * removed. You should instead use an installation client (with an installation token, not a JWT),
- * retrieve a {@link GHAuthenticatedAppInstallation} from {@link GitHub#getInstallation()}, then call
- * {@link GHAuthenticatedAppInstallation#listRepositories()}.
+ * @return the access token url
*/
- @Deprecated
- public PagedSearchIterable listRepositories() {
- GitHubRequest request;
-
- request = root().createRequest().withUrlPath("/installation/repositories").build();
-
- return new PagedSearchIterable<>(root(), request, GHAppInstallationRepositoryResult.class);
+ public String getAccessTokenUrl() {
+ return accessTokenUrl;
}
- private static class GHAppInstallationRepositoryResult extends SearchResult {
- private GHRepository[] repositories;
-
- @Override
- GHRepository[] getItems(GitHub root) {
- return repositories;
- }
+ /**
+ * Gets account.
+ *
+ * @return the account
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHUser getAccount() {
+ return account;
}
/**
@@ -131,50 +136,62 @@ public long getAppId() {
}
/**
- * Gets target id.
+ * Gets events.
*
- * @return the target id
+ * @return the events
*/
- public long getTargetId() {
- return targetId;
+ public List getEvents() {
+ return events.stream()
+ .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
+ .collect(Collectors.toList());
}
/**
- * Gets target type.
+ * Gets the html url.
*
- * @return the target type
+ * @return the html url
*/
- public GHTargetType getTargetType() {
- return targetType;
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * Gets permissions.
+ * Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub
+ * App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will
+ * also see the upcoming pending change.
*
- * @return the permissions
+ *
+ * GitHub Apps must use a JWT to access this endpoint.
+ *
+ * OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
+ *
+ * @return a GHMarketplaceAccountPlan instance
+ * @throws IOException
+ * it may throw an {@link IOException}
+ * @see Get
+ * a subscription plan for an account
*/
- public Map getPermissions() {
- return Collections.unmodifiableMap(permissions);
+ public GHMarketplaceAccountPlan getMarketplaceAccount() throws IOException {
+ return new GHMarketplacePlanForAccountBuilder(root(), account.getId()).createRequest();
}
/**
- * Gets events.
+ * Gets permissions.
*
- * @return the events
+ * @return the permissions
*/
- public List getEvents() {
- return events.stream()
- .map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
- .collect(Collectors.toList());
+ public Map getPermissions() {
+ return Collections.unmodifiableMap(permissions);
}
/**
- * Gets single file name.
+ * Gets repositories url.
*
- * @return the single file name
+ * @return the repositories url
*/
- public String getSingleFileName() {
- return singleFileName;
+ public String getRepositoriesUrl() {
+ return repositoriesUrl;
}
/**
@@ -186,6 +203,15 @@ public GHRepositorySelection getRepositorySelection() {
return repositorySelection;
}
+ /**
+ * Gets single file name.
+ *
+ * @return the single file name
+ */
+ public String getSingleFileName() {
+ return singleFileName;
+ }
+
/**
* Gets suspended at.
*
@@ -207,66 +233,40 @@ public GHUser getSuspendedBy() {
}
/**
- * Delete a Github App installation
- *
- * You must use a JWT to access this endpoint.
+ * Gets target id.
*
- * @throws IOException
- * on error
- * @see Delete an installation
+ * @return the target id
*/
- public void deleteInstallation() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(String.format("/app/installations/%d", getId())).send();
+ public long getTargetId() {
+ return targetId;
}
/**
- * Starts a builder that creates a new App Installation Token.
- *
- *
- * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
- * finally create an access token.
+ * Gets target type.
*
- * @param permissions
- * map of permissions for the created token
- * @return a GHAppCreateTokenBuilder instance
- * @deprecated Use {@link GHAppInstallation#createToken()} instead.
+ * @return the target type
*/
- @Deprecated
- public GHAppCreateTokenBuilder createToken(Map permissions) {
- return createToken().permissions(permissions);
+ public GHTargetType getTargetType() {
+ return targetType;
}
/**
- * Starts a builder that creates a new App Installation Token.
- *
- *
- * You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
- * finally create an access token.
+ * List repositories that this app installation can access.
*
- * @return a GHAppCreateTokenBuilder instance
+ * @return the paged iterable
+ * @deprecated This method cannot work on a {@link GHAppInstallation} retrieved from
+ * {@link GHApp#listInstallations()} (for example), except when resorting to unsupported hacks involving
+ * setRoot(GitHub) to switch from an application client to an installation client. This method will be
+ * removed. You should instead use an installation client (with an installation token, not a JWT),
+ * retrieve a {@link GHAuthenticatedAppInstallation} from {@link GitHub#getInstallation()}, then call
+ * {@link GHAuthenticatedAppInstallation#listRepositories()}.
*/
- public GHAppCreateTokenBuilder createToken() {
- return new GHAppCreateTokenBuilder(root(), String.format("/app/installations/%d/access_tokens", getId()));
- }
+ @Deprecated
+ public PagedSearchIterable listRepositories() {
+ GitHubRequest request;
- /**
- * Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub
- * App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will
- * also see the upcoming pending change.
- *
- *
- * GitHub Apps must use a JWT to access this endpoint.
- *
- * OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
- *
- * @return a GHMarketplaceAccountPlan instance
- * @throws IOException
- * it may throw an {@link IOException}
- * @see Get
- * a subscription plan for an account
- */
- public GHMarketplaceAccountPlan getMarketplaceAccount() throws IOException {
- return new GHMarketplacePlanForAccountBuilder(root(), account.getId()).createRequest();
+ request = root().createRequest().withUrlPath("/installation/repositories").build();
+
+ return new PagedSearchIterable<>(root(), request, GHAppInstallationRepositoryResult.class);
}
}
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationRequest.java b/src/main/java/org/kohsuke/github/GHAppInstallationRequest.java
index a2e7c279fe..44ace753a2 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallationRequest.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallationRequest.java
@@ -9,16 +9,16 @@
* @see GHApp#listInstallationRequests() GHApp#listInstallationRequests()
*/
public class GHAppInstallationRequest extends GHObject {
+ private GHOrganization account;
+
+ private GHUser requester;
+
/**
* Create default GHAppInstallationRequest instance
*/
public GHAppInstallationRequest() {
}
- private GHOrganization account;
-
- private GHUser requester;
-
/**
* Gets the organization where the app was requested to be installed.
*
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
index fb214e235d..3d268cf38a 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java
@@ -14,36 +14,37 @@
*/
public class GHAppInstallationToken extends GitHubInteractiveObject {
+ private Map permissions;
+
+ private List repositories;
+
+ private GHRepositorySelection repositorySelection;
+ private String token;
+ /** The expires at. */
+ protected String expiresAt;
/**
* Create default GHAppInstallationToken instance
*/
public GHAppInstallationToken() {
}
- private String token;
-
- /** The expires at. */
- protected String expiresAt;
- private Map permissions;
- private List repositories;
- private GHRepositorySelection repositorySelection;
-
/**
- * Gets permissions.
+ * Gets expires at.
*
- * @return the permissions
+ * @return date when this token expires
*/
- public Map getPermissions() {
- return Collections.unmodifiableMap(permissions);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getExpiresAt() {
+ return GitHubClient.parseInstant(expiresAt);
}
/**
- * Gets token.
+ * Gets permissions.
*
- * @return the token
+ * @return the permissions
*/
- public String getToken() {
- return token;
+ public Map getPermissions() {
+ return Collections.unmodifiableMap(permissions);
}
/**
@@ -65,12 +66,11 @@ public GHRepositorySelection getRepositorySelection() {
}
/**
- * Gets expires at.
+ * Gets token.
*
- * @return date when this token expires
+ * @return the token
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getExpiresAt() {
- return GitHubClient.parseInstant(expiresAt);
+ public String getToken() {
+ return token;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationsIterable.java b/src/main/java/org/kohsuke/github/GHAppInstallationsIterable.java
index 8a150de1fb..fc89d371ee 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallationsIterable.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallationsIterable.java
@@ -12,8 +12,8 @@ class GHAppInstallationsIterable extends PagedIterable {
/** The Constant APP_INSTALLATIONS_URL. */
public static final String APP_INSTALLATIONS_URL = "/user/installations";
- private final transient GitHub root;
private GHAppInstallationsPage result;
+ private final transient GitHub root;
/**
* Instantiates a new GH app installations iterable.
diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationsPage.java b/src/main/java/org/kohsuke/github/GHAppInstallationsPage.java
index f4eeecc222..cd8f9a1f7e 100644
--- a/src/main/java/org/kohsuke/github/GHAppInstallationsPage.java
+++ b/src/main/java/org/kohsuke/github/GHAppInstallationsPage.java
@@ -5,8 +5,8 @@
* Represents the one page of GHAppInstallations.
*/
class GHAppInstallationsPage {
- private int totalCount;
private GHAppInstallation[] installations;
+ private int totalCount;
/**
* Gets the total count.
diff --git a/src/main/java/org/kohsuke/github/GHArtifact.java b/src/main/java/org/kohsuke/github/GHArtifact.java
index c9af104ed0..21c16836f8 100644
--- a/src/main/java/org/kohsuke/github/GHArtifact.java
+++ b/src/main/java/org/kohsuke/github/GHArtifact.java
@@ -22,38 +22,47 @@
*/
public class GHArtifact extends GHObject {
- /**
- * Create default GHArtifact instance
- */
- public GHArtifact() {
- }
+ private String archiveDownloadUrl;
+ private boolean expired;
+
+ private String expiresAt;
+ private String name;
// Not provided by the API.
@JsonIgnore
private GHRepository owner;
-
- private String name;
private long sizeInBytes;
- private String archiveDownloadUrl;
- private boolean expired;
- private String expiresAt;
+ /**
+ * Create default GHArtifact instance
+ */
+ public GHArtifact() {
+ }
/**
- * Gets the name.
+ * Deletes the artifact.
*
- * @return the name
+ * @throws IOException
+ * the io exception
*/
- public String getName() {
- return name;
+ public void delete() throws IOException {
+ root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
- * Gets the size of the artifact in bytes.
+ * Downloads the artifact.
*
- * @return the size
+ * @param
+ * the type of result
+ * @param streamFunction
+ * The {@link InputStreamFunction} that will process the stream
+ * @return the result of reading the stream.
+ * @throws IOException
+ * The IO exception.
*/
- public long getSizeInBytes() {
- return sizeInBytes;
+ public T download(InputStreamFunction streamFunction) throws IOException {
+ requireNonNull(streamFunction, "Stream function must not be null");
+
+ return root().createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
}
/**
@@ -65,15 +74,6 @@ public URL getArchiveDownloadUrl() {
return GitHubClient.parseURL(archiveDownloadUrl);
}
- /**
- * If this artifact has expired.
- *
- * @return if the artifact has expired
- */
- public boolean isExpired() {
- return expired;
- }
-
/**
* Gets the date at which this artifact will expire.
*
@@ -84,6 +84,15 @@ public Instant getExpiresAt() {
return GitHubClient.parseInstant(expiresAt);
}
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
/**
* Repository to which the artifact belongs.
*
@@ -95,30 +104,21 @@ public GHRepository getRepository() {
}
/**
- * Deletes the artifact.
+ * Gets the size of the artifact in bytes.
*
- * @throws IOException
- * the io exception
+ * @return the size
*/
- public void delete() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
+ public long getSizeInBytes() {
+ return sizeInBytes;
}
/**
- * Downloads the artifact.
+ * If this artifact has expired.
*
- * @param
- * the type of result
- * @param streamFunction
- * The {@link InputStreamFunction} that will process the stream
- * @return the result of reading the stream.
- * @throws IOException
- * The IO exception.
+ * @return if the artifact has expired
*/
- public T download(InputStreamFunction streamFunction) throws IOException {
- requireNonNull(streamFunction, "Stream function must not be null");
-
- return root().createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
+ public boolean isExpired() {
+ return expired;
}
private String getApiRoute() {
diff --git a/src/main/java/org/kohsuke/github/GHArtifactsPage.java b/src/main/java/org/kohsuke/github/GHArtifactsPage.java
index 547eb3eeb1..8b3675bb11 100644
--- a/src/main/java/org/kohsuke/github/GHArtifactsPage.java
+++ b/src/main/java/org/kohsuke/github/GHArtifactsPage.java
@@ -9,8 +9,8 @@
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
class GHArtifactsPage {
- private int totalCount;
private GHArtifact[] artifacts;
+ private int totalCount;
/**
* Gets the total count.
diff --git a/src/main/java/org/kohsuke/github/GHAsset.java b/src/main/java/org/kohsuke/github/GHAsset.java
index b2c994f8e3..8ad0455483 100644
--- a/src/main/java/org/kohsuke/github/GHAsset.java
+++ b/src/main/java/org/kohsuke/github/GHAsset.java
@@ -13,41 +13,63 @@
public class GHAsset extends GHObject {
/**
- * Create default GHAsset instance
+ * Wrap gh asset [ ].
+ *
+ * @param assets
+ * the assets
+ * @param release
+ * the release
+ * @return the gh asset [ ]
*/
- public GHAsset() {
+ public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) {
+ for (GHAsset aTo : assets) {
+ aTo.wrap(release);
+ }
+ return assets;
}
- /** The owner. */
- GHRepository owner;
- private String name;
- private String label;
- private String state;
+ private String browserDownloadUrl;
private String contentType;
- private long size;
private long downloadCount;
- private String browserDownloadUrl;
+ private String label;
+ private String name;
+ private long size;
+ private String state;
+ /** The owner. */
+ GHRepository owner;
/**
- * Gets content type.
- *
- * @return the content type
+ * Create default GHAsset instance
*/
- public String getContentType() {
- return contentType;
+ public GHAsset() {
}
/**
- * Sets content type.
+ * Delete.
*
- * @param contentType
- * the content type
* @throws IOException
* the io exception
*/
- public void setContentType(String contentType) throws IOException {
- edit("content_type", contentType);
- this.contentType = contentType;
+ public void delete() throws IOException {
+ root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
+ }
+
+ /**
+ * Gets browser download url.
+ *
+ * @return the browser download url
+ */
+ public String getBrowserDownloadUrl() {
+ return browserDownloadUrl;
+ }
+
+ /**
+ * Gets content type.
+ *
+ * @return the content type
+ */
+ public String getContentType() {
+ return contentType;
}
/**
@@ -68,19 +90,6 @@ public String getLabel() {
return label;
}
- /**
- * Sets label.
- *
- * @param label
- * the label
- * @throws IOException
- * the io exception
- */
- public void setLabel(String label) throws IOException {
- edit("label", label);
- this.label = label;
- }
-
/**
* Gets name.
*
@@ -119,26 +128,33 @@ public String getState() {
}
/**
- * Gets browser download url.
+ * Sets content type.
*
- * @return the browser download url
+ * @param contentType
+ * the content type
+ * @throws IOException
+ * the io exception
*/
- public String getBrowserDownloadUrl() {
- return browserDownloadUrl;
- }
-
- private void edit(String key, Object value) throws IOException {
- root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
+ public void setContentType(String contentType) throws IOException {
+ edit("content_type", contentType);
+ this.contentType = contentType;
}
/**
- * Delete.
+ * Sets label.
*
+ * @param label
+ * the label
* @throws IOException
* the io exception
*/
- public void delete() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
+ public void setLabel(String label) throws IOException {
+ edit("label", label);
+ this.label = label;
+ }
+
+ private void edit(String key, Object value) throws IOException {
+ root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
private String getApiRoute() {
@@ -156,20 +172,4 @@ GHAsset wrap(GHRelease release) {
this.owner = release.getOwner();
return this;
}
-
- /**
- * Wrap gh asset [ ].
- *
- * @param assets
- * the assets
- * @param release
- * the release
- * @return the gh asset [ ]
- */
- public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) {
- for (GHAsset aTo : assets) {
- aTo.wrap(release);
- }
- return assets;
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHAuthenticatedAppInstallation.java b/src/main/java/org/kohsuke/github/GHAuthenticatedAppInstallation.java
index 7c3fc8257b..73d55ba4c1 100644
--- a/src/main/java/org/kohsuke/github/GHAuthenticatedAppInstallation.java
+++ b/src/main/java/org/kohsuke/github/GHAuthenticatedAppInstallation.java
@@ -10,6 +10,15 @@
*/
public class GHAuthenticatedAppInstallation extends GitHubInteractiveObject {
+ private static class GHAuthenticatedAppInstallationRepositoryResult extends SearchResult {
+ private GHRepository[] repositories;
+
+ @Override
+ GHRepository[] getItems(GitHub root) {
+ return repositories;
+ }
+ }
+
/**
* Instantiates a new GH authenticated app installation.
*
@@ -33,13 +42,4 @@ public PagedSearchIterable listRepositories() {
return new PagedSearchIterable<>(root(), request, GHAuthenticatedAppInstallationRepositoryResult.class);
}
- private static class GHAuthenticatedAppInstallationRepositoryResult extends SearchResult {
- private GHRepository[] repositories;
-
- @Override
- GHRepository[] getItems(GitHub root) {
- return repositories;
- }
- }
-
}
diff --git a/src/main/java/org/kohsuke/github/GHAuthorization.java b/src/main/java/org/kohsuke/github/GHAuthorization.java
index 4a88b20d79..9768de3063 100644
--- a/src/main/java/org/kohsuke/github/GHAuthorization.java
+++ b/src/main/java/org/kohsuke/github/GHAuthorization.java
@@ -17,129 +17,119 @@
*/
public class GHAuthorization extends GHObject {
- /**
- * Create default GHAuthorization instance
- */
- public GHAuthorization() {
+ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
+ justification = "JSON API")
+ private static class App {
+ private String name;
+ // private String client_id; not yet used
+ private String url;
}
- /** The Constant USER. */
- public static final String USER = "user";
-
- /** The Constant USER_EMAIL. */
- public static final String USER_EMAIL = "user:email";
-
- /** The Constant USER_FOLLOW. */
- public static final String USER_FOLLOW = "user:follow";
-
- /** The Constant PUBLIC_REPO. */
- public static final String PUBLIC_REPO = "public_repo";
+ /** The Constant ADMIN_KEY. */
+ public static final String ADMIN_KEY = "admin:public_key";
- /** The Constant REPO. */
- public static final String REPO = "repo";
+ /** The Constant ADMIN_ORG. */
+ public static final String ADMIN_ORG = "admin:org";
- /** The Constant REPO_STATUS. */
- public static final String REPO_STATUS = "repo:status";
+ /** The Constant AMIN_HOOK. */
+ public static final String AMIN_HOOK = "admin:repo_hook";
/** The Constant DELETE_REPO. */
public static final String DELETE_REPO = "delete_repo";
+ /** The Constant GIST. */
+ public static final String GIST = "gist";
+
/** The Constant NOTIFICATIONS. */
public static final String NOTIFICATIONS = "notifications";
- /** The Constant GIST. */
- public static final String GIST = "gist";
+ /** The Constant PUBLIC_REPO. */
+ public static final String PUBLIC_REPO = "public_repo";
/** The Constant READ_HOOK. */
public static final String READ_HOOK = "read:repo_hook";
- /** The Constant WRITE_HOOK. */
- public static final String WRITE_HOOK = "write:repo_hook";
-
- /** The Constant AMIN_HOOK. */
- public static final String AMIN_HOOK = "admin:repo_hook";
+ /** The Constant READ_KEY. */
+ public static final String READ_KEY = "read:public_key";
/** The Constant READ_ORG. */
public static final String READ_ORG = "read:org";
- /** The Constant WRITE_ORG. */
- public static final String WRITE_ORG = "write:org";
+ /** The Constant REPO. */
+ public static final String REPO = "repo";
- /** The Constant ADMIN_ORG. */
- public static final String ADMIN_ORG = "admin:org";
+ /** The Constant REPO_STATUS. */
+ public static final String REPO_STATUS = "repo:status";
- /** The Constant READ_KEY. */
- public static final String READ_KEY = "read:public_key";
+ /** The Constant USER. */
+ public static final String USER = "user";
+
+ /** The Constant USER_EMAIL. */
+ public static final String USER_EMAIL = "user:email";
+
+ /** The Constant USER_FOLLOW. */
+ public static final String USER_FOLLOW = "user:follow";
+
+ /** The Constant WRITE_HOOK. */
+ public static final String WRITE_HOOK = "write:repo_hook";
/** The Constant WRITE_KEY. */
public static final String WRITE_KEY = "write:public_key";
- /** The Constant ADMIN_KEY. */
- public static final String ADMIN_KEY = "admin:public_key";
+ /** The Constant WRITE_ORG. */
+ public static final String WRITE_ORG = "write:org";
- private List scopes;
- private String token;
- private String tokenLastEight;
- private String hashedToken;
private App app;
- private String note;
- private String noteUrl;
private String fingerprint;
// TODO add some user class for https://developer.github.com/v3/oauth_authorizations/#check-an-authorization ?
// private GHUser user;
+ private String hashedToken;
+ private String note;
+ private String noteUrl;
+ private List scopes;
+ private String token;
+ private String tokenLastEight;
/**
- * Gets scopes.
- *
- * @return the scopes
- */
- public List getScopes() {
- return Collections.unmodifiableList(scopes);
- }
-
- /**
- * Gets token.
- *
- * @return the token
+ * Create default GHAuthorization instance
*/
- public String getToken() {
- return token;
+ public GHAuthorization() {
}
/**
- * Gets token last eight.
+ * Gets app name.
*
- * @return the token last eight
+ * @return the app name
*/
- public String getTokenLastEight() {
- return tokenLastEight;
+ public String getAppName() {
+ return app.name;
}
/**
- * Gets hashed token.
+ * Gets app url.
*
- * @return the hashed token
+ * @return the app url
*/
- public String getHashedToken() {
- return hashedToken;
+ public URL getAppUrl() {
+ return GitHubClient.parseURL(app.url);
}
/**
- * Gets app url.
+ * Gets fingerprint.
*
- * @return the app url
+ * @return the fingerprint
*/
- public URL getAppUrl() {
- return GitHubClient.parseURL(app.url);
+ public String getFingerprint() {
+ return fingerprint;
}
/**
- * Gets app name.
+ * Gets hashed token.
*
- * @return the app name
+ * @return the hashed token
*/
- public String getAppName() {
- return app.name;
+ public String getHashedToken() {
+ return hashedToken;
}
/**
@@ -161,19 +151,29 @@ public URL getNoteUrl() {
}
/**
- * Gets fingerprint.
+ * Gets scopes.
*
- * @return the fingerprint
+ * @return the scopes
*/
- public String getFingerprint() {
- return fingerprint;
+ public List getScopes() {
+ return Collections.unmodifiableList(scopes);
}
- @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD" },
- justification = "JSON API")
- private static class App {
- private String url;
- private String name;
- // private String client_id; not yet used
+ /**
+ * Gets token.
+ *
+ * @return the token
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * Gets token last eight.
+ *
+ * @return the token last eight
+ */
+ public String getTokenLastEight() {
+ return tokenLastEight;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHAutolink.java b/src/main/java/org/kohsuke/github/GHAutolink.java
index 7165e8d0a1..9fe9c6a791 100644
--- a/src/main/java/org/kohsuke/github/GHAutolink.java
+++ b/src/main/java/org/kohsuke/github/GHAutolink.java
@@ -15,10 +15,10 @@
public class GHAutolink {
private int id;
- private String keyPrefix;
- private String urlTemplate;
private boolean isAlphanumeric;
+ private String keyPrefix;
private GHRepository owner;
+ private String urlTemplate;
/**
* Instantiates a new Gh autolink.
@@ -26,6 +26,20 @@ public class GHAutolink {
public GHAutolink() {
}
+ /**
+ * Deletes this autolink
+ *
+ * @throws IOException
+ * if the deletion fails
+ */
+ public void delete() throws IOException {
+ owner.root()
+ .createRequest()
+ .method("DELETE")
+ .withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
+ .send();
+ }
+
/**
* Gets the autolink ID
*
@@ -44,6 +58,16 @@ public String getKeyPrefix() {
return keyPrefix;
}
+ /**
+ * Gets the repository that owns this autolink
+ *
+ * @return the repository instance
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return owner;
+ }
+
/**
* Gets the URL template that will be used for matching
*
@@ -62,30 +86,6 @@ public boolean isAlphanumeric() {
return isAlphanumeric;
}
- /**
- * Gets the repository that owns this autolink
- *
- * @return the repository instance
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return owner;
- }
-
- /**
- * Deletes this autolink
- *
- * @throws IOException
- * if the deletion fails
- */
- public void delete() throws IOException {
- owner.root()
- .createRequest()
- .method("DELETE")
- .withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
- .send();
- }
-
/**
* Wraps this autolink with its owner repository.
*
diff --git a/src/main/java/org/kohsuke/github/GHAutolinkBuilder.java b/src/main/java/org/kohsuke/github/GHAutolinkBuilder.java
index 3082d9487d..c5726ced6e 100644
--- a/src/main/java/org/kohsuke/github/GHAutolinkBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHAutolinkBuilder.java
@@ -11,11 +11,11 @@
*/
public class GHAutolinkBuilder {
+ private Boolean isAlphanumeric;
+ private String keyPrefix;
private final GHRepository repo;
private final Requester req;
- private String keyPrefix;
private String urlTemplate;
- private Boolean isAlphanumeric;
/**
* Instantiates a new Gh autolink builder.
@@ -28,6 +28,37 @@ public class GHAutolinkBuilder {
req = repo.root().createRequest();
}
+ /**
+ * Create gh autolink.
+ *
+ * @return the gh autolink
+ * @throws IOException
+ * the io exception
+ */
+ public GHAutolink create() throws IOException {
+ GHAutolink autolink = req.method("POST")
+ .with("key_prefix", keyPrefix)
+ .with("url_template", urlTemplate)
+ .with("is_alphanumeric", isAlphanumeric)
+ .withHeader("Accept", "application/vnd.github+json")
+ .withUrlPath(getApiTail())
+ .fetch(GHAutolink.class);
+
+ return autolink.lateBind(repo);
+ }
+
+ /**
+ * With is alphanumeric gh autolink builder.
+ *
+ * @param isAlphanumeric
+ * the is alphanumeric
+ * @return the gh autolink builder
+ */
+ public GHAutolinkBuilder withIsAlphanumeric(boolean isAlphanumeric) {
+ this.isAlphanumeric = isAlphanumeric;
+ return this;
+ }
+
/**
* With key prefix gh autolink builder.
*
@@ -52,39 +83,8 @@ public GHAutolinkBuilder withUrlTemplate(String urlTemplate) {
return this;
}
- /**
- * With is alphanumeric gh autolink builder.
- *
- * @param isAlphanumeric
- * the is alphanumeric
- * @return the gh autolink builder
- */
- public GHAutolinkBuilder withIsAlphanumeric(boolean isAlphanumeric) {
- this.isAlphanumeric = isAlphanumeric;
- return this;
- }
-
private String getApiTail() {
return String.format("/repos/%s/%s/autolinks", repo.getOwnerName(), repo.getName());
}
- /**
- * Create gh autolink.
- *
- * @return the gh autolink
- * @throws IOException
- * the io exception
- */
- public GHAutolink create() throws IOException {
- GHAutolink autolink = req.method("POST")
- .with("key_prefix", keyPrefix)
- .with("url_template", urlTemplate)
- .with("is_alphanumeric", isAlphanumeric)
- .withHeader("Accept", "application/vnd.github+json")
- .withUrlPath(getApiTail())
- .fetch(GHAutolink.class);
-
- return autolink.lateBind(repo);
- }
-
}
diff --git a/src/main/java/org/kohsuke/github/GHBlob.java b/src/main/java/org/kohsuke/github/GHBlob.java
index 2fc168ec69..31c83b6ff4 100644
--- a/src/main/java/org/kohsuke/github/GHBlob.java
+++ b/src/main/java/org/kohsuke/github/GHBlob.java
@@ -17,22 +17,31 @@
*/
public class GHBlob {
+ private String content, encoding, url, sha;
+
+ private long size;
/**
* Create default GHBlob instance
*/
public GHBlob() {
}
- private String content, encoding, url, sha;
- private long size;
+ /**
+ * Gets content.
+ *
+ * @return Encoded content. You probably want {@link #read()}
+ */
+ public String getContent() {
+ return content;
+ }
/**
- * Gets url.
+ * Gets encoding.
*
- * @return API URL of this blob.
+ * @return the encoding
*/
- public URL getUrl() {
- return GitHubClient.parseURL(url);
+ public String getEncoding() {
+ return encoding;
}
/**
@@ -54,21 +63,12 @@ public long getSize() {
}
/**
- * Gets encoding.
- *
- * @return the encoding
- */
- public String getEncoding() {
- return encoding;
- }
-
- /**
- * Gets content.
+ * Gets url.
*
- * @return Encoded content. You probably want {@link #read()}
+ * @return API URL of this blob.
*/
- public String getContent() {
- return content;
+ public URL getUrl() {
+ return GitHubClient.parseURL(url);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHBlobBuilder.java b/src/main/java/org/kohsuke/github/GHBlobBuilder.java
index 187867689b..237768e503 100644
--- a/src/main/java/org/kohsuke/github/GHBlobBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHBlobBuilder.java
@@ -22,19 +22,6 @@ public class GHBlobBuilder {
req = repo.root().createRequest();
}
- /**
- * Configures a blob with the specified text {@code content}.
- *
- * @param content
- * string text of the blob
- * @return a GHBlobBuilder
- */
- public GHBlobBuilder textContent(String content) {
- req.with("content", content);
- req.with("encoding", "utf-8");
- return this;
- }
-
/**
* Configures a blob with the specified binary {@code content}.
*
@@ -49,10 +36,6 @@ public GHBlobBuilder binaryContent(byte[] content) {
return this;
}
- private String getApiTail() {
- return String.format("/repos/%s/%s/git/blobs", repo.getOwnerName(), repo.getName());
- }
-
/**
* Creates a blob based on the parameters specified thus far.
*
@@ -63,4 +46,21 @@ private String getApiTail() {
public GHBlob create() throws IOException {
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
}
+
+ /**
+ * Configures a blob with the specified text {@code content}.
+ *
+ * @param content
+ * string text of the blob
+ * @return a GHBlobBuilder
+ */
+ public GHBlobBuilder textContent(String content) {
+ req.with("content", content);
+ req.with("encoding", "utf-8");
+ return this;
+ }
+
+ private String getApiTail() {
+ return String.format("/repos/%s/%s/git/blobs", repo.getOwnerName(), repo.getName());
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java
index 08dcb49adc..c18bd23aa7 100644
--- a/src/main/java/org/kohsuke/github/GHBranch.java
+++ b/src/main/java/org/kohsuke/github/GHBranch.java
@@ -21,12 +21,31 @@
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranch extends GitHubInteractiveObject {
- private GHRepository owner;
+ /**
+ * The type Commit.
+ */
+ public static class Commit {
+
+ /** The sha. */
+ String sha;
+
+ /** The url. */
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
+ String url;
+
+ /**
+ * Create default Commit instance
+ */
+ public Commit() {
+ }
+ }
- private String name;
private Commit commit;
+ private String name;
+ private GHRepository owner;
@JsonProperty("protected")
private boolean protection;
+
private String protectionUrl;
/**
@@ -42,32 +61,23 @@ public class GHBranch extends GitHubInteractiveObject {
}
/**
- * The type Commit.
+ * Disables branch protection and allows anyone with push access to push changes.
+ *
+ * @throws IOException
+ * if disabling protection fails
*/
- public static class Commit {
-
- /**
- * Create default Commit instance
- */
- public Commit() {
- }
-
- /** The sha. */
- String sha;
-
- /** The url. */
- @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
- String url;
+ public void disableProtection() throws IOException {
+ root().createRequest().method("DELETE").setRawUrlPath(protectionUrl).send();
}
/**
- * Gets owner.
+ * Enables branch protection to control what commit statuses are required to push.
*
- * @return the repository that this branch is in.
+ * @return GHBranchProtectionBuilder for enabling protection
+ * @see GHCommitStatus#getContext() GHCommitStatus#getContext()
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return owner;
+ public GHBranchProtectionBuilder enableProtection() {
+ return new GHBranchProtectionBuilder(this);
}
/**
@@ -80,21 +90,13 @@ public String getName() {
}
/**
- * Is protected boolean.
- *
- * @return true if the push to this branch is restricted via branch protection.
- */
- public boolean isProtected() {
- return protection;
- }
-
- /**
- * Gets protection url.
+ * Gets owner.
*
- * @return API URL that deals with the protection of this branch.
+ * @return the repository that this branch is in.
*/
- public URL getProtectionUrl() {
- return GitHubClient.parseURL(protectionUrl);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return owner;
}
/**
@@ -109,32 +111,30 @@ public GHBranchProtection getProtection() throws IOException {
}
/**
- * Gets sha 1.
+ * Gets protection url.
*
- * @return The SHA1 of the commit that this branch currently points to.
+ * @return API URL that deals with the protection of this branch.
*/
- public String getSHA1() {
- return commit.sha;
+ public URL getProtectionUrl() {
+ return GitHubClient.parseURL(protectionUrl);
}
/**
- * Disables branch protection and allows anyone with push access to push changes.
+ * Gets sha 1.
*
- * @throws IOException
- * if disabling protection fails
+ * @return The SHA1 of the commit that this branch currently points to.
*/
- public void disableProtection() throws IOException {
- root().createRequest().method("DELETE").setRawUrlPath(protectionUrl).send();
+ public String getSHA1() {
+ return commit.sha;
}
/**
- * Enables branch protection to control what commit statuses are required to push.
+ * Is protected boolean.
*
- * @return GHBranchProtectionBuilder for enabling protection
- * @see GHCommitStatus#getContext() GHCommitStatus#getContext()
+ * @return true if the push to this branch is restricted via branch protection.
*/
- public GHBranchProtectionBuilder enableProtection() {
- return new GHBranchProtectionBuilder(this);
+ public boolean isProtected() {
+ return protection;
}
/**
@@ -190,15 +190,6 @@ public GHCommit merge(String head, String commitMessage) throws IOException {
return result;
}
- /**
- * Gets the api route.
- *
- * @return the api route
- */
- String getApiRoute() {
- return owner.getApiTailUrl("/branches/" + name);
- }
-
/**
* To string.
*
@@ -210,6 +201,15 @@ public String toString() {
return "Branch:" + name + " in " + url;
}
+ /**
+ * Gets the api route.
+ *
+ * @return the api route
+ */
+ String getApiRoute() {
+ return owner.getApiTailUrl("/branches/" + name);
+ }
+
/**
* Wrap.
*
diff --git a/src/main/java/org/kohsuke/github/GHBranchProtection.java b/src/main/java/org/kohsuke/github/GHBranchProtection.java
index 8fbdc0d232..f5d661459c 100644
--- a/src/main/java/org/kohsuke/github/GHBranchProtection.java
+++ b/src/main/java/org/kohsuke/github/GHBranchProtection.java
@@ -20,207 +20,20 @@
justification = "JSON API")
public class GHBranchProtection extends GitHubInteractiveObject {
- /**
- * Create default GHBranchProtection instance
- */
- public GHBranchProtection() {
- }
-
- private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
-
- @JsonProperty
- private AllowDeletions allowDeletions;
-
- @JsonProperty
- private AllowForcePushes allowForcePushes;
-
- @JsonProperty
- private AllowForkSyncing allowForkSyncing;
-
- @JsonProperty
- private BlockCreations blockCreations;
-
- @JsonProperty
- private EnforceAdmins enforceAdmins;
-
- @JsonProperty
- private LockBranch lockBranch;
-
- @JsonProperty
- private RequiredConversationResolution requiredConversationResolution;
-
- @JsonProperty
- private RequiredLinearHistory requiredLinearHistory;
-
- @JsonProperty("required_pull_request_reviews")
- private RequiredReviews requiredReviews;
-
- @JsonProperty
- private RequiredStatusChecks requiredStatusChecks;
-
- @JsonProperty
- private Restrictions restrictions;
-
- @JsonProperty
- private String url;
-
- /**
- * Enabled signed commits.
- *
- * @throws IOException
- * the io exception
- */
- public void enabledSignedCommits() throws IOException {
- requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
- }
-
- /**
- * Disable signed commits.
- *
- * @throws IOException
- * the io exception
- */
- public void disableSignedCommits() throws IOException {
- requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
- }
-
- /**
- * Gets allow deletions.
- *
- * @return the enforce admins
- */
- public AllowDeletions getAllowDeletions() {
- return allowDeletions;
- }
-
- /**
- * Gets allow force pushes.
- *
- * @return the enforce admins
- */
- public AllowForcePushes getAllowForcePushes() {
- return allowForcePushes;
- }
-
- /**
- * Gets allow fork syncing.
- *
- * @return the enforce admins
- */
- public AllowForkSyncing getAllowForkSyncing() {
- return allowForkSyncing;
- }
-
- /**
- * Gets block creations.
- *
- * @return the enforce admins
- */
- public BlockCreations getBlockCreations() {
- return blockCreations;
- }
-
- /**
- * Gets enforce admins.
- *
- * @return the enforce admins
- */
- public EnforceAdmins getEnforceAdmins() {
- return enforceAdmins;
- }
-
- /**
- * Gets lock branch.
- *
- * @return the enforce admins
- */
- public LockBranch getLockBranch() {
- return lockBranch;
- }
-
- /**
- * Gets required conversation resolution.
- *
- * @return the enforce admins
- */
- public RequiredConversationResolution getRequiredConversationResolution() {
- return requiredConversationResolution;
- }
-
- /**
- * Gets required linear history.
- *
- * @return the enforce admins
- */
- public RequiredLinearHistory getRequiredLinearHistory() {
- return requiredLinearHistory;
- }
-
- /**
- * Gets required reviews.
- *
- * @return the required reviews
- */
- public RequiredReviews getRequiredReviews() {
- return requiredReviews;
- }
-
- /**
- * Gets required signatures.
- *
- * @return the required signatures
- * @throws IOException
- * the io exception
- */
- public boolean getRequiredSignatures() throws IOException {
- return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
- }
-
- /**
- * Gets required status checks.
- *
- * @return the required status checks
- */
- public RequiredStatusChecks getRequiredStatusChecks() {
- return requiredStatusChecks;
- }
-
- /**
- * Gets restrictions.
- *
- * @return the restrictions
- */
- public Restrictions getRestrictions() {
- return restrictions;
- }
-
- /**
- * Gets url.
- *
- * @return the url
- */
- public String getUrl() {
- return url;
- }
-
- private Requester requester() {
- return root().createRequest();
- }
-
/**
* The type AllowDeletions.
*/
public static class AllowDeletions {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default AllowDeletions instance
*/
public AllowDeletions() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -231,69 +44,20 @@ public boolean isEnabled() {
}
}
- /**
- * The type Check.
- */
- public static class Check {
- private String context;
-
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private Integer appId;
-
- /**
- * no-arg constructor for the serializer
- */
- public Check() {
- }
-
- /**
- * Regular constructor for use in user business logic
- *
- * @param context
- * the context string of the check
- * @param appId
- * the application ID the check is supposed to come from. Pass "-1" to explicitly allow any app to
- * set the status. Pass "null" to automatically select the GitHub App that has recently provided this
- * check.
- */
- public Check(String context, Integer appId) {
- this.context = context;
- this.appId = appId;
- }
-
- /**
- * The context string of the check
- *
- * @return the string
- */
- public String getContext() {
- return context;
- }
-
- /**
- * The application ID the check is supposed to come from. The value "-1" indicates "any source".
- *
- * @return the integer
- */
- public Integer getAppId() {
- return appId;
- }
- }
-
/**
* The type AllowForcePushes.
*/
public static class AllowForcePushes {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default AllowForcePushes instance
*/
public AllowForcePushes() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -309,15 +73,15 @@ public boolean isEnabled() {
*/
public static class AllowForkSyncing {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default AllowForkSyncing instance
*/
public AllowForkSyncing() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -333,15 +97,15 @@ public boolean isEnabled() {
*/
public static class BlockCreations {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default BlockCreations instance
*/
public BlockCreations() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -353,15 +117,58 @@ public boolean isEnabled() {
}
/**
- * The type EnforceAdmins.
+ * The type Check.
*/
- public static class EnforceAdmins {
+ public static class Check {
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Integer appId;
+
+ private String context;
/**
- * Create default EnforceAdmins instance
+ * no-arg constructor for the serializer
*/
- public EnforceAdmins() {
+ public Check() {
+ }
+
+ /**
+ * Regular constructor for use in user business logic
+ *
+ * @param context
+ * the context string of the check
+ * @param appId
+ * the application ID the check is supposed to come from. Pass "-1" to explicitly allow any app to
+ * set the status. Pass "null" to automatically select the GitHub App that has recently provided this
+ * check.
+ */
+ public Check(String context, Integer appId) {
+ this.context = context;
+ this.appId = appId;
+ }
+
+ /**
+ * The application ID the check is supposed to come from. The value "-1" indicates "any source".
+ *
+ * @return the integer
+ */
+ public Integer getAppId() {
+ return appId;
+ }
+
+ /**
+ * The context string of the check
+ *
+ * @return the string
+ */
+ public String getContext() {
+ return context;
}
+ }
+
+ /**
+ * The type EnforceAdmins.
+ */
+ public static class EnforceAdmins {
@JsonProperty
private boolean enabled;
@@ -369,6 +176,12 @@ public EnforceAdmins() {
@JsonProperty
private String url;
+ /**
+ * Create default EnforceAdmins instance
+ */
+ public EnforceAdmins() {
+ }
+
/**
* Gets url.
*
@@ -393,15 +206,15 @@ public boolean isEnabled() {
*/
public static class LockBranch {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default LockBranch instance
*/
public LockBranch() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -417,15 +230,15 @@ public boolean isEnabled() {
*/
public static class RequiredConversationResolution {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default RequiredConversationResolution instance
*/
public RequiredConversationResolution() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -441,15 +254,15 @@ public boolean isEnabled() {
*/
public static class RequiredLinearHistory {
+ @JsonProperty
+ private boolean enabled;
+
/**
* Create default RequiredLinearHistory instance
*/
public RequiredLinearHistory() {
}
- @JsonProperty
- private boolean enabled;
-
/**
* Is enabled boolean.
*
@@ -465,18 +278,12 @@ public boolean isEnabled() {
*/
public static class RequiredReviews {
- /**
- * Create default RequiredReviews instance
- */
- public RequiredReviews() {
- }
+ @JsonProperty
+ private boolean dismissStaleReviews;
@JsonProperty("dismissal_restrictions")
private Restrictions dismissalRestriction;
- @JsonProperty
- private boolean dismissStaleReviews;
-
@JsonProperty
private boolean requireCodeOwnerReviews;
@@ -489,6 +296,12 @@ public RequiredReviews() {
@JsonProperty
private String url;
+ /**
+ * Create default RequiredReviews instance
+ */
+ public RequiredReviews() {
+ }
+
/**
* Gets dismissal restrictions.
*
@@ -498,6 +311,15 @@ public Restrictions getDismissalRestrictions() {
return dismissalRestriction;
}
+ /**
+ * Gets required reviewers.
+ *
+ * @return the required reviewers
+ */
+ public int getRequiredReviewers() {
+ return requiredReviewers;
+ }
+
/**
* Gets url.
*
@@ -526,47 +348,12 @@ public boolean isRequireCodeOwnerReviews() {
}
/**
- * Is require last push approval boolean.
- *
- * @return the boolean
- */
- public boolean isRequireLastPushApproval() {
- return requireLastPushApproval;
- }
-
- /**
- * Gets required reviewers.
- *
- * @return the required reviewers
- */
- public int getRequiredReviewers() {
- return requiredReviewers;
- }
- }
-
- private static class RequiredSignatures {
- @JsonProperty
- private boolean enabled;
-
- @JsonProperty
- private String url;
-
- /**
- * Gets url.
- *
- * @return the url
- */
- public String getUrl() {
- return url;
- }
-
- /**
- * Is enabled boolean.
+ * Is require last push approval boolean.
*
* @return the boolean
*/
- public boolean isEnabled() {
- return enabled;
+ public boolean isRequireLastPushApproval() {
+ return requireLastPushApproval;
}
}
@@ -575,17 +362,11 @@ public boolean isEnabled() {
*/
public static class RequiredStatusChecks {
- /**
- * Create default RequiredStatusChecks instance
- */
- public RequiredStatusChecks() {
- }
-
@JsonProperty
- private Collection contexts;
+ private Collection checks;
@JsonProperty
- private Collection checks;
+ private Collection contexts;
@JsonProperty
private boolean strict;
@@ -594,12 +375,9 @@ public RequiredStatusChecks() {
private String url;
/**
- * Gets contexts.
- *
- * @return the contexts
+ * Create default RequiredStatusChecks instance
*/
- public Collection getContexts() {
- return Collections.unmodifiableCollection(contexts);
+ public RequiredStatusChecks() {
}
/**
@@ -611,6 +389,15 @@ public Collection getChecks() {
return Collections.unmodifiableCollection(checks);
}
+ /**
+ * Gets contexts.
+ *
+ * @return the contexts
+ */
+ public Collection getContexts() {
+ return Collections.unmodifiableCollection(contexts);
+ }
+
/**
* Gets url.
*
@@ -635,12 +422,6 @@ public boolean isRequiresBranchUpToDate() {
*/
public static class Restrictions {
- /**
- * Create default Restrictions instance
- */
- public Restrictions() {
- }
-
@JsonProperty
private Collection teams;
@@ -654,6 +435,12 @@ public Restrictions() {
private String usersUrl;
+ /**
+ * Create default Restrictions instance
+ */
+ public Restrictions() {
+ }
+
/**
* Gets teams.
*
@@ -699,4 +486,217 @@ public String getUsersUrl() {
return usersUrl;
}
}
+
+ private static class RequiredSignatures {
+ @JsonProperty
+ private boolean enabled;
+
+ @JsonProperty
+ private String url;
+
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * Is enabled boolean.
+ *
+ * @return the boolean
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+ }
+
+ private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
+
+ @JsonProperty
+ private AllowDeletions allowDeletions;
+
+ @JsonProperty
+ private AllowForcePushes allowForcePushes;
+
+ @JsonProperty
+ private AllowForkSyncing allowForkSyncing;
+
+ @JsonProperty
+ private BlockCreations blockCreations;
+
+ @JsonProperty
+ private EnforceAdmins enforceAdmins;
+
+ @JsonProperty
+ private LockBranch lockBranch;
+
+ @JsonProperty
+ private RequiredConversationResolution requiredConversationResolution;
+
+ @JsonProperty
+ private RequiredLinearHistory requiredLinearHistory;
+
+ @JsonProperty("required_pull_request_reviews")
+ private RequiredReviews requiredReviews;
+
+ @JsonProperty
+ private RequiredStatusChecks requiredStatusChecks;
+
+ @JsonProperty
+ private Restrictions restrictions;
+
+ @JsonProperty
+ private String url;
+
+ /**
+ * Create default GHBranchProtection instance
+ */
+ public GHBranchProtection() {
+ }
+
+ /**
+ * Disable signed commits.
+ *
+ * @throws IOException
+ * the io exception
+ */
+ public void disableSignedCommits() throws IOException {
+ requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
+ }
+
+ /**
+ * Enabled signed commits.
+ *
+ * @throws IOException
+ * the io exception
+ */
+ public void enabledSignedCommits() throws IOException {
+ requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
+ }
+
+ /**
+ * Gets allow deletions.
+ *
+ * @return the enforce admins
+ */
+ public AllowDeletions getAllowDeletions() {
+ return allowDeletions;
+ }
+
+ /**
+ * Gets allow force pushes.
+ *
+ * @return the enforce admins
+ */
+ public AllowForcePushes getAllowForcePushes() {
+ return allowForcePushes;
+ }
+
+ /**
+ * Gets allow fork syncing.
+ *
+ * @return the enforce admins
+ */
+ public AllowForkSyncing getAllowForkSyncing() {
+ return allowForkSyncing;
+ }
+
+ /**
+ * Gets block creations.
+ *
+ * @return the enforce admins
+ */
+ public BlockCreations getBlockCreations() {
+ return blockCreations;
+ }
+
+ /**
+ * Gets enforce admins.
+ *
+ * @return the enforce admins
+ */
+ public EnforceAdmins getEnforceAdmins() {
+ return enforceAdmins;
+ }
+
+ /**
+ * Gets lock branch.
+ *
+ * @return the enforce admins
+ */
+ public LockBranch getLockBranch() {
+ return lockBranch;
+ }
+
+ /**
+ * Gets required conversation resolution.
+ *
+ * @return the enforce admins
+ */
+ public RequiredConversationResolution getRequiredConversationResolution() {
+ return requiredConversationResolution;
+ }
+
+ /**
+ * Gets required linear history.
+ *
+ * @return the enforce admins
+ */
+ public RequiredLinearHistory getRequiredLinearHistory() {
+ return requiredLinearHistory;
+ }
+
+ /**
+ * Gets required reviews.
+ *
+ * @return the required reviews
+ */
+ public RequiredReviews getRequiredReviews() {
+ return requiredReviews;
+ }
+
+ /**
+ * Gets required signatures.
+ *
+ * @return the required signatures
+ * @throws IOException
+ * the io exception
+ */
+ public boolean getRequiredSignatures() throws IOException {
+ return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
+ }
+
+ /**
+ * Gets required status checks.
+ *
+ * @return the required status checks
+ */
+ public RequiredStatusChecks getRequiredStatusChecks() {
+ return requiredStatusChecks;
+ }
+
+ /**
+ * Gets restrictions.
+ *
+ * @return the restrictions
+ */
+ public Restrictions getRestrictions() {
+ return restrictions;
+ }
+
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ private Requester requester() {
+ return root().createRequest();
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java
index c56e7f2197..5b1521d9f1 100644
--- a/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHBranchProtectionBuilder.java
@@ -23,11 +23,21 @@
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranchProtectionBuilder {
- private final GHBranch branch;
+ private static class Restrictions {
+ private Set teams = new HashSet();
+ private Set users = new HashSet();
+ }
+ private static class StatusChecks {
+ final List checks = new ArrayList<>();
+ boolean strict;
+ }
+ private final GHBranch branch;
private Map fields = new HashMap();
private Map prReviews;
+
private Restrictions restrictions;
+
private StatusChecks statusChecks;
/**
@@ -48,8 +58,8 @@ public class GHBranchProtectionBuilder {
* the checks
* @return the gh branch protection builder
*/
- public GHBranchProtectionBuilder addRequiredStatusChecks(Collection checks) {
- getStatusChecks().checks.addAll(checks);
+ public GHBranchProtectionBuilder addRequiredChecks(GHBranchProtection.Check... checks) {
+ addRequiredStatusChecks(Arrays.asList(checks));
return this;
}
@@ -60,8 +70,8 @@ public GHBranchProtectionBuilder addRequiredStatusChecks(Collection checks) {
+ getStatusChecks().checks.addAll(checks);
return this;
}
@@ -235,18 +245,6 @@ public GHBranchProtectionBuilder lockBranch(boolean v) {
return this;
}
- /**
- * Required reviewers gh branch protection builder.
- *
- * @param v
- * the v
- * @return the gh branch protection builder
- */
- public GHBranchProtectionBuilder requiredReviewers(int v) {
- getPrReviews().put("required_approving_review_count", v);
- return this;
- }
-
/**
* Require branch is up to date gh branch protection builder.
*
@@ -310,6 +308,16 @@ public GHBranchProtectionBuilder requireLastPushApproval(boolean v) {
return this;
}
+ /**
+ * Require reviews gh branch protection builder.
+ *
+ * @return the gh branch protection builder
+ */
+ public GHBranchProtectionBuilder requireReviews() {
+ getPrReviews();
+ return this;
+ }
+
/**
* Require all conversations on code to be resolved before a pull request can be merged into a branch that matches
* this rule.
@@ -357,12 +365,24 @@ public GHBranchProtectionBuilder requiredLinearHistory(boolean v) {
}
/**
- * Require reviews gh branch protection builder.
+ * Required reviewers gh branch protection builder.
*
+ * @param v
+ * the v
* @return the gh branch protection builder
*/
- public GHBranchProtectionBuilder requireReviews() {
- getPrReviews();
+ public GHBranchProtectionBuilder requiredReviewers(int v) {
+ getPrReviews().put("required_approving_review_count", v);
+ return this;
+ }
+
+ /**
+ * Restrict push access gh branch protection builder.
+ *
+ * @return the gh branch protection builder
+ */
+ public GHBranchProtectionBuilder restrictPushAccess() {
+ getRestrictions();
return this;
}
@@ -381,16 +401,6 @@ public GHBranchProtectionBuilder restrictReviewDismissals() {
return this;
}
- /**
- * Restrict push access gh branch protection builder.
- *
- * @return the gh branch protection builder
- */
- public GHBranchProtectionBuilder restrictPushAccess() {
- getRestrictions();
- return this;
- }
-
/**
* Team push access gh branch protection builder.
*
@@ -538,14 +548,4 @@ private StatusChecks getStatusChecks() {
private Requester requester() {
return branch.root().createRequest();
}
-
- private static class Restrictions {
- private Set teams = new HashSet();
- private Set users = new HashSet();
- }
-
- private static class StatusChecks {
- final List checks = new ArrayList<>();
- boolean strict;
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHBranchSync.java b/src/main/java/org/kohsuke/github/GHBranchSync.java
index c6823abd51..47b1a34158 100644
--- a/src/main/java/org/kohsuke/github/GHBranchSync.java
+++ b/src/main/java/org/kohsuke/github/GHBranchSync.java
@@ -8,15 +8,14 @@
public class GHBranchSync extends GitHubInteractiveObject {
/**
- * Create default GHBranchSync instance
+ * The base branch.
*/
- public GHBranchSync() {
- }
+ private String baseBranch;
/**
- * The Repository that this branch is in.
+ * The merge type.
*/
- private GHRepository owner;
+ private String mergeType;
/**
* The message.
@@ -24,32 +23,23 @@ public GHBranchSync() {
private String message;
/**
- * The merge type.
- */
- private String mergeType;
-
- /**
- * The base branch.
+ * The Repository that this branch is in.
*/
- private String baseBranch;
+ private GHRepository owner;
/**
- * Gets owner.
- *
- * @return the repository that this branch is in.
+ * Create default GHBranchSync instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return owner;
+ public GHBranchSync() {
}
/**
- * Gets message.
+ * Gets base branch.
*
- * @return the message
+ * @return the base branch
*/
- public String getMessage() {
- return message;
+ public String getBaseBranch() {
+ return baseBranch;
}
/**
@@ -62,12 +52,22 @@ public String getMergeType() {
}
/**
- * Gets base branch.
+ * Gets message.
*
- * @return the base branch
+ * @return the message
*/
- public String getBaseBranch() {
- return baseBranch;
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Gets owner.
+ *
+ * @return the repository that this branch is in.
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return owner;
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCheckRun.java b/src/main/java/org/kohsuke/github/GHCheckRun.java
index 8befbba46b..2c776af8d7 100644
--- a/src/main/java/org/kohsuke/github/GHCheckRun.java
+++ b/src/main/java/org/kohsuke/github/GHCheckRun.java
@@ -26,88 +26,42 @@
public class GHCheckRun extends GHObject {
/**
- * Create default GHCheckRun instance
- */
- public GHCheckRun() {
- }
-
- /** The owner. */
- @JsonProperty("repository")
- GHRepository owner;
-
- private String status;
- private String conclusion;
- private String name;
- private String headSha;
- private String nodeId;
- private String externalId;
- private String startedAt;
- private String completedAt;
- private String htmlUrl;
- private String detailsUrl;
- private Output output;
- private GHApp app;
- private GHPullRequest[] pullRequests = new GHPullRequest[0];
- private GHCheckSuite checkSuite;
-
- /**
- * Wrap.
- *
- * @param owner
- * the owner
- * @return the GH check run
- */
- GHCheckRun wrap(GHRepository owner) {
- this.owner = owner;
- wrap(owner.root());
- return this;
- }
-
- /**
- * Wrap.
- *
- * @param root
- * the root
- * @return the GH check run
+ * The Enum AnnotationLevel.
*/
- GHCheckRun wrap(GitHub root) {
- if (owner != null) {
- for (GHPullRequest singlePull : pullRequests) {
- singlePull.wrap(owner);
- }
- }
- if (checkSuite != null) {
- if (owner != null) {
- checkSuite.wrap(owner);
- } else {
- checkSuite.wrap(root);
- }
- }
+ public static enum AnnotationLevel {
- return this;
+ /** The failure. */
+ FAILURE,
+ /** The notice. */
+ NOTICE,
+ /** The warning. */
+ WARNING
}
/**
- * Gets status of the check run.
+ * Final conclusion of the check.
*
- * @return Status of the check run
- * @see Status
- */
- public Status getStatus() {
- return Status.from(status);
- }
-
- /**
- * The Enum Status.
+ * From Check Run
+ * Parameters - conclusion
.
*/
- public static enum Status {
+ public static enum Conclusion {
- /** The queued. */
- QUEUED,
- /** The in progress. */
- IN_PROGRESS,
- /** The completed. */
- COMPLETED,
+ /** The action required. */
+ ACTION_REQUIRED,
+ /** The cancelled. */
+ CANCELLED,
+ /** The failure. */
+ FAILURE,
+ /** The neutral. */
+ NEUTRAL,
+ /** The skipped. */
+ SKIPPED,
+ /** The stale. */
+ STALE,
+ /** The success. */
+ SUCCESS,
+ /** The timed out. */
+ TIMED_OUT,
/** The unknown. */
UNKNOWN;
@@ -116,10 +70,10 @@ public static enum Status {
*
* @param value
* the value
- * @return the status
+ * @return the conclusion
*/
- public static Status from(String value) {
- return EnumUtils.getNullableEnumOrDefault(Status.class, value, Status.UNKNOWN);
+ public static Conclusion from(String value) {
+ return EnumUtils.getNullableEnumOrDefault(Conclusion.class, value, Conclusion.UNKNOWN);
}
/**
@@ -134,39 +88,80 @@ public String toString() {
}
/**
- * Gets conclusion of a completed check run.
+ * Represents an output in a check run to include summary and other results.
*
- * @return Status of the check run
- * @see Conclusion
+ * @see documentation
*/
- public Conclusion getConclusion() {
- return Conclusion.from(conclusion);
- }
+ public static class Output {
+ private int annotationsCount;
+
+ private String annotationsUrl;
+ private String summary;
+ private String text;
+ private String title;
+ /**
+ * Create default Output instance
+ */
+ public Output() {
+ }
+
+ /**
+ * Gets the annotation count of a check run.
+ *
+ * @return annotation count of a check run
+ */
+ public int getAnnotationsCount() {
+ return annotationsCount;
+ }
+
+ /**
+ * Gets the URL of annotations.
+ *
+ * @return URL of annotations
+ */
+ public URL getAnnotationsUrl() {
+ return GitHubClient.parseURL(annotationsUrl);
+ }
+
+ /**
+ * Gets the summary of the check run, note that it supports Markdown.
+ *
+ * @return summary of check run
+ */
+ public String getSummary() {
+ return summary;
+ }
+
+ /**
+ * Gets the details of the check run, note that it supports Markdown.
+ *
+ * @return Details of the check run
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Gets the title of check run.
+ *
+ * @return title of check run
+ */
+ public String getTitle() {
+ return title;
+ }
+ }
/**
- * Final conclusion of the check.
- *
- * From Check Run
- * Parameters - conclusion
.
+ * The Enum Status.
*/
- public static enum Conclusion {
+ public static enum Status {
- /** The action required. */
- ACTION_REQUIRED,
- /** The cancelled. */
- CANCELLED,
- /** The failure. */
- FAILURE,
- /** The neutral. */
- NEUTRAL,
- /** The success. */
- SUCCESS,
- /** The skipped. */
- SKIPPED,
- /** The stale. */
- STALE,
- /** The timed out. */
- TIMED_OUT,
+ /** The completed. */
+ COMPLETED,
+ /** The in progress. */
+ IN_PROGRESS,
+ /** The queued. */
+ QUEUED,
/** The unknown. */
UNKNOWN;
@@ -175,10 +170,10 @@ public static enum Conclusion {
*
* @param value
* the value
- * @return the conclusion
+ * @return the status
*/
- public static Conclusion from(String value) {
- return EnumUtils.getNullableEnumOrDefault(Conclusion.class, value, Conclusion.UNKNOWN);
+ public static Status from(String value) {
+ return EnumUtils.getNullableEnumOrDefault(Status.class, value, Status.UNKNOWN);
}
/**
@@ -191,70 +186,71 @@ public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}
+ private GHApp app;
+ private GHCheckSuite checkSuite;
+ private String completedAt;
+ private String conclusion;
+ private String detailsUrl;
+ private String externalId;
+ private String headSha;
+ private String htmlUrl;
+ private String name;
+ private String nodeId;
+ private Output output;
+ private GHPullRequest[] pullRequests = new GHPullRequest[0];
- /**
- * Gets the custom name of this check run.
- *
- * @return Name of the check run
- */
- public String getName() {
- return name;
- }
+ private String startedAt;
+
+ private String status;
+
+ /** The owner. */
+ @JsonProperty("repository")
+ GHRepository owner;
/**
- * Gets the HEAD SHA.
- *
- * @return sha for the HEAD commit
+ * Create default GHCheckRun instance
*/
- public String getHeadSha() {
- return headSha;
+ public GHCheckRun() {
}
/**
- * Gets the pull requests participated in this check run.
- *
- * Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
- * always empty.
+ * Gets the GitHub app this check run belongs to, included in response.
*
- * @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
- * @throws IOException
- * the io exception
+ * @return GitHub App
*/
- public List getPullRequests() throws IOException {
- for (GHPullRequest singlePull : pullRequests) {
- // Only refresh if we haven't do so before
- singlePull.refresh(singlePull.getTitle());
- }
- return Collections.unmodifiableList(Arrays.asList(pullRequests));
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHApp getApp() {
+ return app;
}
/**
- * Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
- * the check run.
+ * Gets the check suite this check run belongs to.
*
- * @return HTML URL
+ * @return Check suite
*/
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHCheckSuite getCheckSuite() {
+ return checkSuite;
}
/**
- * Gets the global node id to access most objects in GitHub.
+ * Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
*
- * @return Global node id
- * @see documentation
+ * @return Timestamp of the completed time
*/
- public String getNodeId() {
- return nodeId;
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCompletedAt() {
+ return GitHubClient.parseInstant(completedAt);
}
/**
- * Gets a reference for the check run on the integrator's system.
+ * Gets conclusion of a completed check run.
*
- * @return Reference id
+ * @return Status of the check run
+ * @see Conclusion
*/
- public String getExternalId() {
- return externalId;
+ public Conclusion getConclusion() {
+ return Conclusion.from(conclusion);
}
/**
@@ -267,43 +263,50 @@ public URL getDetailsUrl() {
}
/**
- * Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
+ * Gets a reference for the check run on the integrator's system.
*
- * @return Timestamp of the start time
+ * @return Reference id
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getStartedAt() {
- return GitHubClient.parseInstant(startedAt);
+ public String getExternalId() {
+ return externalId;
}
/**
- * Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
+ * Gets the HEAD SHA.
*
- * @return Timestamp of the completed time
+ * @return sha for the HEAD commit
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getCompletedAt() {
- return GitHubClient.parseInstant(completedAt);
+ public String getHeadSha() {
+ return headSha;
}
/**
- * Gets the GitHub app this check run belongs to, included in response.
+ * Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
+ * the check run.
*
- * @return GitHub App
+ * @return HTML URL
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHApp getApp() {
- return app;
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * Gets the check suite this check run belongs to.
+ * Gets the custom name of this check run.
*
- * @return Check suite
+ * @return Name of the check run
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHCheckSuite getCheckSuite() {
- return checkSuite;
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the global node id to access most objects in GitHub.
+ *
+ * @return Global node id
+ * @see documentation
+ */
+ public String getNodeId() {
+ return nodeId;
}
/**
@@ -317,81 +320,41 @@ public Output getOutput() {
}
/**
- * Represents an output in a check run to include summary and other results.
+ * Gets the pull requests participated in this check run.
*
- * @see documentation
+ * Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
+ * always empty.
+ *
+ * @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
+ * @throws IOException
+ * the io exception
*/
- public static class Output {
-
- /**
- * Create default Output instance
- */
- public Output() {
- }
-
- private String title;
- private String summary;
- private String text;
- private int annotationsCount;
- private String annotationsUrl;
-
- /**
- * Gets the title of check run.
- *
- * @return title of check run
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Gets the summary of the check run, note that it supports Markdown.
- *
- * @return summary of check run
- */
- public String getSummary() {
- return summary;
- }
-
- /**
- * Gets the details of the check run, note that it supports Markdown.
- *
- * @return Details of the check run
- */
- public String getText() {
- return text;
- }
-
- /**
- * Gets the annotation count of a check run.
- *
- * @return annotation count of a check run
- */
- public int getAnnotationsCount() {
- return annotationsCount;
- }
-
- /**
- * Gets the URL of annotations.
- *
- * @return URL of annotations
- */
- public URL getAnnotationsUrl() {
- return GitHubClient.parseURL(annotationsUrl);
+ public List getPullRequests() throws IOException {
+ for (GHPullRequest singlePull : pullRequests) {
+ // Only refresh if we haven't do so before
+ singlePull.refresh(singlePull.getTitle());
}
+ return Collections.unmodifiableList(Arrays.asList(pullRequests));
}
/**
- * The Enum AnnotationLevel.
+ * Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
+ *
+ * @return Timestamp of the start time
*/
- public static enum AnnotationLevel {
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStartedAt() {
+ return GitHubClient.parseInstant(startedAt);
+ }
- /** The notice. */
- NOTICE,
- /** The warning. */
- WARNING,
- /** The failure. */
- FAILURE
+ /**
+ * Gets status of the check run.
+ *
+ * @return Status of the check run
+ * @see Status
+ */
+ public Status getStatus() {
+ return Status.from(status);
}
/**
@@ -403,4 +366,41 @@ public static enum AnnotationLevel {
return new GHCheckRunBuilder(owner, getId());
}
+ /**
+ * Wrap.
+ *
+ * @param owner
+ * the owner
+ * @return the GH check run
+ */
+ GHCheckRun wrap(GHRepository owner) {
+ this.owner = owner;
+ wrap(owner.root());
+ return this;
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param root
+ * the root
+ * @return the GH check run
+ */
+ GHCheckRun wrap(GitHub root) {
+ if (owner != null) {
+ for (GHPullRequest singlePull : pullRequests) {
+ singlePull.wrap(owner);
+ }
+ }
+ if (checkSuite != null) {
+ if (owner != null) {
+ checkSuite.wrap(owner);
+ } else {
+ checkSuite.wrap(root);
+ }
+ }
+
+ return this;
+ }
+
}
diff --git a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
index fb996239e2..0dcff092ba 100644
--- a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
@@ -50,239 +50,186 @@
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
public final class GHCheckRunBuilder {
- /** The repo. */
- protected final GHRepository repo;
-
- /** The requester. */
- protected final Requester requester;
- private Output output;
- private List actions;
-
- private GHCheckRunBuilder(GHRepository repo, Requester requester) {
- this.repo = repo;
- this.requester = requester;
- }
-
/**
- * Instantiates a new GH check run builder.
+ * The Class Action.
*
- * @param repo
- * the repo
- * @param name
- * the name
- * @param headSHA
- * the head SHA
+ * @see documentation
*/
- GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
- this(repo,
- repo.root()
- .createRequest()
- .method("POST")
- .with("name", name)
- .with("head_sha", headSHA)
- .withUrlPath(repo.getApiTailUrl("check-runs")));
- }
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static final class Action {
- /**
- * Instantiates a new GH check run builder.
- *
- * @param repo
- * the repo
- * @param checkId
- * the check id
- */
- GHCheckRunBuilder(GHRepository repo, long checkId) {
- this(repo,
- repo.root().createRequest().method("PATCH").withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
- }
+ private final String description;
+ private final String identifier;
+ private final String label;
- /**
- * With name.
- *
- * @param name
- * the name
- * @param oldName
- * the old name
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withName(@CheckForNull String name, String oldName) {
- if (oldName == null) {
- throw new GHException("Can not update uncreated check run");
+ /**
+ * Instantiates a new action.
+ *
+ * @param label
+ * the label
+ * @param description
+ * the description
+ * @param identifier
+ * the identifier
+ */
+ public Action(@NonNull String label, @NonNull String description, @NonNull String identifier) {
+ this.label = label;
+ this.description = description;
+ this.identifier = identifier;
}
- requester.with("name", name);
- return this;
- }
- /**
- * With details URL.
- *
- * @param detailsURL
- * the details URL
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
- requester.with("details_url", detailsURL);
- return this;
}
/**
- * With external ID.
+ * The Class Annotation.
*
- * @param externalID
- * the external ID
- * @return the GH check run builder
+ * @see documentation
*/
- public @NonNull GHCheckRunBuilder withExternalID(@CheckForNull String externalID) {
- requester.with("external_id", externalID);
- return this;
- }
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static final class Annotation {
- /**
- * With status.
- *
- * @param status
- * the status
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withStatus(@CheckForNull GHCheckRun.Status status) {
- if (status != null) {
- // Do *not* use the overload taking Enum, as that s/_/-/g which would be wrong here.
- requester.with("status", status.toString().toLowerCase(Locale.ROOT));
- }
- return this;
- }
+ private final String annotationLevel;
+ private Integer endColumn;
+ private final int endLine;
+ private final String message;
+ private final String path;
+ private String rawDetails;
+ private Integer startColumn;
+ private final int startLine;
+ private String title;
- /**
- * With conclusion.
- *
- * @param conclusion
- * the conclusion
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withConclusion(@CheckForNull GHCheckRun.Conclusion conclusion) {
- if (conclusion != null) {
- requester.with("conclusion", conclusion.toString().toLowerCase(Locale.ROOT));
+ /**
+ * Instantiates a new annotation.
+ *
+ * @param path
+ * the path
+ * @param line
+ * the line
+ * @param annotationLevel
+ * the annotation level
+ * @param message
+ * the message
+ */
+ public Annotation(@NonNull String path,
+ int line,
+ @NonNull GHCheckRun.AnnotationLevel annotationLevel,
+ @NonNull String message) {
+ this(path, line, line, annotationLevel, message);
}
- return this;
- }
- /**
- * With started at.
- *
- * @param startedAt
- * the started at
- * @return the GH check run builder
- * @deprecated Use {@link #withStartedAt(Instant)}
- */
- @Deprecated
- public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
- return withStartedAt(GitHubClient.toInstantOrNull(startedAt));
- }
-
- /**
- * With started at.
- *
- * @param startedAt
- * the started at
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Instant startedAt) {
- if (startedAt != null) {
- requester.with("started_at", GitHubClient.printInstant(startedAt));
+ /**
+ * Instantiates a new annotation.
+ *
+ * @param path
+ * the path
+ * @param startLine
+ * the start line
+ * @param endLine
+ * the end line
+ * @param annotationLevel
+ * the annotation level
+ * @param message
+ * the message
+ */
+ public Annotation(@NonNull String path,
+ int startLine,
+ int endLine,
+ @NonNull GHCheckRun.AnnotationLevel annotationLevel,
+ @NonNull String message) {
+ this.path = path;
+ this.startLine = startLine;
+ this.endLine = endLine;
+ this.annotationLevel = annotationLevel.toString().toLowerCase(Locale.ROOT);
+ this.message = message;
}
- return this;
- }
- /**
- * With completed at.
- *
- * @param completedAt
- * the completed at
- * @return the GH check run builder
- * @deprecated Use {@link #withCompletedAt(Instant)}
- */
- @Deprecated
- public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
- return withCompletedAt(GitHubClient.toInstantOrNull(completedAt));
- }
+ /**
+ * With end column.
+ *
+ * @param endColumn
+ * the end column
+ * @return the annotation
+ */
+ public @NonNull Annotation withEndColumn(@CheckForNull Integer endColumn) {
+ this.endColumn = endColumn;
+ return this;
+ }
- /**
- * With completed at.
- *
- * @param completedAt
- * the completed at
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Instant completedAt) {
- if (completedAt != null) {
- requester.with("completed_at", GitHubClient.printInstant(completedAt));
+ /**
+ * With raw details.
+ *
+ * @param rawDetails
+ * the raw details
+ * @return the annotation
+ */
+ public @NonNull Annotation withRawDetails(@CheckForNull String rawDetails) {
+ this.rawDetails = rawDetails;
+ return this;
}
- return this;
- }
- /**
- * Adds the.
- *
- * @param output
- * the output
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder add(@NonNull Output output) {
- if (this.output != null) {
- throw new IllegalStateException("cannot add Output twice");
+ /**
+ * With start column.
+ *
+ * @param startColumn
+ * the start column
+ * @return the annotation
+ */
+ public @NonNull Annotation withStartColumn(@CheckForNull Integer startColumn) {
+ this.startColumn = startColumn;
+ return this;
}
- this.output = output;
- return this;
- }
- /**
- * Adds the.
- *
- * @param action
- * the action
- * @return the GH check run builder
- */
- public @NonNull GHCheckRunBuilder add(@NonNull Action action) {
- if (actions == null) {
- actions = new LinkedList<>();
+ /**
+ * With title.
+ *
+ * @param title
+ * the title
+ * @return the annotation
+ */
+ public @NonNull Annotation withTitle(@CheckForNull String title) {
+ this.title = title;
+ return this;
}
- actions.add(action);
- return this;
- }
- private static final int MAX_ANNOTATIONS = 50;
+ }
/**
- * Actually creates the check run. (If more than fifty annotations were requested, this is done in batches.)
+ * The Class Image.
*
- * @return the resulting run
- * @throws IOException
- * for the usual reasons
+ * @see documentation
*/
- public @NonNull GHCheckRun create() throws IOException {
- List extraAnnotations;
- if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
- extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
- output.annotations = output.annotations.subList(0, MAX_ANNOTATIONS);
- } else {
- extraAnnotations = Collections.emptyList();
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static final class Image {
+
+ private final String alt;
+ private String caption;
+ private final String imageUrl;
+
+ /**
+ * Instantiates a new image.
+ *
+ * @param alt
+ * the alt
+ * @param imageURL
+ * the image URL
+ */
+ public Image(@NonNull String alt, @NonNull String imageURL) {
+ this.alt = alt;
+ this.imageUrl = imageURL;
}
- GHCheckRun run = requester.with("output", output).with("actions", actions).fetch(GHCheckRun.class).wrap(repo);
- while (!extraAnnotations.isEmpty()) {
- Output output2 = new Output(output.title, output.summary).withText(output.text);
- int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
- output2.annotations = extraAnnotations.subList(0, i);
- extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());
- run = repo.root()
- .createRequest()
- .method("PATCH")
- .with("output", output2)
- .withUrlPath(repo.getApiTailUrl("check-runs/" + run.getId()))
- .fetch(GHCheckRun.class)
- .wrap(repo);
+
+ /**
+ * With caption.
+ *
+ * @param caption
+ * the caption
+ * @return the image
+ */
+ public @NonNull Image withCaption(@CheckForNull String caption) {
+ this.caption = caption;
+ return this;
}
- return run;
- }
+ }
/**
* The Class Output.
*
@@ -291,11 +238,11 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
@JsonInclude(JsonInclude.Include.NON_NULL)
public static final class Output {
- private final String title;
- private final String summary;
- private String text;
private List annotations;
private List images;
+ private final String summary;
+ private String text;
+ private final String title;
/**
* Instantiates a new output.
@@ -310,18 +257,6 @@ public Output(@NonNull String title, @NonNull String summary) {
this.summary = summary;
}
- /**
- * With text.
- *
- * @param text
- * the text
- * @return the output
- */
- public @NonNull Output withText(@CheckForNull String text) {
- this.text = text;
- return this;
- }
-
/**
* Adds the.
*
@@ -352,188 +287,253 @@ public Output(@NonNull String title, @NonNull String summary) {
return this;
}
+ /**
+ * With text.
+ *
+ * @param text
+ * the text
+ * @return the output
+ */
+ public @NonNull Output withText(@CheckForNull String text) {
+ this.text = text;
+ return this;
+ }
+
+ }
+
+ private static final int MAX_ANNOTATIONS = 50;
+
+ private List actions;
+
+ private Output output;
+
+ /** The repo. */
+ protected final GHRepository repo;
+
+ /** The requester. */
+ protected final Requester requester;
+
+ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
+ this.repo = repo;
+ this.requester = requester;
}
/**
- * The Class Annotation.
+ * Instantiates a new GH check run builder.
*
- * @see documentation
+ * @param repo
+ * the repo
+ * @param name
+ * the name
+ * @param headSHA
+ * the head SHA
*/
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static final class Annotation {
-
- private final String path;
- private final int startLine;
- private final int endLine;
- private final String annotationLevel;
- private final String message;
- private Integer startColumn;
- private Integer endColumn;
- private String title;
- private String rawDetails;
-
- /**
- * Instantiates a new annotation.
- *
- * @param path
- * the path
- * @param line
- * the line
- * @param annotationLevel
- * the annotation level
- * @param message
- * the message
- */
- public Annotation(@NonNull String path,
- int line,
- @NonNull GHCheckRun.AnnotationLevel annotationLevel,
- @NonNull String message) {
- this(path, line, line, annotationLevel, message);
- }
+ GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
+ this(repo,
+ repo.root()
+ .createRequest()
+ .method("POST")
+ .with("name", name)
+ .with("head_sha", headSHA)
+ .withUrlPath(repo.getApiTailUrl("check-runs")));
+ }
- /**
- * Instantiates a new annotation.
- *
- * @param path
- * the path
- * @param startLine
- * the start line
- * @param endLine
- * the end line
- * @param annotationLevel
- * the annotation level
- * @param message
- * the message
- */
- public Annotation(@NonNull String path,
- int startLine,
- int endLine,
- @NonNull GHCheckRun.AnnotationLevel annotationLevel,
- @NonNull String message) {
- this.path = path;
- this.startLine = startLine;
- this.endLine = endLine;
- this.annotationLevel = annotationLevel.toString().toLowerCase(Locale.ROOT);
- this.message = message;
- }
+ /**
+ * Instantiates a new GH check run builder.
+ *
+ * @param repo
+ * the repo
+ * @param checkId
+ * the check id
+ */
+ GHCheckRunBuilder(GHRepository repo, long checkId) {
+ this(repo,
+ repo.root().createRequest().method("PATCH").withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
+ }
- /**
- * With start column.
- *
- * @param startColumn
- * the start column
- * @return the annotation
- */
- public @NonNull Annotation withStartColumn(@CheckForNull Integer startColumn) {
- this.startColumn = startColumn;
- return this;
+ /**
+ * Adds the.
+ *
+ * @param action
+ * the action
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder add(@NonNull Action action) {
+ if (actions == null) {
+ actions = new LinkedList<>();
}
+ actions.add(action);
+ return this;
+ }
- /**
- * With end column.
- *
- * @param endColumn
- * the end column
- * @return the annotation
- */
- public @NonNull Annotation withEndColumn(@CheckForNull Integer endColumn) {
- this.endColumn = endColumn;
- return this;
+ /**
+ * Adds the.
+ *
+ * @param output
+ * the output
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder add(@NonNull Output output) {
+ if (this.output != null) {
+ throw new IllegalStateException("cannot add Output twice");
}
+ this.output = output;
+ return this;
+ }
- /**
- * With title.
- *
- * @param title
- * the title
- * @return the annotation
- */
- public @NonNull Annotation withTitle(@CheckForNull String title) {
- this.title = title;
- return this;
+ /**
+ * Actually creates the check run. (If more than fifty annotations were requested, this is done in batches.)
+ *
+ * @return the resulting run
+ * @throws IOException
+ * for the usual reasons
+ */
+ public @NonNull GHCheckRun create() throws IOException {
+ List extraAnnotations;
+ if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
+ extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
+ output.annotations = output.annotations.subList(0, MAX_ANNOTATIONS);
+ } else {
+ extraAnnotations = Collections.emptyList();
}
-
- /**
- * With raw details.
- *
- * @param rawDetails
- * the raw details
- * @return the annotation
- */
- public @NonNull Annotation withRawDetails(@CheckForNull String rawDetails) {
- this.rawDetails = rawDetails;
- return this;
+ GHCheckRun run = requester.with("output", output).with("actions", actions).fetch(GHCheckRun.class).wrap(repo);
+ while (!extraAnnotations.isEmpty()) {
+ Output output2 = new Output(output.title, output.summary).withText(output.text);
+ int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
+ output2.annotations = extraAnnotations.subList(0, i);
+ extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());
+ run = repo.root()
+ .createRequest()
+ .method("PATCH")
+ .with("output", output2)
+ .withUrlPath(repo.getApiTailUrl("check-runs/" + run.getId()))
+ .fetch(GHCheckRun.class)
+ .wrap(repo);
}
-
+ return run;
}
/**
- * The Class Image.
+ * With completed at.
*
- * @see documentation
+ * @param completedAt
+ * the completed at
+ * @return the GH check run builder
+ * @deprecated Use {@link #withCompletedAt(Instant)}
*/
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static final class Image {
-
- private final String alt;
- private final String imageUrl;
- private String caption;
+ @Deprecated
+ public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
+ return withCompletedAt(GitHubClient.toInstantOrNull(completedAt));
+ }
- /**
- * Instantiates a new image.
- *
- * @param alt
- * the alt
- * @param imageURL
- * the image URL
- */
- public Image(@NonNull String alt, @NonNull String imageURL) {
- this.alt = alt;
- this.imageUrl = imageURL;
+ /**
+ * With completed at.
+ *
+ * @param completedAt
+ * the completed at
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Instant completedAt) {
+ if (completedAt != null) {
+ requester.with("completed_at", GitHubClient.printInstant(completedAt));
}
+ return this;
+ }
- /**
- * With caption.
- *
- * @param caption
- * the caption
- * @return the image
- */
- public @NonNull Image withCaption(@CheckForNull String caption) {
- this.caption = caption;
- return this;
+ /**
+ * With conclusion.
+ *
+ * @param conclusion
+ * the conclusion
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withConclusion(@CheckForNull GHCheckRun.Conclusion conclusion) {
+ if (conclusion != null) {
+ requester.with("conclusion", conclusion.toString().toLowerCase(Locale.ROOT));
}
+ return this;
+ }
+ /**
+ * With details URL.
+ *
+ * @param detailsURL
+ * the details URL
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
+ requester.with("details_url", detailsURL);
+ return this;
+ }
+ /**
+ * With external ID.
+ *
+ * @param externalID
+ * the external ID
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withExternalID(@CheckForNull String externalID) {
+ requester.with("external_id", externalID);
+ return this;
}
/**
- * The Class Action.
+ * With name.
*
- * @see documentation
+ * @param name
+ * the name
+ * @param oldName
+ * the old name
+ * @return the GH check run builder
*/
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static final class Action {
+ public @NonNull GHCheckRunBuilder withName(@CheckForNull String name, String oldName) {
+ if (oldName == null) {
+ throw new GHException("Can not update uncreated check run");
+ }
+ requester.with("name", name);
+ return this;
+ }
- private final String label;
- private final String description;
- private final String identifier;
+ /**
+ * With started at.
+ *
+ * @param startedAt
+ * the started at
+ * @return the GH check run builder
+ * @deprecated Use {@link #withStartedAt(Instant)}
+ */
+ @Deprecated
+ public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
+ return withStartedAt(GitHubClient.toInstantOrNull(startedAt));
+ }
- /**
- * Instantiates a new action.
- *
- * @param label
- * the label
- * @param description
- * the description
- * @param identifier
- * the identifier
- */
- public Action(@NonNull String label, @NonNull String description, @NonNull String identifier) {
- this.label = label;
- this.description = description;
- this.identifier = identifier;
+ /**
+ * With started at.
+ *
+ * @param startedAt
+ * the started at
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Instant startedAt) {
+ if (startedAt != null) {
+ requester.with("started_at", GitHubClient.printInstant(startedAt));
}
+ return this;
+ }
+ /**
+ * With status.
+ *
+ * @param status
+ * the status
+ * @return the GH check run builder
+ */
+ public @NonNull GHCheckRunBuilder withStatus(@CheckForNull GHCheckRun.Status status) {
+ if (status != null) {
+ // Do *not* use the overload taking Enum, as that s/_/-/g which would be wrong here.
+ requester.with("status", status.toString().toLowerCase(Locale.ROOT));
+ }
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHCheckRunsPage.java b/src/main/java/org/kohsuke/github/GHCheckRunsPage.java
index 911a6be489..d0b5d012f2 100644
--- a/src/main/java/org/kohsuke/github/GHCheckRunsPage.java
+++ b/src/main/java/org/kohsuke/github/GHCheckRunsPage.java
@@ -9,8 +9,8 @@
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
class GHCheckRunsPage {
- private int totalCount;
private GHCheckRun[] checkRuns;
+ private int totalCount;
/**
* Gets the total count.
diff --git a/src/main/java/org/kohsuke/github/GHCheckSuite.java b/src/main/java/org/kohsuke/github/GHCheckSuite.java
index f6595fa031..0ada44e82b 100644
--- a/src/main/java/org/kohsuke/github/GHCheckSuite.java
+++ b/src/main/java/org/kohsuke/github/GHCheckSuite.java
@@ -23,103 +23,137 @@
public class GHCheckSuite extends GHObject {
/**
- * Create default GHCheckSuite instance
+ * The Class HeadCommit.
*/
- public GHCheckSuite() {
+ public static class HeadCommit extends GitHubBridgeAdapterObject {
+
+ private GitUser author;
+
+ private GitUser committer;
+ private String id;
+ private String message;
+ private String timestamp;
+ private String treeId;
+ /**
+ * Create default HeadCommit instance
+ */
+ public HeadCommit() {
+ }
+
+ /**
+ * Gets author.
+ *
+ * @return the author
+ */
+ public GitUser getAuthor() {
+ return author;
+ }
+
+ /**
+ * Gets committer.
+ *
+ * @return the committer
+ */
+ public GitUser getCommitter() {
+ return committer;
+ }
+
+ /**
+ * Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes.
+ *
+ * @return id of the commit
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Gets message.
+ *
+ * @return commit message.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Gets timestamp of the commit.
+ *
+ * @return timestamp of the commit
+ */
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getTimestamp() {
+ return GitHubClient.parseInstant(timestamp);
+ }
+
+ /**
+ * Gets id of the tree.
+ *
+ * @return id of the tree
+ */
+ public String getTreeId() {
+ return treeId;
+ }
}
- /** The owner. */
- @JsonProperty("repository")
- GHRepository owner;
+ private String after;
- private String nodeId;
- private String headBranch;
- private String headSha;
- private String status;
- private String conclusion;
+ private GHApp app;
private String before;
- private String after;
- private int latestCheckRunsCount;
private String checkRunsUrl;
+ private String conclusion;
+ private String headBranch;
private HeadCommit headCommit;
- private GHApp app;
+ private String headSha;
+ private int latestCheckRunsCount;
+ private String nodeId;
private GHPullRequest[] pullRequests;
+ private String status;
+ /** The owner. */
+ @JsonProperty("repository")
+ GHRepository owner;
/**
- * Wrap.
- *
- * @param owner
- * the owner
- * @return the GH check suite
- */
- GHCheckSuite wrap(GHRepository owner) {
- this.owner = owner;
- this.wrap(owner.root());
- return this;
- }
-
- /**
- * Wrap.
- *
- * @param root
- * the root
- * @return the GH check suite
- */
- GHCheckSuite wrap(GitHub root) {
- if (owner != null) {
- if (pullRequests != null && pullRequests.length != 0) {
- for (GHPullRequest singlePull : pullRequests) {
- singlePull.wrap(owner);
- }
- }
- }
- return this;
- }
-
- /**
- * Wrap.
- *
- * @return the GH pull request[]
+ * Create default GHCheckSuite instance
*/
- GHPullRequest[] wrap() {
- return pullRequests;
+ public GHCheckSuite() {
}
/**
- * Gets the global node id to access most objects in GitHub.
+ * The SHA of the most recent commit on ref after the push.
*
- * @return global node id
- * @see documentation
+ * @return sha of a commit
*/
- public String getNodeId() {
- return nodeId;
+ public String getAfter() {
+ return after;
}
/**
- * The head branch name the changes are on.
+ * Gets the GitHub app this check suite belongs to, included in response.
*
- * @return head branch name
+ * @return GitHub App
*/
- public String getHeadBranch() {
- return headBranch;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHApp getApp() {
+ return app;
}
/**
- * Gets the HEAD SHA.
+ * The SHA of the most recent commit on ref before the push.
*
- * @return sha for the HEAD commit
+ * @return sha of a commit
*/
- public String getHeadSha() {
- return headSha;
+ public String getBefore() {
+ return before;
}
/**
- * Gets status of the check suite. It can be one of request, in_progress, or completed.
+ * The url used to list all the check runs belonged to this suite.
*
- * @return status of the check suite
+ * @return url containing all check runs
*/
- public String getStatus() {
- return status;
+ public URL getCheckRunsUrl() {
+ return GitHubClient.parseURL(checkRunsUrl);
}
/**
@@ -134,58 +168,49 @@ public String getConclusion() {
}
/**
- * The SHA of the most recent commit on ref before the push.
- *
- * @return sha of a commit
- */
- public String getBefore() {
- return before;
- }
-
- /**
- * The SHA of the most recent commit on ref after the push.
+ * The head branch name the changes are on.
*
- * @return sha of a commit
+ * @return head branch name
*/
- public String getAfter() {
- return after;
+ public String getHeadBranch() {
+ return headBranch;
}
/**
- * The quantity of check runs that had run as part of the latest push.
+ * The commit of current head.
*
- * @return sha of the most recent commit
+ * @return head commit
*/
- public int getLatestCheckRunsCount() {
- return latestCheckRunsCount;
+ public HeadCommit getHeadCommit() {
+ return headCommit;
}
/**
- * The url used to list all the check runs belonged to this suite.
+ * Gets the HEAD SHA.
*
- * @return url containing all check runs
+ * @return sha for the HEAD commit
*/
- public URL getCheckRunsUrl() {
- return GitHubClient.parseURL(checkRunsUrl);
+ public String getHeadSha() {
+ return headSha;
}
/**
- * The commit of current head.
+ * The quantity of check runs that had run as part of the latest push.
*
- * @return head commit
+ * @return sha of the most recent commit
*/
- public HeadCommit getHeadCommit() {
- return headCommit;
+ public int getLatestCheckRunsCount() {
+ return latestCheckRunsCount;
}
/**
- * Gets the GitHub app this check suite belongs to, included in response.
+ * Gets the global node id to access most objects in GitHub.
*
- * @return GitHub App
+ * @return global node id
+ * @see documentation
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHApp getApp() {
- return app;
+ public String getNodeId() {
+ return nodeId;
}
/**
@@ -210,76 +235,51 @@ public List getPullRequests() throws IOException {
}
/**
- * The Class HeadCommit.
+ * Gets status of the check suite. It can be one of request, in_progress, or completed.
+ *
+ * @return status of the check suite
*/
- public static class HeadCommit extends GitHubBridgeAdapterObject {
-
- /**
- * Create default HeadCommit instance
- */
- public HeadCommit() {
- }
-
- private String id;
- private String treeId;
- private String message;
- private String timestamp;
- private GitUser author;
- private GitUser committer;
-
- /**
- * Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes.
- *
- * @return id of the commit
- */
- public String getId() {
- return id;
- }
-
- /**
- * Gets id of the tree.
- *
- * @return id of the tree
- */
- public String getTreeId() {
- return treeId;
- }
-
- /**
- * Gets message.
- *
- * @return commit message.
- */
- public String getMessage() {
- return message;
- }
+ public String getStatus() {
+ return status;
+ }
- /**
- * Gets timestamp of the commit.
- *
- * @return timestamp of the commit
- */
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getTimestamp() {
- return GitHubClient.parseInstant(timestamp);
- }
+ /**
+ * Wrap.
+ *
+ * @return the GH pull request[]
+ */
+ GHPullRequest[] wrap() {
+ return pullRequests;
+ }
- /**
- * Gets author.
- *
- * @return the author
- */
- public GitUser getAuthor() {
- return author;
- }
+ /**
+ * Wrap.
+ *
+ * @param owner
+ * the owner
+ * @return the GH check suite
+ */
+ GHCheckSuite wrap(GHRepository owner) {
+ this.owner = owner;
+ this.wrap(owner.root());
+ return this;
+ }
- /**
- * Gets committer.
- *
- * @return the committer
- */
- public GitUser getCommitter() {
- return committer;
+ /**
+ * Wrap.
+ *
+ * @param root
+ * the root
+ * @return the GH check suite
+ */
+ GHCheckSuite wrap(GitHub root) {
+ if (owner != null) {
+ if (pullRequests != null && pullRequests.length != 0) {
+ for (GHPullRequest singlePull : pullRequests) {
+ singlePull.wrap(owner);
+ }
+ }
}
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHCodeownersError.java b/src/main/java/org/kohsuke/github/GHCodeownersError.java
index 49654263b1..b090a1673b 100644
--- a/src/main/java/org/kohsuke/github/GHCodeownersError.java
+++ b/src/main/java/org/kohsuke/github/GHCodeownersError.java
@@ -9,23 +9,14 @@
*/
public class GHCodeownersError {
- /**
- * Create default GHCodeownersError instance
- */
- public GHCodeownersError() {
- }
+ private String kind, source, suggestion, message, path;
private int line, column;
- private String kind, source, suggestion, message, path;
-
/**
- * Gets line.
- *
- * @return the line
+ * Create default GHCodeownersError instance
*/
- public int getLine() {
- return line;
+ public GHCodeownersError() {
}
/**
@@ -47,21 +38,12 @@ public String getKind() {
}
/**
- * Gets source.
- *
- * @return the source
- */
- public String getSource() {
- return source;
- }
-
- /**
- * Gets suggestion.
+ * Gets line.
*
- * @return the suggestion
+ * @return the line
*/
- public String getSuggestion() {
- return suggestion;
+ public int getLine() {
+ return line;
}
/**
@@ -81,4 +63,22 @@ public String getMessage() {
public String getPath() {
return path;
}
+
+ /**
+ * Gets source.
+ *
+ * @return the source
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Gets suggestion.
+ *
+ * @return the suggestion
+ */
+ public String getSuggestion() {
+ return suggestion;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java
index 52ad989ee2..1edf0503d3 100644
--- a/src/main/java/org/kohsuke/github/GHCommit.java
+++ b/src/main/java/org/kohsuke/github/GHCommit.java
@@ -23,109 +23,61 @@
@SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
public class GHCommit {
- private GHRepository owner;
-
- private ShortInfo commit;
-
/**
- * Short summary of this commit.
+ * A file that was modified.
*/
- @SuppressFBWarnings(
- value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
- "UWF_UNWRITTEN_FIELD" },
- justification = "JSON API")
- public static class ShortInfo extends GitCommit {
+ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "It's being initialized by JSON deserialization")
+ public static class File {
- private int commentCount = -1;
+ /** The deletions. */
+ int changes, additions, deletions;
- /**
- * Gets comment count.
- *
- * @return the comment count
- * @throws GHException
- * the GH exception
- */
- public int getCommentCount() throws GHException {
- if (commentCount < 0) {
- throw new GHException("Not available on this endpoint.");
- }
- return commentCount;
- }
+ /** The previous filename. */
+ String filename, previousFilename;
- /**
- * Creates instance of {@link GHCommit.ShortInfo}.
- */
- public ShortInfo() {
- // Empty constructor required for Jackson binding
- };
+ /** The patch. */
+ String rawUrl, blobUrl, sha, patch;
+
+ /** The status. */
+ String status;
/**
- * Instantiates a new short info.
- *
- * @param commit
- * the commit
+ * Create default File instance
*/
- ShortInfo(GitCommit commit) {
- // Inherited copy constructor, used for bridge method from {@link GitCommit},
- // which is used in {@link GHContentUpdateResponse}) to {@link GHCommit}.
- super(commit);
+ public File() {
}
/**
- * Gets the parent SHA 1 s.
+ * Gets blob url.
*
- * @return the parent SHA 1 s
+ * @return URL like
+ * 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml'
+ * that resolves to the HTML page that describes this file.
*/
- @Override
- public List getParentSHA1s() {
- List shortInfoParents = super.getParentSHA1s();
- if (shortInfoParents == null) {
- throw new GHException("Not available on this endpoint. Try calling getParentSHA1s from outer class.");
- }
- return shortInfoParents;
+ public URL getBlobUrl() {
+ return GitHubClient.parseURL(blobUrl);
}
- }
-
- /**
- * The type Stats.
- */
- public static class Stats {
-
/**
- * Create default Stats instance
+ * Gets file name.
+ *
+ * @return Full path in the repository.
*/
- public Stats() {
+ @SuppressFBWarnings(value = "NM_CONFUSING",
+ justification = "It's a part of the library's API and cannot be renamed")
+ public String getFileName() {
+ return filename;
}
- /** The deletions. */
- int total, additions, deletions;
- }
-
- /**
- * A file that was modified.
- */
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "It's being initialized by JSON deserialization")
- public static class File {
-
/**
- * Create default File instance
+ * Gets lines added.
+ *
+ * @return Number of lines added.
*/
- public File() {
+ public int getLinesAdded() {
+ return additions;
}
- /** The status. */
- String status;
-
- /** The deletions. */
- int changes, additions, deletions;
-
- /** The patch. */
- String rawUrl, blobUrl, sha, patch;
-
- /** The previous filename. */
- String filename, previousFilename;
-
/**
* Gets lines changed.
*
@@ -135,15 +87,6 @@ public int getLinesChanged() {
return changes;
}
- /**
- * Gets lines added.
- *
- * @return Number of lines added.
- */
- public int getLinesAdded() {
- return additions;
- }
-
/**
* Gets lines deleted.
*
@@ -154,23 +97,12 @@ public int getLinesDeleted() {
}
/**
- * Gets status.
- *
- * @return "modified", "added", or "removed"
- */
- public String getStatus() {
- return status;
- }
-
- /**
- * Gets file name.
+ * Gets patch.
*
- * @return Full path in the repository.
+ * @return The actual change.
*/
- @SuppressFBWarnings(value = "NM_CONFUSING",
- justification = "It's a part of the library's API and cannot be renamed")
- public String getFileName() {
- return filename;
+ public String getPatch() {
+ return patch;
}
/**
@@ -182,15 +114,6 @@ public String getPreviousFilename() {
return previousFilename;
}
- /**
- * Gets patch.
- *
- * @return The actual change.
- */
- public String getPatch() {
- return patch;
- }
-
/**
* Gets raw url.
*
@@ -203,23 +126,21 @@ public URL getRawUrl() {
}
/**
- * Gets blob url.
+ * Gets sha.
*
- * @return URL like
- * 'https://github.com/jenkinsci/jenkins/blob/1182e2ebb1734d0653142bd422ad33c21437f7cf/core/pom.xml'
- * that resolves to the HTML page that describes this file.
+ * @return [0 -9a-f]{40} SHA1 checksum.
*/
- public URL getBlobUrl() {
- return GitHubClient.parseURL(blobUrl);
+ public String getSha() {
+ return sha;
}
/**
- * Gets sha.
+ * Gets status.
*
- * @return [0 -9a-f]{40} SHA1 checksum.
+ * @return "modified", "added", or "removed"
*/
- public String getSha() {
- return sha;
+ public String getStatus() {
+ return status;
}
}
@@ -228,18 +149,93 @@ public String getSha() {
*/
public static class Parent {
+ /** The sha. */
+ String sha;
+
+ /** The url. */
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
+ String url;
+
/**
* Create default Parent instance
*/
public Parent() {
}
+ }
- /** The url. */
- @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
- String url;
+ /**
+ * Short summary of this commit.
+ */
+ @SuppressFBWarnings(
+ value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
+ "UWF_UNWRITTEN_FIELD" },
+ justification = "JSON API")
+ public static class ShortInfo extends GitCommit {
+
+ private int commentCount = -1;
+
+ /**
+ * Creates instance of {@link GHCommit.ShortInfo}.
+ */
+ public ShortInfo() {
+ // Empty constructor required for Jackson binding
+ }
+
+ /**
+ * Instantiates a new short info.
+ *
+ * @param commit
+ * the commit
+ */
+ ShortInfo(GitCommit commit) {
+ // Inherited copy constructor, used for bridge method from {@link GitCommit},
+ // which is used in {@link GHContentUpdateResponse}) to {@link GHCommit}.
+ super(commit);
+ };
+
+ /**
+ * Gets comment count.
+ *
+ * @return the comment count
+ * @throws GHException
+ * the GH exception
+ */
+ public int getCommentCount() throws GHException {
+ if (commentCount < 0) {
+ throw new GHException("Not available on this endpoint.");
+ }
+ return commentCount;
+ }
+
+ /**
+ * Gets the parent SHA 1 s.
+ *
+ * @return the parent SHA 1 s
+ */
+ @Override
+ public List getParentSHA1s() {
+ List shortInfoParents = super.getParentSHA1s();
+ if (shortInfoParents == null) {
+ throw new GHException("Not available on this endpoint. Try calling getParentSHA1s from outer class.");
+ }
+ return shortInfoParents;
+ }
- /** The sha. */
- String sha;
+ }
+
+ /**
+ * The type Stats.
+ */
+ public static class Stats {
+
+ /** The deletions. */
+ int total, additions, deletions;
+
+ /**
+ * Create default Stats instance
+ */
+ public Stats() {
+ }
}
/**
@@ -247,33 +243,37 @@ public Parent() {
*/
static class User {
- /** The gravatar id. */
- // TODO: what if someone who doesn't have an account on GitHub makes a commit?
- @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
- String url, avatarUrl, gravatarId;
-
/** The id. */
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
int id;
/** The login. */
String login;
+
+ /** The gravatar id. */
+ // TODO: what if someone who doesn't have an account on GitHub makes a commit?
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
+ String url, avatarUrl, gravatarId;
}
- /** The sha. */
- String url, htmlUrl, sha, message;
+ private ShortInfo commit;
+
+ private GHRepository owner;
+
+ /** The committer. */
+ User author, committer;
/** The files. */
List files;
- /** The stats. */
- Stats stats;
-
/** The parents. */
List parents;
- /** The committer. */
- User author, committer;
+ /** The stats. */
+ Stats stats;
+
+ /** The sha. */
+ String url, htmlUrl, sha, message;
/**
* Creates an instance of {@link GHCommit}.
@@ -304,73 +304,119 @@ public GHCommit() {
}
/**
- * Gets commit short info.
+ * Create comment gh commit comment.
*
- * @return the commit short info
+ * @param body
+ * the body
+ * @return the gh commit comment
* @throws IOException
* the io exception
*/
- public ShortInfo getCommitShortInfo() throws IOException {
- if (commit == null)
- populate();
- return commit;
+ public GHCommitComment createComment(String body) throws IOException {
+ return createComment(body, null, null, null);
+ }
+
+ /**
+ * Creates a commit comment.
+ *
+ * I'm not sure how path/line/position parameters interact with each other.
+ *
+ * @param body
+ * body of the comment
+ * @param path
+ * path of file being commented on
+ * @param line
+ * target line for comment
+ * @param position
+ * position on line
+ * @return created GHCommitComment
+ * @throws IOException
+ * if comment is not created
+ */
+ public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
+ GHCommitComment r = owner.root()
+ .createRequest()
+ .method("POST")
+ .with("body", body)
+ .with("path", path)
+ .with("line", line)
+ .with("position", position)
+ .withUrlPath(
+ String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
+ .fetch(GHCommitComment.class);
+ return r.wrap(owner);
+ }
+
+ /**
+ * Gets author.
+ *
+ * @return the author
+ * @throws IOException
+ * the io exception
+ */
+ public GHUser getAuthor() throws IOException {
+ populate();
+ return resolveUser(author);
}
/**
- * Gets owner.
+ * Gets the date the change was authored on.
*
- * @return the repository that contains the commit.
+ * @return the date the change was authored on.
+ * @throws IOException
+ * if the information was not already fetched and an attempt at fetching the information failed.
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return owner;
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getAuthoredDate() throws IOException {
+ return getCommitShortInfo().getAuthoredDate();
}
/**
- * Gets lines changed.
+ * Gets check-runs for given sha.
*
- * @return the number of lines added + removed.
+ * @return check runs for given sha.
* @throws IOException
- * if the field was not populated and refresh fails
+ * on error
*/
- public int getLinesChanged() throws IOException {
- populate();
- return stats.total;
+ public PagedIterable getCheckRuns() throws IOException {
+ return owner.getCheckRuns(sha);
}
/**
- * Gets lines added.
+ * Gets the date the change was committed on.
*
- * @return Number of lines added.
+ * @return the date the change was committed on.
* @throws IOException
- * if the field was not populated and refresh fails
+ * if the information was not already fetched and an attempt at fetching the information failed.
*/
- public int getLinesAdded() throws IOException {
- populate();
- return stats.additions;
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCommitDate() throws IOException {
+ return getCommitShortInfo().getCommitDate();
}
/**
- * Gets lines deleted.
+ * Gets commit short info.
*
- * @return Number of lines removed.
+ * @return the commit short info
* @throws IOException
- * if the field was not populated and refresh fails
+ * the io exception
*/
- public int getLinesDeleted() throws IOException {
- populate();
- return stats.deletions;
+ public ShortInfo getCommitShortInfo() throws IOException {
+ if (commit == null)
+ populate();
+ return commit;
}
/**
- * Use this method to walk the tree.
+ * Gets committer.
*
- * @return a GHTree to walk
+ * @return the committer
* @throws IOException
- * on error
+ * the io exception
*/
- public GHTree getTree() throws IOException {
- return owner.getTree(getCommitShortInfo().getTreeSHA1());
+ public GHUser getCommitter() throws IOException {
+ populate();
+ return resolveUser(committer);
}
/**
@@ -384,38 +430,60 @@ public URL getHtmlUrl() {
}
/**
- * Gets sha 1.
+ * Gets last status.
*
- * @return [0 -9a-f]{40} SHA1 checksum.
+ * @return the last status of this commit, which is what gets shown in the UI.
+ * @throws IOException
+ * on error
*/
- public String getSHA1() {
- return sha;
+ public GHCommitStatus getLastStatus() throws IOException {
+ return owner.getLastCommitStatus(sha);
}
/**
- * Gets url.
+ * Gets lines added.
*
- * @return API URL of this object.
+ * @return Number of lines added.
+ * @throws IOException
+ * if the field was not populated and refresh fails
*/
- public URL getUrl() {
- return GitHubClient.parseURL(url);
+ public int getLinesAdded() throws IOException {
+ populate();
+ return stats.additions;
}
/**
- * List of files changed/added/removed in this commit. Uses a paginated list if the files returned by GitHub exceed
- * 300 in quantity.
+ * Gets lines changed.
*
- * @return the List of files
- * @see Get a
- * commit
+ * @return the number of lines added + removed.
* @throws IOException
- * on error
+ * if the field was not populated and refresh fails
*/
- public PagedIterable listFiles() throws IOException {
+ public int getLinesChanged() throws IOException {
+ populate();
+ return stats.total;
+ }
+ /**
+ * Gets lines deleted.
+ *
+ * @return Number of lines removed.
+ * @throws IOException
+ * if the field was not populated and refresh fails
+ */
+ public int getLinesDeleted() throws IOException {
populate();
+ return stats.deletions;
+ }
- return new GHCommitFileIterable(owner, sha, files);
+ /**
+ * Gets owner.
+ *
+ * @return the repository that contains the commit.
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return owner;
}
/**
@@ -455,69 +523,32 @@ public List getParents() throws IOException {
}
/**
- * Gets author.
- *
- * @return the author
- * @throws IOException
- * the io exception
- */
- public GHUser getAuthor() throws IOException {
- populate();
- return resolveUser(author);
- }
-
- /**
- * Gets the date the change was authored on.
- *
- * @return the date the change was authored on.
- * @throws IOException
- * if the information was not already fetched and an attempt at fetching the information failed.
- */
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getAuthoredDate() throws IOException {
- return getCommitShortInfo().getAuthoredDate();
- }
-
- /**
- * Gets committer.
+ * Gets sha 1.
*
- * @return the committer
- * @throws IOException
- * the io exception
+ * @return [0 -9a-f]{40} SHA1 checksum.
*/
- public GHUser getCommitter() throws IOException {
- populate();
- return resolveUser(committer);
+ public String getSHA1() {
+ return sha;
}
/**
- * Gets the date the change was committed on.
+ * Use this method to walk the tree.
*
- * @return the date the change was committed on.
+ * @return a GHTree to walk
* @throws IOException
- * if the information was not already fetched and an attempt at fetching the information failed.
+ * on error
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getCommitDate() throws IOException {
- return getCommitShortInfo().getCommitDate();
- }
-
- private GHUser resolveUser(User author) throws IOException {
- if (author == null || author.login == null)
- return null;
- return owner.root().getUser(author.login);
+ public GHTree getTree() throws IOException {
+ return owner.getTree(getCommitShortInfo().getTreeSHA1());
}
/**
- * Retrieves a list of pull requests which contain this commit.
+ * Gets url.
*
- * @return {@link PagedIterable} with the pull requests which contain this commit
+ * @return API URL of this object.
*/
- public PagedIterable listPullRequests() {
- return owner.root()
- .createRequest()
- .withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
- .toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
+ public URL getUrl() {
+ return GitHubClient.parseURL(url);
}
/**
@@ -545,47 +576,32 @@ public PagedIterable listComments() {
}
/**
- * Creates a commit comment.
- *
- * I'm not sure how path/line/position parameters interact with each other.
+ * List of files changed/added/removed in this commit. Uses a paginated list if the files returned by GitHub exceed
+ * 300 in quantity.
*
- * @param body
- * body of the comment
- * @param path
- * path of file being commented on
- * @param line
- * target line for comment
- * @param position
- * position on line
- * @return created GHCommitComment
+ * @return the List of files
+ * @see Get a
+ * commit
* @throws IOException
- * if comment is not created
+ * on error
*/
- public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
- GHCommitComment r = owner.root()
- .createRequest()
- .method("POST")
- .with("body", body)
- .with("path", path)
- .with("line", line)
- .with("position", position)
- .withUrlPath(
- String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
- .fetch(GHCommitComment.class);
- return r.wrap(owner);
+ public PagedIterable listFiles() throws IOException {
+
+ populate();
+
+ return new GHCommitFileIterable(owner, sha, files);
}
/**
- * Create comment gh commit comment.
+ * Retrieves a list of pull requests which contain this commit.
*
- * @param body
- * the body
- * @return the gh commit comment
- * @throws IOException
- * the io exception
+ * @return {@link PagedIterable} with the pull requests which contain this commit
*/
- public GHCommitComment createComment(String body) throws IOException {
- return createComment(body, null, null, null);
+ public PagedIterable listPullRequests() {
+ return owner.root()
+ .createRequest()
+ .withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
+ .toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
}
/**
@@ -599,26 +615,10 @@ public PagedIterable listStatuses() throws IOException {
return owner.listCommitStatuses(sha);
}
- /**
- * Gets last status.
- *
- * @return the last status of this commit, which is what gets shown in the UI.
- * @throws IOException
- * on error
- */
- public GHCommitStatus getLastStatus() throws IOException {
- return owner.getLastCommitStatus(sha);
- }
-
- /**
- * Gets check-runs for given sha.
- *
- * @return check runs for given sha.
- * @throws IOException
- * on error
- */
- public PagedIterable getCheckRuns() throws IOException {
- return owner.getCheckRuns(sha);
+ private GHUser resolveUser(User author) throws IOException {
+ if (author == null || author.login == null)
+ return null;
+ return owner.root().getUser(author.login);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCommitBuilder.java b/src/main/java/org/kohsuke/github/GHCommitBuilder.java
index 7dfb40e148..65f4c6d679 100644
--- a/src/main/java/org/kohsuke/github/GHCommitBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCommitBuilder.java
@@ -11,15 +11,10 @@
* Builder pattern for creating a new commit. Based on https://developer.github.com/v3/git/commits/#create-a-commit
*/
public class GHCommitBuilder {
- private final GHRepository repo;
- private final Requester req;
-
- private final List parents = new ArrayList();
-
private static final class UserInfo {
- private final String name;
- private final String email;
private final String date;
+ private final String email;
+ private final String name;
private UserInfo(String name, String email, Instant date) {
this.name = name;
@@ -27,6 +22,11 @@ private UserInfo(String name, String email, Instant date) {
this.date = GitHubClient.printInstant(date);
}
}
+ private final List parents = new ArrayList();
+
+ private final GHRepository repo;
+
+ private final Requester req;
/**
* Instantiates a new GH commit builder.
@@ -39,42 +39,6 @@ private UserInfo(String name, String email, Instant date) {
req = repo.root().createRequest().method("POST");
}
- /**
- * Message gh commit builder.
- *
- * @param message
- * the commit message
- * @return the gh commit builder
- */
- public GHCommitBuilder message(String message) {
- req.with("message", message);
- return this;
- }
-
- /**
- * Tree gh commit builder.
- *
- * @param tree
- * the SHA of the tree object this commit points to
- * @return the gh commit builder
- */
- public GHCommitBuilder tree(String tree) {
- req.with("tree", tree);
- return this;
- }
-
- /**
- * Parent gh commit builder.
- *
- * @param parent
- * the SHA of a parent commit.
- * @return the gh commit builder
- */
- public GHCommitBuilder parent(String parent) {
- parents.add(parent);
- return this;
- }
-
/**
* Configures the author of this commit.
*
@@ -108,19 +72,6 @@ public GHCommitBuilder author(String name, String email, Instant date) {
return this;
}
- /**
- * Configures the PGP signature of this commit.
- *
- * @param signature
- * the signature calculated from the commit
- *
- * @return the gh commit builder
- */
- public GHCommitBuilder withSignature(String signature) {
- req.with("signature", signature);
- return this;
- }
-
/**
* Configures the committer of this commit.
*
@@ -154,10 +105,6 @@ public GHCommitBuilder committer(String name, String email, Instant date) {
return this;
}
- private String getApiTail() {
- return String.format("/repos/%s/%s/git/commits", repo.getOwnerName(), repo.getName());
- }
-
/**
* Creates a blob based on the parameters specified thus far.
*
@@ -169,4 +116,57 @@ public GHCommit create() throws IOException {
req.with("parents", parents);
return req.method("POST").withUrlPath(getApiTail()).fetch(GHCommit.class).wrapUp(repo);
}
+
+ /**
+ * Message gh commit builder.
+ *
+ * @param message
+ * the commit message
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder message(String message) {
+ req.with("message", message);
+ return this;
+ }
+
+ /**
+ * Parent gh commit builder.
+ *
+ * @param parent
+ * the SHA of a parent commit.
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder parent(String parent) {
+ parents.add(parent);
+ return this;
+ }
+
+ /**
+ * Tree gh commit builder.
+ *
+ * @param tree
+ * the SHA of the tree object this commit points to
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder tree(String tree) {
+ req.with("tree", tree);
+ return this;
+ }
+
+ /**
+ * Configures the PGP signature of this commit.
+ *
+ * @param signature
+ * the signature calculated from the commit
+ *
+ * @return the gh commit builder
+ */
+ public GHCommitBuilder withSignature(String signature) {
+ req.with("signature", signature);
+ return this;
+ }
+
+ private String getApiTail() {
+ return String.format("/repos/%s/%s/git/commits", repo.getOwnerName(), repo.getName());
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitComment.java b/src/main/java/org/kohsuke/github/GHCommitComment.java
index 76bbdfa0da..b73a49666d 100644
--- a/src/main/java/org/kohsuke/github/GHCommitComment.java
+++ b/src/main/java/org/kohsuke/github/GHCommitComment.java
@@ -19,12 +19,6 @@
justification = "JSON API")
public class GHCommitComment extends GHObject implements Reactable {
- /**
- * Create default GHCommitComment instance
- */
- public GHCommitComment() {
- }
-
private GHRepository owner;
/** The commit id. */
@@ -40,33 +34,53 @@ public GHCommitComment() {
GHUser user; // not fully populated. beware.
/**
- * Gets owner.
+ * Create default GHCommitComment instance
+ */
+ public GHCommitComment() {
+ }
+
+ /**
+ * Creates the reaction.
*
- * @return the owner
+ * @param content
+ * the content
+ * @return the GH reaction
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return owner;
+ public GHReaction createReaction(ReactionContent content) throws IOException {
+ return owner.root()
+ .createRequest()
+ .method("POST")
+ .with("content", content.getContent())
+ .withUrlPath(getApiTail() + "/reactions")
+ .fetch(GHReaction.class);
}
/**
- * URL like
- * 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to
- * show this commit comment in a browser.
+ * Deletes this comment.
*
- * @return the html url
+ * @throws IOException
+ * the io exception
*/
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
+ public void delete() throws IOException {
+ owner.root().createRequest().method("DELETE").withUrlPath(getApiTail()).send();
}
/**
- * Gets sha 1.
+ * Delete reaction.
*
- * @return the sha 1
+ * @param reaction
+ * the reaction
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
*/
- public String getSHA1() {
- return commitId;
+ public void deleteReaction(GHReaction reaction) throws IOException {
+ owner.root()
+ .createRequest()
+ .method("DELETE")
+ .withUrlPath(getApiTail(), "reactions", String.valueOf(reaction.getId()))
+ .send();
}
/**
@@ -79,97 +93,75 @@ public String getBody() {
}
/**
- * A commit comment can be on a specific line of a specific file, if so, this field points to a file. Otherwise
- * null.
+ * Gets the commit to which this comment is associated with.
*
- * @return the path
+ * @return the commit
+ * @throws IOException
+ * the io exception
*/
- public String getPath() {
- return path;
+ public GHCommit getCommit() throws IOException {
+ return getOwner().getCommit(getSHA1());
}
/**
- * A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the
- * file. Otherwise -1.
+ * URL like
+ * 'https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000#commitcomment-1252827' to
+ * show this commit comment in a browser.
*
- * @return the line
+ * @return the html url
*/
- public int getLine() {
- return line != null ? line : -1;
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * Gets the user who put this comment.
+ * A commit comment can be on a specific line of a specific file, if so, this field points to the line number in the
+ * file. Otherwise -1.
*
- * @return the user
- * @throws IOException
- * the io exception
+ * @return the line
*/
- public GHUser getUser() throws IOException {
- return owner == null || owner.isOffline() ? user : owner.root().getUser(user.login);
+ public int getLine() {
+ return line != null ? line : -1;
}
/**
- * Gets the commit to which this comment is associated with.
+ * Gets owner.
*
- * @return the commit
- * @throws IOException
- * the io exception
+ * @return the owner
*/
- public GHCommit getCommit() throws IOException {
- return getOwner().getCommit(getSHA1());
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return owner;
}
/**
- * Updates the body of the commit message.
+ * A commit comment can be on a specific line of a specific file, if so, this field points to a file. Otherwise
+ * null.
*
- * @param body
- * the body
- * @throws IOException
- * the io exception
+ * @return the path
*/
- public void update(String body) throws IOException {
- owner.root()
- .createRequest()
- .method("PATCH")
- .with("body", body)
- .withUrlPath(getApiTail())
- .fetch(GHCommitComment.class);
- this.body = body;
+ public String getPath() {
+ return path;
}
/**
- * Creates the reaction.
+ * Gets sha 1.
*
- * @param content
- * the content
- * @return the GH reaction
- * @throws IOException
- * Signals that an I/O exception has occurred.
+ * @return the sha 1
*/
- public GHReaction createReaction(ReactionContent content) throws IOException {
- return owner.root()
- .createRequest()
- .method("POST")
- .with("content", content.getContent())
- .withUrlPath(getApiTail() + "/reactions")
- .fetch(GHReaction.class);
+ public String getSHA1() {
+ return commitId;
}
/**
- * Delete reaction.
+ * Gets the user who put this comment.
*
- * @param reaction
- * the reaction
+ * @return the user
* @throws IOException
- * Signals that an I/O exception has occurred.
+ * the io exception
*/
- public void deleteReaction(GHReaction reaction) throws IOException {
- owner.root()
- .createRequest()
- .method("DELETE")
- .withUrlPath(getApiTail(), "reactions", String.valueOf(reaction.getId()))
- .send();
+ public GHUser getUser() throws IOException {
+ return owner == null || owner.isOffline() ? user : owner.root().getUser(user.login);
}
/**
@@ -185,13 +177,21 @@ public PagedIterable listReactions() {
}
/**
- * Deletes this comment.
+ * Updates the body of the commit message.
*
+ * @param body
+ * the body
* @throws IOException
* the io exception
*/
- public void delete() throws IOException {
- owner.root().createRequest().method("DELETE").withUrlPath(getApiTail()).send();
+ public void update(String body) throws IOException {
+ owner.root()
+ .createRequest()
+ .method("PATCH")
+ .with("body", body)
+ .withUrlPath(getApiTail())
+ .fetch(GHCommitComment.class);
+ this.body = body;
}
private String getApiTail() {
diff --git a/src/main/java/org/kohsuke/github/GHCommitFileIterable.java b/src/main/java/org/kohsuke/github/GHCommitFileIterable.java
index 8a3f02a6fe..808f036017 100644
--- a/src/main/java/org/kohsuke/github/GHCommitFileIterable.java
+++ b/src/main/java/org/kohsuke/github/GHCommitFileIterable.java
@@ -21,9 +21,9 @@ class GHCommitFileIterable extends PagedIterable {
*/
private static final int GH_FILE_LIMIT_PER_COMMIT_PAGE = 300;
+ private final File[] files;
private final GHRepository owner;
private final String sha;
- private final File[] files;
/**
* Instantiates a new GH commit iterable.
diff --git a/src/main/java/org/kohsuke/github/GHCommitPointer.java b/src/main/java/org/kohsuke/github/GHCommitPointer.java
index a466239729..41cb15114c 100644
--- a/src/main/java/org/kohsuke/github/GHCommitPointer.java
+++ b/src/main/java/org/kohsuke/github/GHCommitPointer.java
@@ -35,36 +35,34 @@
*/
public class GHCommitPointer {
+ private String ref, sha, label;
+
+ private GHRepository repo;
+ private GHUser user;
/**
* Create default GHCommitPointer instance
*/
public GHCommitPointer() {
}
- private String ref, sha, label;
- private GHUser user;
- private GHRepository repo;
-
/**
- * This points to the user who owns the {@link #getRepository()}.
+ * Obtains the commit that this pointer is referring to.
*
- * @return the user
+ * @return the commit
+ * @throws IOException
+ * the io exception
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHUser getUser() {
- if (user != null)
- return user.root().intern(user);
- return user;
+ public GHCommit getCommit() throws IOException {
+ return getRepository().getCommit(getSha());
}
/**
- * The repository that contains the commit.
+ * String that looks like "USERNAME:REF".
*
- * @return the repository
+ * @return the label
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getRepository() {
- return repo;
+ public String getLabel() {
+ return label;
}
/**
@@ -77,32 +75,34 @@ public String getRef() {
}
/**
- * SHA1 of the commit.
+ * The repository that contains the commit.
*
- * @return the sha
+ * @return the repository
*/
- public String getSha() {
- return sha;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getRepository() {
+ return repo;
}
/**
- * String that looks like "USERNAME:REF".
+ * SHA1 of the commit.
*
- * @return the label
+ * @return the sha
*/
- public String getLabel() {
- return label;
+ public String getSha() {
+ return sha;
}
/**
- * Obtains the commit that this pointer is referring to.
+ * This points to the user who owns the {@link #getRepository()}.
*
- * @return the commit
- * @throws IOException
- * the io exception
+ * @return the user
*/
- public GHCommit getCommit() throws IOException {
- return getRepository().getCommit(getSha());
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHUser getUser() {
+ if (user != null)
+ return user.root().intern(user);
+ return user;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
index dd4738421d..8a03adb62f 100644
--- a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java
@@ -21,8 +21,8 @@
* @see GHRepository#queryCommits() GHRepository#queryCommits()
*/
public class GHCommitQueryBuilder {
- private final Requester req;
private final GHRepository repo;
+ private final Requester req;
/**
* Instantiates a new GH commit query builder.
@@ -47,18 +47,6 @@ public GHCommitQueryBuilder author(String author) {
return this;
}
- /**
- * Only commits containing this file path will be returned.
- *
- * @param path
- * the path
- * @return the gh commit query builder
- */
- public GHCommitQueryBuilder path(String path) {
- req.with("path", path);
- return this;
- }
-
/**
* Specifies the SHA1 commit / tag / branch / etc to start listing commits from.
*
@@ -71,6 +59,15 @@ public GHCommitQueryBuilder from(String ref) {
return this;
}
+ /**
+ * Lists up the commits with the criteria built so far.
+ *
+ * @return the paged iterable
+ */
+ public PagedIterable list() {
+ return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> item.wrapUp(repo));
+ }
+
/**
* Page size gh commit query builder.
*
@@ -83,6 +80,18 @@ public GHCommitQueryBuilder pageSize(int pageSize) {
return this;
}
+ /**
+ * Only commits containing this file path will be returned.
+ *
+ * @param path
+ * the path
+ * @return the gh commit query builder
+ */
+ public GHCommitQueryBuilder path(String path) {
+ req.with("path", path);
+ return this;
+ }
+
/**
* Only commits after this date will be returned.
*
@@ -154,13 +163,4 @@ public GHCommitQueryBuilder until(Instant dt) {
public GHCommitQueryBuilder until(long timestamp) {
return until(Instant.ofEpochMilli(timestamp));
}
-
- /**
- * Lists up the commits with the criteria built so far.
- *
- * @return the paged iterable
- */
- public PagedIterable list() {
- return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> item.wrapUp(repo));
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java
index 28e34d66b8..3a1ddbffce 100644
--- a/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCommitSearchBuilder.java
@@ -15,69 +15,80 @@
public class GHCommitSearchBuilder extends GHSearchBuilder {
/**
- * Instantiates a new GH commit search builder.
- *
- * @param root
- * the root
+ * The enum Sort.
*/
- GHCommitSearchBuilder(GitHub root) {
- super(root, CommitSearchResult.class);
+ public enum Sort {
+
+ /** The author date. */
+ AUTHOR_DATE,
+ /** The committer date. */
+ COMMITTER_DATE
}
- /**
- * Search terms.
- *
- * @param term
- * the term
- * @return the GH commit search builder
- */
- public GHCommitSearchBuilder q(String term) {
- super.q(term);
- return this;
+ @SuppressFBWarnings(
+ value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
+ justification = "JSON API")
+ private static class CommitSearchResult extends SearchResult {
+ private GHCommit[] items;
+
+ @Override
+ GHCommit[] getItems(GitHub root) {
+ for (GHCommit commit : items) {
+ String repoName = getRepoName(commit.url);
+ try {
+ GHRepository repo = root.getRepository(repoName);
+ commit.wrapUp(repo);
+ } catch (IOException ioe) {
+ }
+ }
+ return items;
+ }
}
/**
- * Author gh commit search builder.
- *
- * @param v
- * the v
- * @return the gh commit search builder
+ * @param commitUrl
+ * a commit URL
+ * @return the repo name ("username/reponame")
*/
- public GHCommitSearchBuilder author(String v) {
- return q("author:" + v);
+ private static String getRepoName(String commitUrl) {
+ if (StringUtils.isBlank(commitUrl)) {
+ return null;
+ }
+ int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
+ String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
+ return tokens[0] + '/' + tokens[1];
}
/**
- * Committer gh commit search builder.
+ * Instantiates a new GH commit search builder.
*
- * @param v
- * the v
- * @return the gh commit search builder
+ * @param root
+ * the root
*/
- public GHCommitSearchBuilder committer(String v) {
- return q("committer:" + v);
+ GHCommitSearchBuilder(GitHub root) {
+ super(root, CommitSearchResult.class);
}
/**
- * Author name gh commit search builder.
+ * Author gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder authorName(String v) {
- return q("author-name:" + v);
+ public GHCommitSearchBuilder author(String v) {
+ return q("author:" + v);
}
/**
- * Committer name gh commit search builder.
+ * Author date gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder committerName(String v) {
- return q("committer-name:" + v);
+ public GHCommitSearchBuilder authorDate(String v) {
+ return q("author-date:" + v);
}
/**
@@ -92,25 +103,25 @@ public GHCommitSearchBuilder authorEmail(String v) {
}
/**
- * Committer email gh commit search builder.
+ * Author name gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder committerEmail(String v) {
- return q("committer-email:" + v);
+ public GHCommitSearchBuilder authorName(String v) {
+ return q("author-name:" + v);
}
/**
- * Author date gh commit search builder.
+ * Committer gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder authorDate(String v) {
- return q("author-date:" + v);
+ public GHCommitSearchBuilder committer(String v) {
+ return q("committer:" + v);
}
/**
@@ -125,69 +136,70 @@ public GHCommitSearchBuilder committerDate(String v) {
}
/**
- * Merge gh commit search builder.
+ * Committer email gh commit search builder.
*
- * @param merge
- * the merge
+ * @param v
+ * the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder merge(boolean merge) {
- return q("merge:" + Boolean.valueOf(merge).toString().toLowerCase());
+ public GHCommitSearchBuilder committerEmail(String v) {
+ return q("committer-email:" + v);
}
/**
- * Hash gh commit search builder.
+ * Committer name gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder hash(String v) {
- return q("hash:" + v);
+ public GHCommitSearchBuilder committerName(String v) {
+ return q("committer-name:" + v);
}
/**
- * Parent gh commit search builder.
+ * Hash gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder parent(String v) {
- return q("parent:" + v);
+ public GHCommitSearchBuilder hash(String v) {
+ return q("hash:" + v);
}
/**
- * Tree gh commit search builder.
+ * Is gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder tree(String v) {
- return q("tree:" + v);
+ public GHCommitSearchBuilder is(String v) {
+ return q("is:" + v);
}
/**
- * Is gh commit search builder.
+ * Merge gh commit search builder.
*
- * @param v
- * the v
+ * @param merge
+ * the merge
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder is(String v) {
- return q("is:" + v);
+ public GHCommitSearchBuilder merge(boolean merge) {
+ return q("merge:" + Boolean.valueOf(merge).toString().toLowerCase());
}
/**
- * User gh commit search builder.
+ * Order gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder user(String v) {
- return q("user:" + v);
+ public GHCommitSearchBuilder order(GHDirection v) {
+ req.with("order", v);
+ return this;
}
/**
@@ -202,26 +214,37 @@ public GHCommitSearchBuilder org(String v) {
}
/**
- * Repo gh commit search builder.
+ * Parent gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder repo(String v) {
- return q("repo:" + v);
+ public GHCommitSearchBuilder parent(String v) {
+ return q("parent:" + v);
}
/**
- * Order gh commit search builder.
+ * Search terms.
+ *
+ * @param term
+ * the term
+ * @return the GH commit search builder
+ */
+ public GHCommitSearchBuilder q(String term) {
+ super.q(term);
+ return this;
+ }
+
+ /**
+ * Repo gh commit search builder.
*
* @param v
* the v
* @return the gh commit search builder
*/
- public GHCommitSearchBuilder order(GHDirection v) {
- req.with("order", v);
- return this;
+ public GHCommitSearchBuilder repo(String v) {
+ return q("repo:" + v);
}
/**
@@ -237,48 +260,25 @@ public GHCommitSearchBuilder sort(Sort sort) {
}
/**
- * The enum Sort.
+ * Tree gh commit search builder.
+ *
+ * @param v
+ * the v
+ * @return the gh commit search builder
*/
- public enum Sort {
-
- /** The author date. */
- AUTHOR_DATE,
- /** The committer date. */
- COMMITTER_DATE
- }
-
- @SuppressFBWarnings(
- value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
- justification = "JSON API")
- private static class CommitSearchResult extends SearchResult {
- private GHCommit[] items;
-
- @Override
- GHCommit[] getItems(GitHub root) {
- for (GHCommit commit : items) {
- String repoName = getRepoName(commit.url);
- try {
- GHRepository repo = root.getRepository(repoName);
- commit.wrapUp(repo);
- } catch (IOException ioe) {
- }
- }
- return items;
- }
+ public GHCommitSearchBuilder tree(String v) {
+ return q("tree:" + v);
}
/**
- * @param commitUrl
- * a commit URL
- * @return the repo name ("username/reponame")
+ * User gh commit search builder.
+ *
+ * @param v
+ * the v
+ * @return the gh commit search builder
*/
- private static String getRepoName(String commitUrl) {
- if (StringUtils.isBlank(commitUrl)) {
- return null;
- }
- int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
- String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
- return tokens[0] + '/' + tokens[1];
+ public GHCommitSearchBuilder user(String v) {
+ return q("user:" + v);
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHCommitState.java b/src/main/java/org/kohsuke/github/GHCommitState.java
index bdefc01446..7a89a3dc72 100644
--- a/src/main/java/org/kohsuke/github/GHCommitState.java
+++ b/src/main/java/org/kohsuke/github/GHCommitState.java
@@ -9,12 +9,12 @@
*/
public enum GHCommitState {
- /** The pending. */
- PENDING,
- /** The success. */
- SUCCESS,
/** The error. */
ERROR,
/** The failure. */
- FAILURE
+ FAILURE,
+ /** The pending. */
+ PENDING,
+ /** The success. */
+ SUCCESS
}
diff --git a/src/main/java/org/kohsuke/github/GHCommitStatus.java b/src/main/java/org/kohsuke/github/GHCommitStatus.java
index 04aaca2fd1..fe61d61ea7 100644
--- a/src/main/java/org/kohsuke/github/GHCommitStatus.java
+++ b/src/main/java/org/kohsuke/github/GHCommitStatus.java
@@ -12,11 +12,11 @@
*/
public class GHCommitStatus extends GHObject {
- /**
- * Create default GHCommitStatus instance
- */
- public GHCommitStatus() {
- }
+ /** The context. */
+ String context;
+
+ /** The creator. */
+ GHUser creator;
/** The state. */
String state;
@@ -24,34 +24,28 @@ public GHCommitStatus() {
/** The description. */
String targetUrl, description;
- /** The context. */
- String context;
-
- /** The creator. */
- GHUser creator;
+ /**
+ * Create default GHCommitStatus instance
+ */
+ public GHCommitStatus() {
+ }
/**
- * Gets state.
+ * Gets context.
*
- * @return the state
+ * @return the context
*/
- public GHCommitState getState() {
- for (GHCommitState s : GHCommitState.values()) {
- if (s.name().equalsIgnoreCase(state))
- return s;
- }
- throw new IllegalStateException("Unexpected state: " + state);
+ public String getContext() {
+ return context;
}
/**
- * The URL that this status is linked to.
- *
- * This is the URL specified when creating a commit status.
+ * Gets creator.
*
- * @return the target url
+ * @return the creator
*/
- public String getTargetUrl() {
- return targetUrl;
+ public GHUser getCreator() {
+ return root().intern(creator);
}
/**
@@ -64,21 +58,27 @@ public String getDescription() {
}
/**
- * Gets creator.
+ * Gets state.
*
- * @return the creator
+ * @return the state
*/
- public GHUser getCreator() {
- return root().intern(creator);
+ public GHCommitState getState() {
+ for (GHCommitState s : GHCommitState.values()) {
+ if (s.name().equalsIgnoreCase(state))
+ return s;
+ }
+ throw new IllegalStateException("Unexpected state: " + state);
}
/**
- * Gets context.
+ * The URL that this status is linked to.
+ *
+ * This is the URL specified when creating a commit status.
*
- * @return the context
+ * @return the target url
*/
- public String getContext() {
- return context;
+ public String getTargetUrl() {
+ return targetUrl;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHCompare.java b/src/main/java/org/kohsuke/github/GHCompare.java
index 53ffadac92..48340fda36 100644
--- a/src/main/java/org/kohsuke/github/GHCompare.java
+++ b/src/main/java/org/kohsuke/github/GHCompare.java
@@ -18,208 +18,6 @@
*/
public class GHCompare {
- /**
- * Create default GHCompare instance
- */
- public GHCompare() {
- }
-
- private String url, htmlUrl, permalinkUrl, diffUrl, patchUrl;
- private Status status;
- private int aheadBy, behindBy, totalCommits;
- private Commit baseCommit, mergeBaseCommit;
- private Commit[] commits;
- private GHCommit.File[] files;
-
- private GHRepository owner;
-
- @JacksonInject("GHCompare_usePaginatedCommits")
- private boolean usePaginatedCommits;
-
- /**
- * Gets url.
- *
- * @return the url
- */
- public URL getUrl() {
- return GitHubClient.parseURL(url);
- }
-
- /**
- * Gets html url.
- *
- * @return the html url
- */
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
- }
-
- /**
- * Gets permalink url.
- *
- * @return the permalink url
- */
- public URL getPermalinkUrl() {
- return GitHubClient.parseURL(permalinkUrl);
- }
-
- /**
- * Gets diff url.
- *
- * @return the diff url
- */
- public URL getDiffUrl() {
- return GitHubClient.parseURL(diffUrl);
- }
-
- /**
- * Gets patch url.
- *
- * @return the patch url
- */
- public URL getPatchUrl() {
- return GitHubClient.parseURL(patchUrl);
- }
-
- /**
- * Gets status.
- *
- * @return the status
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * Gets ahead by.
- *
- * @return the ahead by
- */
- public int getAheadBy() {
- return aheadBy;
- }
-
- /**
- * Gets behind by.
- *
- * @return the behind by
- */
- public int getBehindBy() {
- return behindBy;
- }
-
- /**
- * Gets total commits.
- *
- * @return the total commits
- */
- public int getTotalCommits() {
- return totalCommits;
- }
-
- /**
- * Gets base commit.
- *
- * @return the base commit
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public Commit getBaseCommit() {
- return baseCommit;
- }
-
- /**
- * Gets merge base commit.
- *
- * @return the merge base commit
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public Commit getMergeBaseCommit() {
- return mergeBaseCommit;
- }
-
- /**
- * Gets an array of commits.
- *
- * By default, the commit list is limited to 250 results.
- *
- * Since
- * 2021-03-22,
- * compare supports pagination of commits. This makes the initial {@link GHCompare} response return faster and
- * supports comparisons with more than 250 commits. To read commits progressively using pagination, set
- * {@link GHRepository#setCompareUsePaginatedCommits(boolean)} to true before calling
- * {@link GHRepository#getCompare(String, String)}.
- *
- * @return A copy of the array being stored in the class.
- */
- public Commit[] getCommits() {
- try {
- return listCommits().withPageSize(100).toArray();
- } catch (IOException e) {
- throw new GHException(e.getMessage(), e);
- }
- }
-
- /**
- * Iterable of commits for this comparison.
- *
- * By default, the commit list is limited to 250 results.
- *
- * Since
- * 2021-03-22,
- * compare supports pagination of commits. This makes the initial {@link GHCompare} response return faster and
- * supports comparisons with more than 250 commits. To read commits progressively using pagination, set
- * {@link GHRepository#setCompareUsePaginatedCommits(boolean)} to true before calling
- * {@link GHRepository#getCompare(String, String)}.
- *
- * @return iterable of commits
- */
- public PagedIterable listCommits() {
- if (usePaginatedCommits) {
- return new GHCompareCommitsIterable();
- } else {
- // if not using paginated commits, adapt the returned commits array
- return new PagedIterable() {
- @Nonnull
- @Override
- public PagedIterator _iterator(int pageSize) {
- return new PagedIterator<>(Collections.singleton(commits).iterator(), null);
- }
- };
- }
- }
-
- /**
- * Gets an array of files.
- *
- * By default, the file array is limited to 300 results. To retrieve the full list of files, iterate over each
- * commit returned by {@link GHCompare#listCommits} and use {@link GHCommit#listFiles} to get the files for each
- * commit.
- *
- * @return A copy of the array being stored in the class.
- */
- public GHCommit.File[] getFiles() {
- GHCommit.File[] newValue = new GHCommit.File[files.length];
- System.arraycopy(files, 0, newValue, 0, files.length);
- return newValue;
- }
-
- /**
- * Wrap gh compare.
- *
- * @param owner
- * the owner
- * @return the gh compare
- */
- GHCompare lateBind(GHRepository owner) {
- this.owner = owner;
- for (Commit commit : commits) {
- commit.wrapUp(owner);
- }
- mergeBaseCommit.wrapUp(owner);
- baseCommit.wrapUp(owner);
- return this;
- }
-
/**
* Compare commits had a child commit element with additional details we want to capture. This extension of GHCommit
* provides that.
@@ -228,14 +26,14 @@ GHCompare lateBind(GHRepository owner) {
justification = "JSON API")
public static class Commit extends GHCommit {
+ private InnerCommit commit;
+
/**
* Create default Commit instance
*/
public Commit() {
}
- private InnerCommit commit;
-
/**
* Gets commit.
*
@@ -251,32 +49,32 @@ public InnerCommit getCommit() {
*/
public static class InnerCommit {
+ private GitUser author, committer;
+
+ private Tree tree;
+ private String url, sha, message;
/**
* Create default InnerCommit instance
*/
public InnerCommit() {
}
- private String url, sha, message;
- private GitUser author, committer;
- private Tree tree;
-
/**
- * Gets url.
+ * Gets author.
*
- * @return the url
+ * @return the author
*/
- public String getUrl() {
- return url;
+ public GitUser getAuthor() {
+ return author;
}
/**
- * Gets sha.
+ * Gets committer.
*
- * @return the sha
+ * @return the committer
*/
- public String getSha() {
- return sha;
+ public GitUser getCommitter() {
+ return committer;
}
/**
@@ -289,53 +87,57 @@ public String getMessage() {
}
/**
- * Gets author.
+ * Gets sha.
*
- * @return the author
+ * @return the sha
*/
- public GitUser getAuthor() {
- return author;
+ public String getSha() {
+ return sha;
}
/**
- * Gets committer.
+ * Gets tree.
*
- * @return the committer
+ * @return the tree
*/
- public GitUser getCommitter() {
- return committer;
+ public Tree getTree() {
+ return tree;
}
/**
- * Gets tree.
+ * Gets url.
*
- * @return the tree
+ * @return the url
*/
- public Tree getTree() {
- return tree;
+ public String getUrl() {
+ return url;
}
}
+ /**
+ * The enum Status.
+ */
+ public static enum Status {
+ /** The ahead. */
+ ahead,
+ /** The behind. */
+ behind,
+ /** The diverged. */
+ diverged,
+ /** The identical. */
+ identical
+ }
/**
* The type Tree.
*/
public static class Tree {
- /**
- * Create default Tree instance
- */
- public Tree() {
- }
-
private String url, sha;
/**
- * Gets url.
- *
- * @return the url
+ * Create default Tree instance
*/
- public String getUrl() {
- return url;
+ public Tree() {
}
/**
@@ -346,23 +148,16 @@ public String getUrl() {
public String getSha() {
return sha;
}
- }
-
- /**
- * The enum Status.
- */
- public static enum Status {
- /** The behind. */
- behind,
- /** The ahead. */
- ahead,
- /** The identical. */
- identical,
- /** The diverged. */
- diverged
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
}
-
/**
* Iterable for commit listing.
*/
@@ -424,4 +219,209 @@ public Commit[] next() {
};
}
}
+ private int aheadBy, behindBy, totalCommits;
+ private Commit baseCommit, mergeBaseCommit;
+
+ private Commit[] commits;
+
+ private GHCommit.File[] files;
+
+ private GHRepository owner;
+
+ private Status status;
+
+ private String url, htmlUrl, permalinkUrl, diffUrl, patchUrl;
+
+ @JacksonInject("GHCompare_usePaginatedCommits")
+ private boolean usePaginatedCommits;
+
+ /**
+ * Create default GHCompare instance
+ */
+ public GHCompare() {
+ }
+
+ /**
+ * Gets ahead by.
+ *
+ * @return the ahead by
+ */
+ public int getAheadBy() {
+ return aheadBy;
+ }
+
+ /**
+ * Gets base commit.
+ *
+ * @return the base commit
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public Commit getBaseCommit() {
+ return baseCommit;
+ }
+
+ /**
+ * Gets behind by.
+ *
+ * @return the behind by
+ */
+ public int getBehindBy() {
+ return behindBy;
+ }
+
+ /**
+ * Gets an array of commits.
+ *
+ * By default, the commit list is limited to 250 results.
+ *
+ * Since
+ * 2021-03-22,
+ * compare supports pagination of commits. This makes the initial {@link GHCompare} response return faster and
+ * supports comparisons with more than 250 commits. To read commits progressively using pagination, set
+ * {@link GHRepository#setCompareUsePaginatedCommits(boolean)} to true before calling
+ * {@link GHRepository#getCompare(String, String)}.
+ *
+ * @return A copy of the array being stored in the class.
+ */
+ public Commit[] getCommits() {
+ try {
+ return listCommits().withPageSize(100).toArray();
+ } catch (IOException e) {
+ throw new GHException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Gets diff url.
+ *
+ * @return the diff url
+ */
+ public URL getDiffUrl() {
+ return GitHubClient.parseURL(diffUrl);
+ }
+
+ /**
+ * Gets an array of files.
+ *
+ * By default, the file array is limited to 300 results. To retrieve the full list of files, iterate over each
+ * commit returned by {@link GHCompare#listCommits} and use {@link GHCommit#listFiles} to get the files for each
+ * commit.
+ *
+ * @return A copy of the array being stored in the class.
+ */
+ public GHCommit.File[] getFiles() {
+ GHCommit.File[] newValue = new GHCommit.File[files.length];
+ System.arraycopy(files, 0, newValue, 0, files.length);
+ return newValue;
+ }
+
+ /**
+ * Gets html url.
+ *
+ * @return the html url
+ */
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
+ }
+
+ /**
+ * Gets merge base commit.
+ *
+ * @return the merge base commit
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public Commit getMergeBaseCommit() {
+ return mergeBaseCommit;
+ }
+
+ /**
+ * Gets patch url.
+ *
+ * @return the patch url
+ */
+ public URL getPatchUrl() {
+ return GitHubClient.parseURL(patchUrl);
+ }
+
+ /**
+ * Gets permalink url.
+ *
+ * @return the permalink url
+ */
+ public URL getPermalinkUrl() {
+ return GitHubClient.parseURL(permalinkUrl);
+ }
+
+ /**
+ * Gets status.
+ *
+ * @return the status
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * Gets total commits.
+ *
+ * @return the total commits
+ */
+ public int getTotalCommits() {
+ return totalCommits;
+ }
+
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public URL getUrl() {
+ return GitHubClient.parseURL(url);
+ }
+
+ /**
+ * Iterable of commits for this comparison.
+ *
+ * By default, the commit list is limited to 250 results.
+ *
+ * Since
+ * 2021-03-22,
+ * compare supports pagination of commits. This makes the initial {@link GHCompare} response return faster and
+ * supports comparisons with more than 250 commits. To read commits progressively using pagination, set
+ * {@link GHRepository#setCompareUsePaginatedCommits(boolean)} to true before calling
+ * {@link GHRepository#getCompare(String, String)}.
+ *
+ * @return iterable of commits
+ */
+ public PagedIterable listCommits() {
+ if (usePaginatedCommits) {
+ return new GHCompareCommitsIterable();
+ } else {
+ // if not using paginated commits, adapt the returned commits array
+ return new PagedIterable() {
+ @Nonnull
+ @Override
+ public PagedIterator _iterator(int pageSize) {
+ return new PagedIterator<>(Collections.singleton(commits).iterator(), null);
+ }
+ };
+ }
+ }
+
+ /**
+ * Wrap gh compare.
+ *
+ * @param owner
+ * the owner
+ * @return the gh compare
+ */
+ GHCompare lateBind(GHRepository owner) {
+ this.owner = owner;
+ for (Commit commit : commits) {
+ commit.wrapUp(owner);
+ }
+ mergeBaseCommit.wrapUp(owner);
+ baseCommit.wrapUp(owner);
+ return this;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHContent.java b/src/main/java/org/kohsuke/github/GHContent.java
index 75e59c11cd..d6d9549b01 100644
--- a/src/main/java/org/kohsuke/github/GHContent.java
+++ b/src/main/java/org/kohsuke/github/GHContent.java
@@ -19,101 +19,83 @@
public class GHContent extends GitHubInteractiveObject implements Refreshable {
/**
- * Create default GHContent instance
+ * Gets the api route.
+ *
+ * @param repository
+ * the repository
+ * @param path
+ * the path
+ * @return the api route
*/
- public GHContent() {
+ static String getApiRoute(GHRepository repository, String path) {
+ return repository.getApiTailUrl("contents/" + path);
}
+ private String content;
+
+ private String downloadUrl;
+ private String encoding;
+ private String gitUrl; // this is the Blob url
+ private String htmlUrl; // this is the UI
+ private String name;
+ private String path;
/*
* In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested
* 'repository' field that gets populated from JSON.
*/
private GHRepository repository;
-
- private String type;
- private String encoding;
- private long size;
private String sha;
- private String name;
- private String path;
+ private long size;
private String target;
- private String content;
+ private String type;
private String url; // this is the API url
- private String gitUrl; // this is the Blob url
- private String htmlUrl; // this is the UI
- private String downloadUrl;
/**
- * Gets owner.
- *
- * @return the owner
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getOwner() {
- return repository;
- }
-
- /**
- * Gets type.
- *
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * Gets encoding.
- *
- * @return the encoding
+ * Create default GHContent instance
*/
- public String getEncoding() {
- return encoding;
+ public GHContent() {
}
/**
- * Gets size.
+ * Delete gh content update response.
*
- * @return the size
+ * @param message
+ * the message
+ * @return the gh content update response
+ * @throws IOException
+ * the io exception
*/
- public long getSize() {
- return size;
+ public GHContentUpdateResponse delete(String message) throws IOException {
+ return delete(message, null);
}
/**
- * Gets sha.
+ * Delete gh content update response.
*
- * @return the sha
+ * @param commitMessage
+ * the commit message
+ * @param branch
+ * the branch
+ * @return the gh content update response
+ * @throws IOException
+ * the io exception
*/
- public String getSha() {
- return sha;
- }
+ public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
+ Requester requester = root().createRequest()
+ .method("DELETE")
+ .with("path", path)
+ .with("message", commitMessage)
+ .with("sha", sha);
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ if (branch != null) {
+ requester.with("branch", branch);
+ }
- /**
- * Gets path.
- *
- * @return the path
- */
- public String getPath() {
- return path;
- }
+ GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
+ .fetch(GHContentUpdateResponse.class);
- /**
- * Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
- *
- * @return the target
- */
- public String getTarget() {
- return target;
+ response.getCommit().wrapUp(repository);
+ return response;
}
/**
@@ -134,6 +116,18 @@ public String getContent() throws IOException {
return new String(readDecodedContent());
}
+ /**
+ * URL to retrieve the raw content of the file. Null if this is a directory.
+ *
+ * @return the download url
+ * @throws IOException
+ * the io exception
+ */
+ public String getDownloadUrl() throws IOException {
+ refresh(downloadUrl);
+ return downloadUrl;
+ }
+
/**
* Retrieve the base64-encoded content that is stored at this location.
*
@@ -153,12 +147,12 @@ public String getEncodedContent() throws IOException {
}
/**
- * Gets url.
+ * Gets encoding.
*
- * @return the url
+ * @return the encoding
*/
- public String getUrl() {
- return url;
+ public String getEncoding() {
+ return encoding;
}
/**
@@ -180,56 +174,76 @@ public String getHtmlUrl() {
}
/**
- * Retrieves the actual bytes of the blob.
+ * Gets name.
*
- * @return the input stream
- * @throws IOException
- * the io exception
+ * @return the name
*/
- public InputStream read() throws IOException {
- return new ByteArrayInputStream(readDecodedContent());
+ public String getName() {
+ return name;
}
/**
- * Retrieves the decoded bytes of the blob.
+ * Gets owner.
*
- * @return the input stream
- * @throws IOException
- * the io exception
+ * @return the owner
*/
- private byte[] readDecodedContent() throws IOException {
- String encodedContent = getEncodedContent();
- if (encoding.equals("base64")) {
- try {
- Base64.Decoder decoder = Base64.getMimeDecoder();
- return decoder.decode(encodedContent.getBytes(StandardCharsets.US_ASCII));
- } catch (IllegalArgumentException e) {
- throw new AssertionError(e); // US-ASCII is mandatory
- }
- }
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getOwner() {
+ return repository;
+ }
- throw new UnsupportedOperationException("Unrecognized encoding: " + encoding);
+ /**
+ * Gets path.
+ *
+ * @return the path
+ */
+ public String getPath() {
+ return path;
}
/**
- * URL to retrieve the raw content of the file. Null if this is a directory.
+ * Gets sha.
*
- * @return the download url
- * @throws IOException
- * the io exception
+ * @return the sha
*/
- public String getDownloadUrl() throws IOException {
- refresh(downloadUrl);
- return downloadUrl;
+ public String getSha() {
+ return sha;
}
/**
- * Is file boolean.
+ * Gets size.
*
- * @return the boolean
+ * @return the size
*/
- public boolean isFile() {
- return "file".equals(type);
+ public long getSize() {
+ return size;
+ }
+
+ /**
+ * Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
+ *
+ * @return the target
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * Gets type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
}
/**
@@ -242,15 +256,12 @@ public boolean isDirectory() {
}
/**
- * Fully populate the data by retrieving missing data.
- *
- * Depending on the original API call where this object is created, it may not contain everything.
+ * Is file boolean.
*
- * @throws IOException
- * the io exception
+ * @return the boolean
*/
- protected synchronized void populate() throws IOException {
- root().createRequest().withUrlPath(url).fetchInto(this);
+ public boolean isFile() {
+ return "file".equals(type);
}
/**
@@ -265,6 +276,30 @@ public PagedIterable listDirectoryContent() {
return root().createRequest().setRawUrlPath(url).toIterable(GHContent[].class, item -> item.wrap(repository));
}
+ /**
+ * Retrieves the actual bytes of the blob.
+ *
+ * @return the input stream
+ * @throws IOException
+ * the io exception
+ */
+ public InputStream read() throws IOException {
+ return new ByteArrayInputStream(readDecodedContent());
+ }
+
+ /**
+ * Fully populate the data by retrieving missing data.
+ *
+ * Depending on the original API call where this object is created, it may not contain everything.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ @Override
+ public synchronized void refresh() throws IOException {
+ root().createRequest().setRawUrlPath(url).fetchInto(this);
+ }
+
/**
* Update gh content update response.
*
@@ -353,58 +388,36 @@ public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessa
}
/**
- * Delete gh content update response.
- *
- * @param message
- * the message
- * @return the gh content update response
- * @throws IOException
- * the io exception
- */
- public GHContentUpdateResponse delete(String message) throws IOException {
- return delete(message, null);
- }
-
- /**
- * Delete gh content update response.
+ * Retrieves the decoded bytes of the blob.
*
- * @param commitMessage
- * the commit message
- * @param branch
- * the branch
- * @return the gh content update response
+ * @return the input stream
* @throws IOException
* the io exception
*/
- public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
- Requester requester = root().createRequest()
- .method("DELETE")
- .with("path", path)
- .with("message", commitMessage)
- .with("sha", sha);
-
- if (branch != null) {
- requester.with("branch", branch);
+ private byte[] readDecodedContent() throws IOException {
+ String encodedContent = getEncodedContent();
+ if (encoding.equals("base64")) {
+ try {
+ Base64.Decoder decoder = Base64.getMimeDecoder();
+ return decoder.decode(encodedContent.getBytes(StandardCharsets.US_ASCII));
+ } catch (IllegalArgumentException e) {
+ throw new AssertionError(e); // US-ASCII is mandatory
+ }
}
- GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
- .fetch(GHContentUpdateResponse.class);
-
- response.getCommit().wrapUp(repository);
- return response;
+ throw new UnsupportedOperationException("Unrecognized encoding: " + encoding);
}
/**
- * Gets the api route.
+ * Fully populate the data by retrieving missing data.
+ *
+ * Depending on the original API call where this object is created, it may not contain everything.
*
- * @param repository
- * the repository
- * @param path
- * the path
- * @return the api route
+ * @throws IOException
+ * the io exception
*/
- static String getApiRoute(GHRepository repository, String path) {
- return repository.getApiTailUrl("contents/" + path);
+ protected synchronized void populate() throws IOException {
+ root().createRequest().withUrlPath(url).fetchInto(this);
}
/**
@@ -418,17 +431,4 @@ GHContent wrap(GHRepository owner) {
this.repository = owner;
return this;
}
-
- /**
- * Fully populate the data by retrieving missing data.
- *
- * Depending on the original API call where this object is created, it may not contain everything.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- @Override
- public synchronized void refresh() throws IOException {
- root().createRequest().setRawUrlPath(url).fetchInto(this);
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHContentBuilder.java b/src/main/java/org/kohsuke/github/GHContentBuilder.java
index 9b24af92b0..11a77ab1b8 100644
--- a/src/main/java/org/kohsuke/github/GHContentBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHContentBuilder.java
@@ -15,9 +15,9 @@
* @see GHRepository#createContent() GHRepository#createContent()
*/
public final class GHContentBuilder {
+ private String path;
private final GHRepository repo;
private final Requester req;
- private String path;
/**
* Instantiates a new GH content builder.
@@ -30,19 +30,6 @@ public final class GHContentBuilder {
this.req = repo.root().createRequest().method("PUT");
}
- /**
- * Path gh content builder.
- *
- * @param path
- * the path
- * @return the gh content builder
- */
- public GHContentBuilder path(String path) {
- this.path = path;
- req.with("path", path);
- return this;
- }
-
/**
* Branch gh content builder.
*
@@ -56,15 +43,20 @@ public GHContentBuilder branch(String branch) {
}
/**
- * Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
+ * Commits a new content.
*
- * @param sha
- * the sha
- * @return the gh content builder
+ * @return the gh content update response
+ * @throws IOException
+ * the io exception
*/
- public GHContentBuilder sha(String sha) {
- req.with("sha", sha);
- return this;
+ public GHContentUpdateResponse commit() throws IOException {
+ GHContentUpdateResponse response = req.withUrlPath(GHContent.getApiRoute(repo, path))
+ .fetch(GHContentUpdateResponse.class);
+
+ response.getContent().wrap(repo);
+ response.getCommit().wrapUp(repo);
+
+ return response;
}
/**
@@ -74,9 +66,8 @@ public GHContentBuilder sha(String sha) {
* the content
* @return the gh content builder
*/
- public GHContentBuilder content(byte[] content) {
- req.with("content", Base64.getEncoder().encodeToString(content));
- return this;
+ public GHContentBuilder content(String content) {
+ return content(content.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -86,8 +77,9 @@ public GHContentBuilder content(byte[] content) {
* the content
* @return the gh content builder
*/
- public GHContentBuilder content(String content) {
- return content(content.getBytes(StandardCharsets.UTF_8));
+ public GHContentBuilder content(byte[] content) {
+ req.with("content", Base64.getEncoder().encodeToString(content));
+ return this;
}
/**
@@ -103,19 +95,27 @@ public GHContentBuilder message(String commitMessage) {
}
/**
- * Commits a new content.
+ * Path gh content builder.
*
- * @return the gh content update response
- * @throws IOException
- * the io exception
+ * @param path
+ * the path
+ * @return the gh content builder
*/
- public GHContentUpdateResponse commit() throws IOException {
- GHContentUpdateResponse response = req.withUrlPath(GHContent.getApiRoute(repo, path))
- .fetch(GHContentUpdateResponse.class);
-
- response.getContent().wrap(repo);
- response.getCommit().wrapUp(repo);
+ public GHContentBuilder path(String path) {
+ this.path = path;
+ req.with("path", path);
+ return this;
+ }
- return response;
+ /**
+ * Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
+ *
+ * @param sha
+ * the sha
+ * @return the gh content builder
+ */
+ public GHContentBuilder sha(String sha) {
+ req.with("sha", sha);
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java b/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java
index e29449e6bb..bdd16cea3e 100644
--- a/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHContentSearchBuilder.java
@@ -10,53 +10,55 @@
public class GHContentSearchBuilder extends GHSearchBuilder {
/**
- * Instantiates a new GH content search builder.
- *
- * @param root
- * the root
+ * The enum Sort.
*/
- GHContentSearchBuilder(GitHub root) {
- super(root, ContentSearchResult.class);
+ public enum Sort {
+
+ /** The best match. */
+ BEST_MATCH,
+ /** The indexed. */
+ INDEXED
}
- /**
- * {@inheritDoc}
- */
- @Override
- public GHContentSearchBuilder q(String term) {
- super.q(term);
- return this;
+ private static class ContentSearchResult extends SearchResult {
+ private GHContent[] items;
+
+ @Override
+ GHContent[] getItems(GitHub root) {
+ return items;
+ }
}
/**
- * {@inheritDoc}
+ * Instantiates a new GH content search builder.
+ *
+ * @param root
+ * the root
*/
- @Override
- GHContentSearchBuilder q(String qualifier, String value) {
- super.q(qualifier, value);
- return this;
+ GHContentSearchBuilder(GitHub root) {
+ super(root, ContentSearchResult.class);
}
/**
- * In gh content search builder.
+ * Extension gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder in(String v) {
- return q("in:" + v);
+ public GHContentSearchBuilder extension(String v) {
+ return q("extension:" + v);
}
/**
- * Language gh content search builder.
+ * Filename gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder language(String v) {
- return q("language:" + v);
+ public GHContentSearchBuilder filename(String v) {
+ return q("filename:" + v);
}
/**
@@ -76,58 +78,57 @@ public GHContentSearchBuilder fork(GHFork fork) {
}
/**
- * Size gh content search builder.
+ * In gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder size(String v) {
- return q("size:" + v);
+ public GHContentSearchBuilder in(String v) {
+ return q("in:" + v);
}
/**
- * Path gh content search builder.
+ * Language gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder path(String v) {
- return q("path:" + v);
+ public GHContentSearchBuilder language(String v) {
+ return q("language:" + v);
}
/**
- * Filename gh content search builder.
+ * Order gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder filename(String v) {
- return q("filename:" + v);
+ public GHContentSearchBuilder order(GHDirection v) {
+ req.with("order", v);
+ return this;
}
/**
- * Extension gh content search builder.
+ * Path gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder extension(String v) {
- return q("extension:" + v);
+ public GHContentSearchBuilder path(String v) {
+ return q("path:" + v);
}
/**
- * User gh content search builder.
- *
- * @param v
- * the v
- * @return the gh content search builder
+ * {@inheritDoc}
*/
- public GHContentSearchBuilder user(String v) {
- return q("user:" + v);
+ @Override
+ public GHContentSearchBuilder q(String term) {
+ super.q(term);
+ return this;
}
/**
@@ -142,15 +143,14 @@ public GHContentSearchBuilder repo(String v) {
}
/**
- * Order gh content search builder.
+ * Size gh content search builder.
*
* @param v
* the v
* @return the gh content search builder
*/
- public GHContentSearchBuilder order(GHDirection v) {
- req.with("order", v);
- return this;
+ public GHContentSearchBuilder size(String v) {
+ return q("size:" + v);
}
/**
@@ -170,23 +170,14 @@ public GHContentSearchBuilder sort(GHContentSearchBuilder.Sort sort) {
}
/**
- * The enum Sort.
+ * User gh content search builder.
+ *
+ * @param v
+ * the v
+ * @return the gh content search builder
*/
- public enum Sort {
-
- /** The best match. */
- BEST_MATCH,
- /** The indexed. */
- INDEXED
- }
-
- private static class ContentSearchResult extends SearchResult {
- private GHContent[] items;
-
- @Override
- GHContent[] getItems(GitHub root) {
- return items;
- }
+ public GHContentSearchBuilder user(String v) {
+ return q("user:" + v);
}
/**
@@ -198,4 +189,13 @@ GHContent[] getItems(GitHub root) {
protected String getApiUrl() {
return "/search/code";
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ GHContentSearchBuilder q(String qualifier, String value) {
+ super.q(qualifier, value);
+ return this;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java b/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java
index 3703023140..193ed2bd1f 100644
--- a/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java
+++ b/src/main/java/org/kohsuke/github/GHContentUpdateResponse.java
@@ -8,33 +8,33 @@
*/
public class GHContentUpdateResponse {
+ private GitCommit commit;
+
+ private GHContent content;
/**
* Create default GHContentUpdateResponse instance
*/
public GHContentUpdateResponse() {
}
- private GHContent content;
- private GitCommit commit;
-
/**
- * Gets content.
+ * Gets commit.
*
- * @return the content
+ * @return the commit
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHContent getContent() {
- return content;
+ public GitCommit getCommit() {
+ return commit;
}
/**
- * Gets commit.
+ * Gets content.
*
- * @return the commit
+ * @return the content
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GitCommit getCommit() {
- return commit;
+ public GHContent getContent() {
+ return content;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java b/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java
index 15bceb2ebd..9a787a1cb9 100644
--- a/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHCreateRepositoryBuilder.java
@@ -32,32 +32,6 @@ public GHCreateRepositoryBuilder(String name, GitHub root, String apiTail) {
}
}
- /**
- * Creates a default .gitignore
- *
- * @param language
- * template to base the ignore file on
- * @return a builder to continue with building See https://developer.github.com/v3/repos/#create
- * @throws IOException
- * In case of any networking error or error from the server.
- */
- public GHCreateRepositoryBuilder gitignoreTemplate(String language) throws IOException {
- return with("gitignore_template", language);
- }
-
- /**
- * Desired license template to apply.
- *
- * @param license
- * template to base the license file on
- * @return a builder to continue with building See https://developer.github.com/v3/repos/#create
- * @throws IOException
- * In case of any networking error or error from the server.
- */
- public GHCreateRepositoryBuilder licenseTemplate(String license) throws IOException {
- return with("license_template", license);
- }
-
/**
* If true, create an initial commit with empty README.
*
@@ -72,31 +46,29 @@ public GHCreateRepositoryBuilder autoInit(boolean enabled) throws IOException {
}
/**
- * The team that gets granted access to this repository. Only valid for creating a repository in an organization.
+ * Creates a repository with all the parameters.
*
- * @param team
- * team to grant access to
- * @return a builder to continue with building
+ * @return the gh repository
* @throws IOException
- * In case of any networking error or error from the server.
+ * if repository cannot be created
*/
- public GHCreateRepositoryBuilder team(GHTeam team) throws IOException {
- if (team != null)
- return with("team_id", team.getId());
- return this;
+ public GHRepository create() throws IOException {
+ return done();
}
/**
- * Specifies the ownership of the repository.
+ * Create repository from template repository.
*
- * @param owner
- * organization or personage
+ * @param templateRepository
+ * the template repository as a GHRepository
* @return a builder to continue with building
- * @throws IOException
- * In case of any networking error or error from the server.
*/
- public GHCreateRepositoryBuilder owner(String owner) throws IOException {
- return with("owner", owner);
+ public GHCreateRepositoryBuilder fromTemplateRepository(GHRepository templateRepository) {
+ Objects.requireNonNull(templateRepository, "templateRepository cannot be null");
+ if (!templateRepository.isTemplate()) {
+ throw new IllegalArgumentException("The provided repository is not a template repository.");
+ }
+ return fromTemplateRepository(templateRepository.getOwnerName(), templateRepository.getName());
}
/**
@@ -114,28 +86,56 @@ public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, St
}
/**
- * Create repository from template repository.
+ * Creates a default .gitignore
*
- * @param templateRepository
- * the template repository as a GHRepository
+ * @param language
+ * template to base the ignore file on
+ * @return a builder to continue with building See https://developer.github.com/v3/repos/#create
+ * @throws IOException
+ * In case of any networking error or error from the server.
+ */
+ public GHCreateRepositoryBuilder gitignoreTemplate(String language) throws IOException {
+ return with("gitignore_template", language);
+ }
+
+ /**
+ * Desired license template to apply.
+ *
+ * @param license
+ * template to base the license file on
+ * @return a builder to continue with building See https://developer.github.com/v3/repos/#create
+ * @throws IOException
+ * In case of any networking error or error from the server.
+ */
+ public GHCreateRepositoryBuilder licenseTemplate(String license) throws IOException {
+ return with("license_template", license);
+ }
+
+ /**
+ * Specifies the ownership of the repository.
+ *
+ * @param owner
+ * organization or personage
* @return a builder to continue with building
+ * @throws IOException
+ * In case of any networking error or error from the server.
*/
- public GHCreateRepositoryBuilder fromTemplateRepository(GHRepository templateRepository) {
- Objects.requireNonNull(templateRepository, "templateRepository cannot be null");
- if (!templateRepository.isTemplate()) {
- throw new IllegalArgumentException("The provided repository is not a template repository.");
- }
- return fromTemplateRepository(templateRepository.getOwnerName(), templateRepository.getName());
+ public GHCreateRepositoryBuilder owner(String owner) throws IOException {
+ return with("owner", owner);
}
/**
- * Creates a repository with all the parameters.
+ * The team that gets granted access to this repository. Only valid for creating a repository in an organization.
*
- * @return the gh repository
+ * @param team
+ * team to grant access to
+ * @return a builder to continue with building
* @throws IOException
- * if repository cannot be created
+ * In case of any networking error or error from the server.
*/
- public GHRepository create() throws IOException {
- return done();
+ public GHCreateRepositoryBuilder team(GHTeam team) throws IOException {
+ if (team != null)
+ return with("team_id", team.getId());
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHDeployKey.java b/src/main/java/org/kohsuke/github/GHDeployKey.java
index 07ee6279a0..cba3e243c7 100644
--- a/src/main/java/org/kohsuke/github/GHDeployKey.java
+++ b/src/main/java/org/kohsuke/github/GHDeployKey.java
@@ -13,21 +13,8 @@
*/
public class GHDeployKey {
- /**
- * Create default GHDeployKey instance
- */
- public GHDeployKey() {
- }
-
- /** The title. */
- protected String url, key, title;
-
- /** The verified. */
- protected boolean verified;
-
- /** The id. */
- protected long id;
- private GHRepository owner;
+ /** Name of user that added the deploy key */
+ private String addedBy;
/** Creation date of the deploy key */
private String createdAt;
@@ -35,55 +22,57 @@ public GHDeployKey() {
/** Last used date of the deploy key */
private String lastUsed;
- /** Name of user that added the deploy key */
- private String addedBy;
-
+ private GHRepository owner;
/** Whether the deploykey has readonly permission or full access */
private boolean readOnly;
- /**
- * Gets id.
- *
- * @return the id
- */
- public long getId() {
- return id;
- }
+ /** The id. */
+ protected long id;
+
+ /** The title. */
+ protected String url, key, title;
+
+ /** The verified. */
+ protected boolean verified;
/**
- * Gets key.
- *
- * @return the key
+ * Create default GHDeployKey instance
*/
- public String getKey() {
- return key;
+ public GHDeployKey() {
}
/**
- * Gets title.
+ * Delete.
*
- * @return the title
+ * @throws IOException
+ * the io exception
*/
- public String getTitle() {
- return title;
+ public void delete() throws IOException {
+ owner.root()
+ .createRequest()
+ .method("DELETE")
+ .withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
+ .send();
}
/**
- * Gets url.
+ * Gets added_by
*
- * @return the url
+ * @return the added_by
*/
- public String getUrl() {
- return url;
+ public String getAddedBy() {
+ return addedBy;
}
/**
- * Is verified boolean.
+ * Gets added_by
*
- * @return the boolean
+ * @return the added_by
+ * @deprecated Use {@link #getAddedBy()}
*/
- public boolean isVerified() {
- return verified;
+ @Deprecated
+ public String getAdded_by() {
+ return getAddedBy();
}
/**
@@ -96,6 +85,24 @@ public Instant getCreatedAt() {
return GitHubClient.parseInstant(createdAt);
}
+ /**
+ * Gets id.
+ *
+ * @return the id
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Gets key.
+ *
+ * @return the key
+ */
+ public String getKey() {
+ return key;
+ }
+
/**
* Gets last_used.
*
@@ -107,55 +114,50 @@ public Instant getLastUsedAt() {
}
/**
- * Gets added_by
+ * Gets title.
*
- * @return the added_by
- * @deprecated Use {@link #getAddedBy()}
+ * @return the title
*/
- @Deprecated
- public String getAdded_by() {
- return getAddedBy();
+ public String getTitle() {
+ return title;
}
/**
- * Gets added_by
+ * Gets url.
*
- * @return the added_by
+ * @return the url
*/
- public String getAddedBy() {
- return addedBy;
+ public String getUrl() {
+ return url;
}
/**
* Is read_only
*
* @return true if the key can only read. False if the key has write permission as well.
- * @deprecated {@link #isReadOnly()}
*/
- @Deprecated
- public boolean isRead_only() {
- return isReadOnly();
+ public boolean isReadOnly() {
+ return readOnly;
}
/**
* Is read_only
*
* @return true if the key can only read. False if the key has write permission as well.
+ * @deprecated {@link #isReadOnly()}
*/
- public boolean isReadOnly() {
- return readOnly;
+ @Deprecated
+ public boolean isRead_only() {
+ return isReadOnly();
}
/**
- * Wrap gh deploy key.
+ * Is verified boolean.
*
- * @param repo
- * the repo
- * @return the gh deploy key
+ * @return the boolean
*/
- GHDeployKey lateBind(GHRepository repo) {
- this.owner = repo;
- return this;
+ public boolean isVerified() {
+ return verified;
}
/**
@@ -175,16 +177,14 @@ public String toString() {
}
/**
- * Delete.
+ * Wrap gh deploy key.
*
- * @throws IOException
- * the io exception
+ * @param repo
+ * the repo
+ * @return the gh deploy key
*/
- public void delete() throws IOException {
- owner.root()
- .createRequest()
- .method("DELETE")
- .withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
- .send();
+ GHDeployKey lateBind(GHRepository repo) {
+ this.owner = repo;
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHDeployment.java b/src/main/java/org/kohsuke/github/GHDeployment.java
index a075c75638..95770de8c4 100644
--- a/src/main/java/org/kohsuke/github/GHDeployment.java
+++ b/src/main/java/org/kohsuke/github/GHDeployment.java
@@ -15,87 +15,86 @@
*/
public class GHDeployment extends GHObject {
- /**
- * Create default GHDeployment instance
- */
- public GHDeployment() {
- }
-
private GHRepository owner;
- /** The sha. */
- protected String sha;
+ /** The creator. */
+ protected GHUser creator;
- /** The ref. */
- protected String ref;
+ /** The description. */
+ protected String description;
- /** The task. */
- protected String task;
+ /** The environment. */
+ protected String environment;
+
+ /** The original environment. */
+ protected String originalEnvironment;
/** The payload. */
protected Object payload;
- /** The environment. */
- protected String environment;
-
- /** The description. */
- protected String description;
+ /** The production environment. */
+ protected boolean productionEnvironment;
- /** The statuses url. */
- protected String statusesUrl;
+ /** The ref. */
+ protected String ref;
/** The repository url. */
protected String repositoryUrl;
- /** The creator. */
- protected GHUser creator;
+ /** The sha. */
+ protected String sha;
- /** The original environment. */
- protected String originalEnvironment;
+ /** The statuses url. */
+ protected String statusesUrl;
+
+ /** The task. */
+ protected String task;
/** The transient environment. */
protected boolean transientEnvironment;
- /** The production environment. */
- protected boolean productionEnvironment;
+ /**
+ * Create default GHDeployment instance
+ */
+ public GHDeployment() {
+ }
/**
- * Wrap.
+ * Create status gh deployment status builder.
*
- * @param owner
- * the owner
- * @return the GH deployment
+ * @param state
+ * the state
+ * @return the gh deployment status builder
*/
- GHDeployment wrap(GHRepository owner) {
- this.owner = owner;
- return this;
+ public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
+ return new GHDeploymentStatusBuilder(owner, getId(), state);
}
/**
- * Gets statuses url.
+ * Gets creator.
*
- * @return the statuses url
+ * @return the creator
*/
- public URL getStatusesUrl() {
- return GitHubClient.parseURL(statusesUrl);
+ public GHUser getCreator() {
+ return root().intern(creator);
}
/**
- * Gets repository url.
+ * Gets environment.
*
- * @return the repository url
+ * @return the environment
*/
- public URL getRepositoryUrl() {
- return GitHubClient.parseURL(repositoryUrl);
+ public String getEnvironment() {
+ return environment;
}
/**
- * Gets task.
+ * The environment defined when the deployment was first created.
*
- * @return the task
+ * @return the original deployment environment
*/
- public String getTask() {
- return task;
+ public String getOriginalEnvironment() {
+ return originalEnvironment;
}
/**
@@ -128,78 +127,67 @@ public Object getPayloadObject() {
}
/**
- * The environment defined when the deployment was first created.
- *
- * @return the original deployment environment
- */
- public String getOriginalEnvironment() {
- return originalEnvironment;
- }
-
- /**
- * Gets environment.
+ * Gets ref.
*
- * @return the environment
+ * @return the ref
*/
- public String getEnvironment() {
- return environment;
+ public String getRef() {
+ return ref;
}
/**
- * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
- * future.
+ * Gets repository url.
*
- * @return the environment is transient
+ * @return the repository url
*/
- public boolean isTransientEnvironment() {
- return transientEnvironment;
+ public URL getRepositoryUrl() {
+ return GitHubClient.parseURL(repositoryUrl);
}
/**
- * Specifies if the given environment is one that end-users directly interact with.
+ * Gets sha.
*
- * @return the environment is used by end-users directly
+ * @return the sha
*/
- public boolean isProductionEnvironment() {
- return productionEnvironment;
+ public String getSha() {
+ return sha;
}
/**
- * Gets creator.
+ * Gets statuses url.
*
- * @return the creator
+ * @return the statuses url
*/
- public GHUser getCreator() {
- return root().intern(creator);
+ public URL getStatusesUrl() {
+ return GitHubClient.parseURL(statusesUrl);
}
/**
- * Gets ref.
+ * Gets task.
*
- * @return the ref
+ * @return the task
*/
- public String getRef() {
- return ref;
+ public String getTask() {
+ return task;
}
/**
- * Gets sha.
+ * Specifies if the given environment is one that end-users directly interact with.
*
- * @return the sha
+ * @return the environment is used by end-users directly
*/
- public String getSha() {
- return sha;
+ public boolean isProductionEnvironment() {
+ return productionEnvironment;
}
/**
- * Create status gh deployment status builder.
+ * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
+ * future.
*
- * @param state
- * the state
- * @return the gh deployment status builder
+ * @return the environment is transient
*/
- public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
- return new GHDeploymentStatusBuilder(owner, getId(), state);
+ public boolean isTransientEnvironment() {
+ return transientEnvironment;
}
/**
@@ -222,4 +210,16 @@ public PagedIterable listStatuses() {
GHRepository getOwner() {
return owner;
}
+
+ /**
+ * Wrap.
+ *
+ * @param owner
+ * the owner
+ * @return the GH deployment
+ */
+ GHDeployment wrap(GHRepository owner) {
+ this.owner = owner;
+ return this;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java b/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
index 0463b425bc..3340558bbe 100644
--- a/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
@@ -11,8 +11,8 @@
*/
// Based on https://developer.github.com/v3/repos/deployments/#create-a-deployment
public class GHDeploymentBuilder {
- private final GHRepository repo;
private final Requester builder;
+ private final GHRepository repo;
/**
* Instantiates a new Gh deployment builder.
@@ -40,54 +40,53 @@ public GHDeploymentBuilder(GHRepository repo, String ref) {
}
/**
- * Ref gh deployment builder.
+ * Auto merge gh deployment builder.
*
- * @param branch
- * the branch
+ * @param autoMerge
+ * the auto merge
*
* @return the gh deployment builder
*/
- public GHDeploymentBuilder ref(String branch) {
- builder.with("ref", branch);
+ public GHDeploymentBuilder autoMerge(boolean autoMerge) {
+ builder.with("auto_merge", autoMerge);
return this;
}
/**
- * Task gh deployment builder.
+ * Create gh deployment.
*
- * @param task
- * the task
+ * @return the gh deployment
*
- * @return the gh deployment builder
+ * @throws IOException
+ * the io exception
*/
- public GHDeploymentBuilder task(String task) {
- builder.with("task", task);
- return this;
+ public GHDeployment create() throws IOException {
+ return builder.withUrlPath(repo.getApiTailUrl("deployments")).fetch(GHDeployment.class).wrap(repo);
}
/**
- * Auto merge gh deployment builder.
+ * Description gh deployment builder.
*
- * @param autoMerge
- * the auto merge
+ * @param description
+ * the description
*
* @return the gh deployment builder
*/
- public GHDeploymentBuilder autoMerge(boolean autoMerge) {
- builder.with("auto_merge", autoMerge);
+ public GHDeploymentBuilder description(String description) {
+ builder.with("description", description);
return this;
}
/**
- * Required contexts gh deployment builder.
+ * Environment gh deployment builder.
*
- * @param requiredContexts
- * the required contexts
+ * @param environment
+ * the environment
*
* @return the gh deployment builder
*/
- public GHDeploymentBuilder requiredContexts(List requiredContexts) {
- builder.with("required_contexts", requiredContexts);
+ public GHDeploymentBuilder environment(String environment) {
+ builder.with("environment", environment);
return this;
}
@@ -105,65 +104,66 @@ public GHDeploymentBuilder payload(String payload) {
}
/**
- * Environment gh deployment builder.
- *
- * @param environment
- * the environment
+ * Specifies if the given environment is one that end-users directly interact with.
*
+ * @param productionEnvironment
+ * the environment is used by end-users directly
* @return the gh deployment builder
*/
- public GHDeploymentBuilder environment(String environment) {
- builder.with("environment", environment);
+ public GHDeploymentBuilder productionEnvironment(boolean productionEnvironment) {
+ builder.with("production_environment", productionEnvironment);
return this;
}
/**
- * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
- * future.
+ * Ref gh deployment builder.
+ *
+ * @param branch
+ * the branch
*
- * @param transientEnvironment
- * the environment is transient
* @return the gh deployment builder
*/
- public GHDeploymentBuilder transientEnvironment(boolean transientEnvironment) {
- builder.with("transient_environment", transientEnvironment);
+ public GHDeploymentBuilder ref(String branch) {
+ builder.with("ref", branch);
return this;
}
/**
- * Specifies if the given environment is one that end-users directly interact with.
+ * Required contexts gh deployment builder.
+ *
+ * @param requiredContexts
+ * the required contexts
*
- * @param productionEnvironment
- * the environment is used by end-users directly
* @return the gh deployment builder
*/
- public GHDeploymentBuilder productionEnvironment(boolean productionEnvironment) {
- builder.with("production_environment", productionEnvironment);
+ public GHDeploymentBuilder requiredContexts(List requiredContexts) {
+ builder.with("required_contexts", requiredContexts);
return this;
}
/**
- * Description gh deployment builder.
+ * Task gh deployment builder.
*
- * @param description
- * the description
+ * @param task
+ * the task
*
* @return the gh deployment builder
*/
- public GHDeploymentBuilder description(String description) {
- builder.with("description", description);
+ public GHDeploymentBuilder task(String task) {
+ builder.with("task", task);
return this;
}
/**
- * Create gh deployment.
- *
- * @return the gh deployment
+ * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
+ * future.
*
- * @throws IOException
- * the io exception
+ * @param transientEnvironment
+ * the environment is transient
+ * @return the gh deployment builder
*/
- public GHDeployment create() throws IOException {
- return builder.withUrlPath(repo.getApiTailUrl("deployments")).fetch(GHDeployment.class).wrap(repo);
+ public GHDeploymentBuilder transientEnvironment(boolean transientEnvironment) {
+ builder.with("transient_environment", transientEnvironment);
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHDeploymentState.java b/src/main/java/org/kohsuke/github/GHDeploymentState.java
index 718e57c478..cefb3bc8ac 100644
--- a/src/main/java/org/kohsuke/github/GHDeploymentState.java
+++ b/src/main/java/org/kohsuke/github/GHDeploymentState.java
@@ -6,30 +6,30 @@
*/
public enum GHDeploymentState {
- /** The pending. */
- PENDING,
-
- /** The success. */
- SUCCESS,
-
/** The error. */
ERROR,
/** The failure. */
FAILURE,
+ /**
+ * The state of the deployment currently reflects it's no longer active.
+ */
+ INACTIVE,
+
/**
* The state of the deployment currently reflects it's in progress.
*/
IN_PROGRESS,
+ /** The pending. */
+ PENDING,
+
/**
* The state of the deployment currently reflects it's queued up for processing.
*/
QUEUED,
- /**
- * The state of the deployment currently reflects it's no longer active.
- */
- INACTIVE
+ /** The success. */
+ SUCCESS
}
diff --git a/src/main/java/org/kohsuke/github/GHDeploymentStatus.java b/src/main/java/org/kohsuke/github/GHDeploymentStatus.java
index 9362da4af6..3cf39fecf9 100644
--- a/src/main/java/org/kohsuke/github/GHDeploymentStatus.java
+++ b/src/main/java/org/kohsuke/github/GHDeploymentStatus.java
@@ -9,58 +9,36 @@
*/
public class GHDeploymentStatus extends GHObject {
- /**
- * Create default GHDeploymentStatus instance
- */
- public GHDeploymentStatus() {
- }
-
private GHRepository owner;
/** The creator. */
protected GHUser creator;
- /** The state. */
- protected String state;
+ /** The deployment url. */
+ protected String deploymentUrl;
/** The description. */
protected String description;
- /** The target url. */
- protected String targetUrl;
+ /** The environment url. */
+ protected String environmentUrl;
/** The log url. */
protected String logUrl;
- /** The deployment url. */
- protected String deploymentUrl;
-
/** The repository url. */
protected String repositoryUrl;
- /** The environment url. */
- protected String environmentUrl;
+ /** The state. */
+ protected String state;
- /**
- * Wrap gh deployment status.
- *
- * @param owner
- * the owner
- *
- * @return the gh deployment status
- */
- GHDeploymentStatus lateBind(GHRepository owner) {
- this.owner = owner;
- return this;
- }
+ /** The target url. */
+ protected String targetUrl;
/**
- * Gets target url.
- *
- * @return the target url
+ * Create default GHDeploymentStatus instance
*/
- public URL getLogUrl() {
- return GitHubClient.parseURL(logUrl);
+ public GHDeploymentStatus() {
}
/**
@@ -81,6 +59,15 @@ public URL getEnvironmentUrl() {
return GitHubClient.parseURL(environmentUrl);
}
+ /**
+ * Gets target url.
+ *
+ * @return the target url
+ */
+ public URL getLogUrl() {
+ return GitHubClient.parseURL(logUrl);
+ }
+
/**
* Gets repository url.
*
@@ -108,4 +95,17 @@ public GHDeploymentState getState() {
GHRepository getOwner() {
return owner;
}
+
+ /**
+ * Wrap gh deployment status.
+ *
+ * @param owner
+ * the owner
+ *
+ * @return the gh deployment status
+ */
+ GHDeploymentStatus lateBind(GHRepository owner) {
+ this.owner = owner;
+ return this;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java b/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java
index e003758fb8..23406e0580 100644
--- a/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHDeploymentStatusBuilder.java
@@ -10,8 +10,8 @@
*/
public class GHDeploymentStatusBuilder {
private final Requester builder;
- private GHRepository repo;
private long deploymentId;
+ private GHRepository repo;
/**
* Instantiates a new GH deployment status builder.
@@ -44,6 +44,20 @@ public GHDeploymentStatusBuilder autoInactive(boolean autoInactive) {
return this;
}
+ /**
+ * Create gh deployment status.
+ *
+ * @return the gh deployment status
+ *
+ * @throws IOException
+ * the io exception
+ */
+ public GHDeploymentStatus create() throws IOException {
+ return builder.withUrlPath(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"))
+ .fetch(GHDeploymentStatus.class)
+ .lateBind(repo);
+ }
+
/**
* Description gh deployment status builder.
*
@@ -92,18 +106,4 @@ public GHDeploymentStatusBuilder logUrl(String logUrl) {
this.builder.with("log_url", logUrl);
return this;
}
-
- /**
- * Create gh deployment status.
- *
- * @return the gh deployment status
- *
- * @throws IOException
- * the io exception
- */
- public GHDeploymentStatus create() throws IOException {
- return builder.withUrlPath(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"))
- .fetch(GHDeploymentStatus.class)
- .lateBind(repo);
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHDiscussion.java b/src/main/java/org/kohsuke/github/GHDiscussion.java
index d2fbaa3f67..99e8801d08 100644
--- a/src/main/java/org/kohsuke/github/GHDiscussion.java
+++ b/src/main/java/org/kohsuke/github/GHDiscussion.java
@@ -20,96 +20,56 @@
public class GHDiscussion extends GHObject {
/**
- * Create default GHDiscussion instance
- */
- public GHDiscussion() {
- }
-
- private GHTeam team;
- private long number;
- private String body, title, htmlUrl;
-
- @JsonProperty(value = "private")
- private boolean isPrivate;
-
- /**
- * Gets the html url.
- *
- * @return the html url
- */
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
- }
-
- /**
- * Wrap up.
- *
- * @param team
- * the team
- * @return the GH discussion
- */
- GHDiscussion wrapUp(GHTeam team) {
- this.team = team;
- return this;
- }
-
- /**
- * Get the team to which this discussion belongs.
+ * A {@link GHLabelBuilder} that creates a new {@link GHLabel}
*
- * @return the team for this discussion
+ * Consumer must call {@link Creator#done()} to create the new instance.
*/
- @Nonnull
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHTeam getTeam() {
- return team;
- }
+ public static class Creator extends GHDiscussionBuilder {
- /**
- * Get the title of the discussion.
- *
- * @return the title
- */
- public String getTitle() {
- return title;
- }
+ private Creator(@Nonnull GHTeam team) {
+ super(GHDiscussion.Creator.class, team, null);
+ requester.method("POST").setRawUrlPath(getRawUrlPath(team, null));
+ }
- /**
- * The description of this discussion.
- *
- * @return the body
- */
- public String getBody() {
- return body;
+ /**
+ * Sets whether this discussion is private to this team.
+ *
+ * @param value
+ * privacy of this discussion
+ * @return either a continuing builder or an updated {@link GHDiscussion}
+ * @throws IOException
+ * if there is an I/O Exception
+ */
+ @Nonnull
+ public Creator private_(boolean value) throws IOException {
+ return with("private", value);
+ }
}
/**
- * The number of this discussion.
+ * A {@link GHLabelBuilder} that updates a single property per request
*
- * @return the number
+ * {@link GitHubRequestBuilderDone#done()} is called automatically after the property is set.
*/
- public long getNumber() {
- return number;
+ public static class Setter extends GHDiscussionBuilder {
+ private Setter(@Nonnull GHDiscussion base) {
+ super(GHDiscussion.class, base.team, base);
+ requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
+ }
}
-
/**
- * The id number of this discussion. GitHub discussions have "number" instead of "id". This is provided for
- * convenience.
+ * A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
*
- * @return the id number for this discussion
- * @see #getNumber()
+ * Consumer must call {@link Updater#done()} to commit changes.
*/
- @Override
- public long getId() {
- return getNumber();
+ public static class Updater extends GHDiscussionBuilder {
+ private Updater(@Nonnull GHDiscussion base) {
+ super(GHDiscussion.Updater.class, base.team, base);
+ requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
+ }
}
-
- /**
- * Whether the discussion is private to the team.
- *
- * @return {@code true} if discussion is private.
- */
- public boolean isPrivate() {
- return isPrivate;
+ private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
+ return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
}
/**
@@ -158,24 +118,19 @@ static PagedIterable readAll(GHTeam team) {
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
}
- /**
- * Begins a batch update
- *
- * Consumer must call {@link GHDiscussion.Updater#done()} to commit changes.
- *
- * @return a {@link GHDiscussion.Updater}
- */
- public GHDiscussion.Updater update() {
- return new GHDiscussion.Updater(this);
- }
+ private String body, title, htmlUrl;
+
+ @JsonProperty(value = "private")
+ private boolean isPrivate;
+
+ private long number;
+
+ private GHTeam team;
/**
- * Begins a single property update.
- *
- * @return a {@link GHDiscussion.Setter}
+ * Create default GHDiscussion instance
*/
- public GHDiscussion.Setter set() {
- return new GHDiscussion.Setter(this);
+ public GHDiscussion() {
}
/**
@@ -188,79 +143,83 @@ public void delete() throws IOException {
team.root().createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
}
- private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
- return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
+ /**
+ * Equals.
+ *
+ * @param o
+ * the o
+ * @return true, if successful
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ GHDiscussion that = (GHDiscussion) o;
+ return number == that.number && Objects.equals(getUrl(), that.getUrl()) && Objects.equals(team, that.team)
+ && Objects.equals(body, that.body) && Objects.equals(title, that.title);
}
/**
- * A {@link GHLabelBuilder} that updates a single property per request
+ * The description of this discussion.
*
- * {@link GitHubRequestBuilderDone#done()} is called automatically after the property is set.
+ * @return the body
*/
- public static class Setter extends GHDiscussionBuilder {
- private Setter(@Nonnull GHDiscussion base) {
- super(GHDiscussion.class, base.team, base);
- requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
- }
+ public String getBody() {
+ return body;
}
/**
- * A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
+ * Gets the html url.
*
- * Consumer must call {@link Updater#done()} to commit changes.
+ * @return the html url
*/
- public static class Updater extends GHDiscussionBuilder {
- private Updater(@Nonnull GHDiscussion base) {
- super(GHDiscussion.Updater.class, base.team, base);
- requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
- }
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * A {@link GHLabelBuilder} that creates a new {@link GHLabel}
+ * The id number of this discussion. GitHub discussions have "number" instead of "id". This is provided for
+ * convenience.
*
- * Consumer must call {@link Creator#done()} to create the new instance.
+ * @return the id number for this discussion
+ * @see #getNumber()
*/
- public static class Creator extends GHDiscussionBuilder {
+ @Override
+ public long getId() {
+ return getNumber();
+ }
- private Creator(@Nonnull GHTeam team) {
- super(GHDiscussion.Creator.class, team, null);
- requester.method("POST").setRawUrlPath(getRawUrlPath(team, null));
- }
+ /**
+ * The number of this discussion.
+ *
+ * @return the number
+ */
+ public long getNumber() {
+ return number;
+ }
- /**
- * Sets whether this discussion is private to this team.
- *
- * @param value
- * privacy of this discussion
- * @return either a continuing builder or an updated {@link GHDiscussion}
- * @throws IOException
- * if there is an I/O Exception
- */
- @Nonnull
- public Creator private_(boolean value) throws IOException {
- return with("private", value);
- }
+ /**
+ * Get the team to which this discussion belongs.
+ *
+ * @return the team for this discussion
+ */
+ @Nonnull
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHTeam getTeam() {
+ return team;
}
/**
- * Equals.
+ * Get the title of the discussion.
*
- * @param o
- * the o
- * @return true, if successful
+ * @return the title
*/
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- GHDiscussion that = (GHDiscussion) o;
- return number == that.number && Objects.equals(getUrl(), that.getUrl()) && Objects.equals(team, that.team)
- && Objects.equals(body, that.body) && Objects.equals(title, that.title);
+ public String getTitle() {
+ return title;
}
/**
@@ -272,4 +231,45 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(team, number, body, title);
}
+
+ /**
+ * Whether the discussion is private to the team.
+ *
+ * @return {@code true} if discussion is private.
+ */
+ public boolean isPrivate() {
+ return isPrivate;
+ }
+
+ /**
+ * Begins a single property update.
+ *
+ * @return a {@link GHDiscussion.Setter}
+ */
+ public GHDiscussion.Setter set() {
+ return new GHDiscussion.Setter(this);
+ }
+
+ /**
+ * Begins a batch update
+ *
+ * Consumer must call {@link GHDiscussion.Updater#done()} to commit changes.
+ *
+ * @return a {@link GHDiscussion.Updater}
+ */
+ public GHDiscussion.Updater update() {
+ return new GHDiscussion.Updater(this);
+ }
+
+ /**
+ * Wrap up.
+ *
+ * @param team
+ * the team
+ * @return the GH discussion
+ */
+ GHDiscussion wrapUp(GHTeam team) {
+ this.team = team;
+ return this;
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHDiscussionBuilder.java b/src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
index 39dfd287d1..30d1986731 100644
--- a/src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
@@ -43,20 +43,6 @@ protected GHDiscussionBuilder(@Nonnull Class intermediateReturnType,
}
}
- /**
- * Title for this discussion.
- *
- * @param value
- * title of discussion
- * @return either a continuing builder or an updated {@link GHDiscussion}
- * @throws IOException
- * if there is an I/O Exception
- */
- @Nonnull
- public S title(String value) throws IOException {
- return with("title", value);
- }
-
/**
* Body content for this discussion.
*
@@ -79,4 +65,18 @@ public S body(String value) throws IOException {
public GHDiscussion done() throws IOException {
return super.done().wrapUp(team);
}
+
+ /**
+ * Title for this discussion.
+ *
+ * @param value
+ * title of discussion
+ * @return either a continuing builder or an updated {@link GHDiscussion}
+ * @throws IOException
+ * if there is an I/O Exception
+ */
+ @Nonnull
+ public S title(String value) throws IOException {
+ return with("title", value);
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHEmail.java b/src/main/java/org/kohsuke/github/GHEmail.java
index 75dcc0b6ba..f5446a338d 100644
--- a/src/main/java/org/kohsuke/github/GHEmail.java
+++ b/src/main/java/org/kohsuke/github/GHEmail.java
@@ -37,12 +37,6 @@
justification = "JSON API")
public class GHEmail {
- /**
- * Create default GHEmail instance
- */
- public GHEmail() {
- }
-
/** The email. */
protected String email;
@@ -52,6 +46,28 @@ public GHEmail() {
/** The verified. */
protected boolean verified;
+ /**
+ * Create default GHEmail instance
+ */
+ public GHEmail() {
+ }
+
+ /**
+ * Equals.
+ *
+ * @param obj
+ * the obj
+ * @return true, if successful
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof GHEmail) {
+ GHEmail that = (GHEmail) obj;
+ return this.email.equals(that.email);
+ }
+ return false;
+ }
+
/**
* Gets email.
*
@@ -61,6 +77,16 @@ public String getEmail() {
return email;
}
+ /**
+ * Hash code.
+ *
+ * @return the int
+ */
+ @Override
+ public int hashCode() {
+ return email.hashCode();
+ }
+
/**
* Is primary boolean.
*
@@ -88,30 +114,4 @@ public boolean isVerified() {
public String toString() {
return "Email:" + email;
}
-
- /**
- * Hash code.
- *
- * @return the int
- */
- @Override
- public int hashCode() {
- return email.hashCode();
- }
-
- /**
- * Equals.
- *
- * @param obj
- * the obj
- * @return true, if successful
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof GHEmail) {
- GHEmail that = (GHEmail) obj;
- return this.email.equals(that.email);
- }
- return false;
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHError.java b/src/main/java/org/kohsuke/github/GHError.java
index 9455ff31fe..3602703945 100644
--- a/src/main/java/org/kohsuke/github/GHError.java
+++ b/src/main/java/org/kohsuke/github/GHError.java
@@ -13,37 +13,28 @@
*/
public class GHError implements Serializable {
- /**
- * Create default GHError instance
- */
- public GHError() {
- }
-
/**
* The serial version UID of the error
*/
private static final long serialVersionUID = 2008071901;
/**
- * The error message.
+ * The URL to the documentation for the error.
*/
+ @JsonProperty("documentation_url")
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private String message;
+ private String documentation;
/**
- * The URL to the documentation for the error.
+ * The error message.
*/
- @JsonProperty("documentation_url")
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private String documentation;
+ private String message;
/**
- * Get the error message.
- *
- * @return the message
+ * Create default GHError instance
*/
- public String getMessage() {
- return message;
+ public GHError() {
}
/**
@@ -55,4 +46,13 @@ public URL getDocumentationUrl() {
return GitHubClient.parseURL(documentation);
}
+ /**
+ * Get the error message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
}
diff --git a/src/main/java/org/kohsuke/github/GHEvent.java b/src/main/java/org/kohsuke/github/GHEvent.java
index 1170743ac3..d3619c06a0 100644
--- a/src/main/java/org/kohsuke/github/GHEvent.java
+++ b/src/main/java/org/kohsuke/github/GHEvent.java
@@ -12,6 +12,9 @@
*/
public enum GHEvent {
+ /** Special event type that means "every possible event". */
+ ALL,
+
/** The branch protection rule. */
BRANCH_PROTECTION_RULE,
@@ -36,15 +39,15 @@ public enum GHEvent {
/** The delete. */
DELETE,
- /** The deploy key. */
- DEPLOY_KEY,
-
/** The deployment. */
DEPLOYMENT,
/** The deployment status. */
DEPLOYMENT_STATUS,
+ /** The deploy key. */
+ DEPLOY_KEY,
+
/** The discussion. */
DISCUSSION,
@@ -63,12 +66,12 @@ public enum GHEvent {
/** The fork apply. */
FORK_APPLY,
- /** The github app authorization. */
- GITHUB_APP_AUTHORIZATION,
-
/** The gist. */
GIST,
+ /** The github app authorization. */
+ GITHUB_APP_AUTHORIZATION,
+
/** The gollum. */
GOLLUM,
@@ -81,12 +84,12 @@ public enum GHEvent {
/** The integration installation repositories. */
INTEGRATION_INSTALLATION_REPOSITORIES,
- /** The issue comment. */
- ISSUE_COMMENT,
-
/** The issues. */
ISSUES,
+ /** The issue comment. */
+ ISSUE_COMMENT,
+
/** The label. */
LABEL,
@@ -99,12 +102,12 @@ public enum GHEvent {
/** The membership. */
MEMBERSHIP,
- /** The merge queue entry. */
- MERGE_QUEUE_ENTRY,
-
/** The merge group entry. */
MERGE_GROUP,
+ /** The merge queue entry. */
+ MERGE_QUEUE_ENTRY,
+
/** The meta. */
META,
@@ -123,18 +126,18 @@ public enum GHEvent {
/** The page build. */
PAGE_BUILD,
+ /** The ping. */
+ PING,
+
+ /** The project. */
+ PROJECT,
+
/** The project card. */
PROJECT_CARD,
/** The project column. */
PROJECT_COLUMN,
- /** The project. */
- PROJECT,
-
- /** The ping. */
- PING,
-
/** The public. */
PUBLIC,
@@ -158,13 +161,13 @@ public enum GHEvent {
/** The release. */
RELEASE,
-
- /** The repository dispatch. */
- REPOSITORY_DISPATCH,
/** The repository. */
// only valid for org hooks
REPOSITORY,
+ /** The repository dispatch. */
+ REPOSITORY_DISPATCH,
+
/** The repository import. */
REPOSITORY_IMPORT,
@@ -189,25 +192,22 @@ public enum GHEvent {
/** The team add. */
TEAM_ADD,
+ /**
+ * Special event type that means we haven't found an enum value corresponding to the event.
+ */
+ UNKNOWN,
+
/** The watch. */
WATCH,
- /** The workflow job. */
- WORKFLOW_JOB,
-
/** The workflow dispatch. */
WORKFLOW_DISPATCH,
- /** The workflow run. */
- WORKFLOW_RUN,
-
- /**
- * Special event type that means we haven't found an enum value corresponding to the event.
- */
- UNKNOWN,
+ /** The workflow job. */
+ WORKFLOW_JOB,
- /** Special event type that means "every possible event". */
- ALL;
+ /** The workflow run. */
+ WORKFLOW_RUN;
/**
* Returns GitHub's internal representation of this event.
diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java
index d2448dfee2..b9adccf2e6 100644
--- a/src/main/java/org/kohsuke/github/GHEventInfo.java
+++ b/src/main/java/org/kohsuke/github/GHEventInfo.java
@@ -17,34 +17,6 @@
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHEventInfo extends GitHubInteractiveObject {
- /**
- * Create default GHEventInfo instance
- */
- public GHEventInfo() {
- }
-
- // we don't want to expose Jackson dependency to the user. This needs databinding
- private ObjectNode payload;
-
- private long id;
- private String createdAt;
-
- /**
- * Representation of GitHub Event API Event Type.
- *
- * This is not the same as the values used for hook methods such as
- * {@link GHRepository#createHook(String, Map, Collection, boolean)}.
- *
- * @see GitHub event
- * types
- */
- private String type;
-
- // these are all shallow objects
- private GHEventRepository repo;
- private GHUser actor;
- private GHOrganization org;
-
/**
* Inside the event JSON model, GitHub uses a slightly different format.
*/
@@ -54,17 +26,17 @@ public GHEventInfo() {
justification = "JSON API")
public static class GHEventRepository {
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
+ private long id;
+
+ private String name; // owner/repo
+ @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
+ private String url; // repository API URL
/**
* Create default GHEventRepository instance
*/
public GHEventRepository() {
}
-
- @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
- private long id;
- @SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "We don't provide it in API now")
- private String url; // repository API URL
- private String name; // owner/repo
}
/** The Constant mapTypeStringToEvent. */
@@ -95,7 +67,6 @@ private static Map createEventMap() {
map.put("WatchEvent", GHEvent.WATCH);
return Collections.unmodifiableMap(map);
}
-
/**
* Transform type to GH event.
*
@@ -107,45 +78,33 @@ static GHEvent transformTypeToGHEvent(String type) {
return mapTypeStringToEvent.getOrDefault(type, GHEvent.UNKNOWN);
}
- /**
- * Gets type.
- *
- * @return the type
- */
- public GHEvent getType() {
- return transformTypeToGHEvent(type);
- }
+ private GHUser actor;
- /**
- * Gets id.
- *
- * @return the id
- */
- public long getId() {
- return id;
- }
+ private String createdAt;
+ private long id;
+ private GHOrganization org;
+
+ // we don't want to expose Jackson dependency to the user. This needs databinding
+ private ObjectNode payload;
+
+ // these are all shallow objects
+ private GHEventRepository repo;
/**
- * Gets created at.
+ * Representation of GitHub Event API Event Type.
*
- * @return the created at
+ * This is not the same as the values used for hook methods such as
+ * {@link GHRepository#createHook(String, Map, Collection, boolean)}.
+ *
+ * @see GitHub event
+ * types
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getCreatedAt() {
- return GitHubClient.parseInstant(createdAt);
- }
+ private String type;
/**
- * Gets repository.
- *
- * @return Repository where the change was made.
- * @throws IOException
- * on error
+ * Create default GHEventInfo instance
*/
- @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
- justification = "The field comes from JSON deserialization")
- public GHRepository getRepository() throws IOException {
- return root().getRepository(repo.name);
+ public GHEventInfo() {
}
/**
@@ -170,6 +129,25 @@ public String getActorLogin() {
return actor.getLogin();
}
+ /**
+ * Gets created at.
+ *
+ * @return the created at
+ */
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getCreatedAt() {
+ return GitHubClient.parseInstant(createdAt);
+ }
+
+ /**
+ * Gets id.
+ *
+ * @return the id
+ */
+ public long getId() {
+ return id;
+ }
+
/**
* Gets organization.
*
@@ -200,4 +178,26 @@ public T getPayload(Class type) throws IOException
v.lateBind();
return v;
}
+
+ /**
+ * Gets repository.
+ *
+ * @return Repository where the change was made.
+ * @throws IOException
+ * on error
+ */
+ @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" },
+ justification = "The field comes from JSON deserialization")
+ public GHRepository getRepository() throws IOException {
+ return root().getRepository(repo.name);
+ }
+
+ /**
+ * Gets type.
+ *
+ * @return the type
+ */
+ public GHEvent getType() {
+ return transformTypeToGHEvent(type);
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java
index 592a04e28f..d4d0af2b77 100644
--- a/src/main/java/org/kohsuke/github/GHEventPayload.java
+++ b/src/main/java/org/kohsuke/github/GHEventPayload.java
@@ -25,84 +25,6 @@
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API")
public abstract class GHEventPayload extends GitHubInteractiveObject {
- // https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object-common-properties
- // Webhook payload object common properties: action, sender, repository, organization, installation
- private String action;
- private GHUser sender;
- private GHRepository repository;
- private GHOrganization organization;
- private GHAppInstallation installation;
-
- /**
- * Instantiates a new GH event payload.
- */
- GHEventPayload() {
- }
-
- /**
- * Gets the action for the triggered event. Most but not all webhook payloads contain an action property that
- * contains the specific activity that triggered the event.
- *
- * @return event action
- */
- public String getAction() {
- return action;
- }
-
- /**
- * Gets the sender or {@code null} if accessed via the events API.
- *
- * @return the sender or {@code null} if accessed via the events API.
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHUser getSender() {
- return sender;
- }
-
- /**
- * Gets repository.
- *
- * @return the repository
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRepository getRepository() {
- return repository;
- }
-
- /**
- * Gets organization.
- *
- * @return the organization
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHOrganization getOrganization() {
- return organization;
- }
-
- /**
- * Gets installation.
- *
- * @return the installation
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHAppInstallation getInstallation() {
- return installation;
- }
-
- // List of events that still need to be added:
- // ContentReferenceEvent
- // DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
- // InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
- // MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
- // ProjectCardEvent ProjectColumnEvent ProjectEvent RepositoryDispatchEvent RepositoryImportEvent
- // RepositoryVulnerabilityAlertEvent SecurityAdvisoryEvent StarEvent StatusEvent TeamEvent TeamAddEvent WatchEvent
-
- /**
- * Late bind.
- */
- void lateBind() {
- }
-
/**
* A check run event has been created, rerequested, completed, or has a requested_action.
*
@@ -112,23 +34,14 @@ void lateBind() {
*/
public static class CheckRun extends GHEventPayload {
- /**
- * Create default CheckRun instance
- */
- public CheckRun() {
- }
+ private GHCheckRun checkRun;
private int number;
- private GHCheckRun checkRun;
private GHRequestedAction requestedAction;
-
/**
- * Gets number.
- *
- * @return the number
+ * Create default CheckRun instance
*/
- public int getNumber() {
- return number;
+ public CheckRun() {
}
/**
@@ -141,6 +54,15 @@ public GHCheckRun getCheckRun() {
return checkRun;
}
+ /**
+ * Gets number.
+ *
+ * @return the number
+ */
+ public int getNumber() {
+ return number;
+ }
+
/**
* Gets the Requested Action object.
*
@@ -168,7 +90,6 @@ void lateBind() {
}
}
}
-
/**
* A check suite event has been requested, rerequested or completed.
*
@@ -178,14 +99,14 @@ void lateBind() {
*/
public static class CheckSuite extends GHEventPayload {
+ private GHCheckSuite checkSuite;
+
/**
* Create default CheckSuite instance
*/
public CheckSuite() {
}
- private GHCheckSuite checkSuite;
-
/**
* Gets the Check Suite object.
*
@@ -213,62 +134,81 @@ void lateBind() {
}
}
}
-
/**
- * An installation has been installed, uninstalled, or its permissions have been changed.
+ * Wrapper for changes on issue and pull request review comments action="edited".
*
- * @see
- * installation event
- * @see GitHub App Installation
+ * @see GHEventPayload.IssueComment
+ * @see GHEventPayload.PullRequestReviewComment
*/
- public static class Installation extends GHEventPayload {
+ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "JSON API")
+ public static class CommentChanges {
/**
- * Create default Installation instance
+ * Wrapper for changed values.
*/
- public Installation() {
+ public static class GHFrom {
+
+ private String from;
+
+ /**
+ * Create default GHFrom instance
+ */
+ public GHFrom() {
+ }
+
+ /**
+ * Previous comment value that was changed.
+ *
+ * @return previous value
+ */
+ public String getFrom() {
+ return from;
+ }
}
- private List repositories;
- private List ghRepositories = null;
+ private GHFrom body;
/**
- * Gets repositories. For the "deleted" action please rather call {@link #getRawRepositories()}
+ * Create default CommentChanges instance
+ */
+ public CommentChanges() {
+ }
+
+ /**
+ * Gets the previous comment body.
*
- * @return the repositories
+ * @return previous comment body (or null if not changed)
*/
- public List getRepositories() {
- if ("deleted".equalsIgnoreCase(getAction())) {
- throw new IllegalStateException("Can't call #getRepositories() on Installation event "
- + "with 'deleted' action. Call #getRawRepositories() instead.");
- }
+ public GHFrom getBody() {
+ return body;
+ }
+ }
+ /**
+ * A comment was added to a commit.
+ *
+ * @see
+ * commit comment
+ * @see Comments
+ */
+ public static class CommitComment extends GHEventPayload {
- if (ghRepositories == null) {
- ghRepositories = new ArrayList<>(repositories.size());
- try {
- for (Repository singleRepo : repositories) {
- // populate each repository
- // the repository information provided here is so limited
- // as to be unusable without populating, so we do it eagerly
- ghRepositories.add(this.root().getRepositoryById(singleRepo.getId()));
- }
- } catch (IOException e) {
- throw new GHException("Failed to refresh repositories", e);
- }
- }
+ private GHCommitComment comment;
- return Collections.unmodifiableList(ghRepositories);
+ /**
+ * Create default CommitComment instance
+ */
+ public CommitComment() {
}
/**
- * Returns a list of raw, unpopulated repositories. Useful when calling from within Installation event with
- * action "deleted". You can't fetch the info for repositories of an already deleted installation.
+ * Gets comment.
*
- * @return the list of raw Repository records
+ * @return the comment
*/
- public List getRawRepositories() {
- return Collections.unmodifiableList(repositories);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHCommitComment getComment() {
+ return comment;
}
/**
@@ -276,214 +216,134 @@ public List getRawRepositories() {
*/
@Override
void lateBind() {
- if (getInstallation() == null) {
- throw new IllegalStateException(
- "Expected installation payload, but got something else. Maybe we've got another type of event?");
- }
super.lateBind();
+ GHRepository repository = getRepository();
+ if (repository != null) {
+ comment.wrap(repository);
+ }
}
+ }
+ /**
+ * A repository, branch, or tag was created.
+ *
+ * @see
+ * create event
+ * @see Git data
+ */
+ public static class Create extends GHEventPayload {
+
+ private String description;
+ private String masterBranch;
+ private String ref;
+ private String refType;
/**
- * A special minimal implementation of a {@link GHRepository} which contains only fields from "Properties of
- * repositories" from here
+ * Create default Create instance
*/
- public static class Repository {
-
- /**
- * Create default Repository instance
- */
- public Repository() {
- }
+ public Create() {
+ }
- private long id;
- private String fullName;
- private String name;
- private String nodeId;
- @JsonProperty(value = "private")
- private boolean isPrivate;
-
- /**
- * Get the id.
- *
- * @return the id
- */
- public long getId() {
- return id;
- }
-
- /**
- * Gets the full name.
- *
- * @return the full name
- */
- public String getFullName() {
- return fullName;
- }
-
- /**
- * Gets the name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets the node id.
- *
- * @return the node id
- */
- public String getNodeId() {
- return nodeId;
- }
-
- /**
- * Gets the repository private flag.
- *
- * @return whether the repository is private
- */
- public boolean isPrivate() {
- return isPrivate;
- }
- }
- }
-
- /**
- * A repository has been added or removed from an installation.
- *
- * @see
- * installation_repositories event
- * @see GitHub App installation
- */
- public static class InstallationRepositories extends GHEventPayload {
-
- /**
- * Create default InstallationRepositories instance
- */
- public InstallationRepositories() {
- }
-
- private String repositorySelection;
- private List repositoriesAdded;
- private List repositoriesRemoved;
+ /**
+ * Gets description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
/**
- * Gets installation selection.
+ * Gets default branch.
*
- * @return the installation selection
- */
- public String getRepositorySelection() {
- return repositorySelection;
- }
-
- /**
- * Gets repositories added.
+ * Name is an artifact of when "master" was the most common default.
*
- * @return the repositories
+ * @return the default branch
*/
- public List getRepositoriesAdded() {
- return Collections.unmodifiableList(repositoriesAdded);
+ public String getMasterBranch() {
+ return masterBranch;
}
/**
- * Gets repositories removed.
+ * Gets ref.
*
- * @return the repositories
+ * @return the ref
*/
- public List getRepositoriesRemoved() {
- return Collections.unmodifiableList(repositoriesRemoved);
+ public String getRef() {
+ return ref;
}
/**
- * Late bind.
+ * Gets ref type.
+ *
+ * @return the ref type
*/
- @Override
- void lateBind() {
- if (getInstallation() == null) {
- throw new IllegalStateException(
- "Expected installation_repositories payload, but got something else. Maybe we've got another type of event?");
- }
- super.lateBind();
- List repositories;
- if ("added".equals(getAction()))
- repositories = repositoriesAdded;
- else // action == "removed"
- repositories = repositoriesRemoved;
-
- if (repositories != null && !repositories.isEmpty()) {
- try {
- for (GHRepository singleRepo : repositories) { // warp each of the repository
- singleRepo.populate();
- }
- } catch (IOException e) {
- throw new GHException("Failed to refresh repositories", e);
- }
- }
+ public String getRefType() {
+ return refType;
}
}
/**
- * A pull request status has changed.
+ * A branch, or tag was deleted.
*
- * @see
- * pull_request event
- * @see Pull Requests
+ * @see
+ * delete event
+ * @see Git data
*/
- @SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD" }, justification = "JSON API")
- public static class PullRequest extends GHEventPayload {
+ public static class Delete extends GHEventPayload {
+
+ private String ref;
+ private String refType;
/**
- * Create default PullRequest instance
+ * Create default Delete instance
*/
- public PullRequest() {
+ public Delete() {
}
- private int number;
- private GHPullRequest pullRequest;
- private GHLabel label;
- private GHPullRequestChanges changes;
-
/**
- * Gets number.
+ * Gets ref.
*
- * @return the number
+ * @return the ref
*/
- public int getNumber() {
- return number;
+ public String getRef() {
+ return ref;
}
/**
- * Gets pull request.
+ * Gets ref type.
*
- * @return the pull request
+ * @return the ref type
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequest getPullRequest() {
- return pullRequest;
+ public String getRefType() {
+ return refType;
}
+ }
+
+ /**
+ * A deployment.
+ *
+ * @see
+ * deployment event
+ * @see Deployments
+ */
+ public static class Deployment extends GHEventPayload {
+
+ private GHDeployment deployment;
/**
- * Gets the added or removed label for labeled/unlabeled events.
- *
- * @return label the added or removed label
+ * Create default Deployment instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHLabel getLabel() {
- return label;
+ public Deployment() {
}
/**
- * Get changes (for action="edited").
+ * Gets deployment.
*
- * @return changes
+ * @return the deployment
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequestChanges getChanges() {
- return changes;
+ public GHDeployment getDeployment() {
+ return deployment;
}
/**
@@ -491,54 +351,51 @@ public GHPullRequestChanges getChanges() {
*/
@Override
void lateBind() {
- if (pullRequest == null)
- throw new IllegalStateException(
- "Expected pull_request payload, but got something else. Maybe we've got another type of event?");
super.lateBind();
GHRepository repository = getRepository();
if (repository != null) {
- pullRequest.wrapUp(repository);
+ deployment.wrap(repository);
}
}
}
/**
- * A review was added to a pull request.
+ * A deployment status.
*
* @see
- * pull_request_review event
- * @see Pull Request Reviews
+ * "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deployment_status">
+ * deployment_status event
+ * @see Deployments
*/
- public static class PullRequestReview extends GHEventPayload {
+ public static class DeploymentStatus extends GHEventPayload {
+
+ private GHDeployment deployment;
+ private GHDeploymentStatus deploymentStatus;
/**
- * Create default PullRequestReview instance
+ * Create default DeploymentStatus instance
*/
- public PullRequestReview() {
+ public DeploymentStatus() {
}
- private GHPullRequestReview review;
- private GHPullRequest pullRequest;
-
/**
- * Gets review.
+ * Gets deployment.
*
- * @return the review
+ * @return the deployment
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequestReview getReview() {
- return review;
+ public GHDeployment getDeployment() {
+ return deployment;
}
/**
- * Gets pull request.
+ * Gets deployment status.
*
- * @return the pull request
+ * @return the deployment status
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequest getPullRequest() {
- return pullRequest;
+ public GHDeploymentStatus getDeploymentStatus() {
+ return deploymentStatus;
}
/**
@@ -546,187 +403,253 @@ public GHPullRequest getPullRequest() {
*/
@Override
void lateBind() {
- if (review == null)
- throw new IllegalStateException(
- "Expected pull_request_review payload, but got something else. Maybe we've got another type of event?");
super.lateBind();
-
- review.wrapUp(pullRequest);
-
GHRepository repository = getRepository();
if (repository != null) {
- pullRequest.wrapUp(repository);
+ deployment.wrap(repository);
+ deploymentStatus.lateBind(repository);
}
}
}
/**
- * Wrapper for changes on issue and pull request review comments action="edited".
+ * A discussion was closed, reopened, created, edited, deleted, pinned, unpinned, locked, unlocked, transferred,
+ * category_changed, answered, or unanswered.
*
- * @see GHEventPayload.IssueComment
- * @see GHEventPayload.PullRequestReviewComment
+ * @see
+ * discussion event
*/
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "JSON API")
- public static class CommentChanges {
+ public static class Discussion extends GHEventPayload {
+
+ private GHRepositoryDiscussion discussion;
+
+ private GHLabel label;
/**
- * Create default CommentChanges instance
+ * Create default Discussion instance
*/
- public CommentChanges() {
+ public Discussion() {
}
- private GHFrom body;
-
/**
- * Gets the previous comment body.
+ * Gets discussion.
*
- * @return previous comment body (or null if not changed)
+ * @return the discussion
*/
- public GHFrom getBody() {
- return body;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHRepositoryDiscussion getDiscussion() {
+ return discussion;
}
/**
- * Wrapper for changed values.
+ * Gets the added or removed label for labeled/unlabeled events.
+ *
+ * @return label the added or removed label
*/
- public static class GHFrom {
-
- /**
- * Create default GHFrom instance
- */
- public GHFrom() {
- }
-
- private String from;
-
- /**
- * Previous comment value that was changed.
- *
- * @return previous value
- */
- public String getFrom() {
- return from;
- }
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHLabel getLabel() {
+ return label;
}
}
/**
- * A review comment was added to a pull request.
+ * A discussion comment was created, deleted, or edited.
*
* @see
- * pull_request_review_comment event
- * @see Pull Request Review Comments
+ * "https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#discussion_comment">
+ * discussion event
*/
- public static class PullRequestReviewComment extends GHEventPayload {
+ public static class DiscussionComment extends GHEventPayload {
+
+ private GHRepositoryDiscussionComment comment;
+
+ private GHRepositoryDiscussion discussion;
/**
- * Create default PullRequestReviewComment instance
+ * Create default DiscussionComment instance
*/
- public PullRequestReviewComment() {
+ public DiscussionComment() {
}
- private GHPullRequestReviewComment comment;
- private GHPullRequest pullRequest;
- private CommentChanges changes;
-
/**
- * Gets comment.
+ * Gets discussion comment.
*
- * @return the comment
+ * @return the discussion
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequestReviewComment getComment() {
+ public GHRepositoryDiscussionComment getComment() {
return comment;
}
/**
- * Get changes (for action="edited").
+ * Gets discussion.
*
- * @return changes
+ * @return the discussion
*/
- public CommentChanges getChanges() {
- return changes;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHRepositoryDiscussion getDiscussion() {
+ return discussion;
}
+ }
+
+ /**
+ * A user forked a repository.
+ *
+ * @see fork
+ * event
+ * @see Forks
+ */
+ public static class Fork extends GHEventPayload {
+
+ private GHRepository forkee;
/**
- * Gets pull request.
- *
- * @return the pull request
+ * Create default Fork instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHPullRequest getPullRequest() {
- return pullRequest;
+ public Fork() {
}
/**
- * Late bind.
+ * Gets forkee.
+ *
+ * @return the forkee
*/
- @Override
- void lateBind() {
- if (comment == null)
- throw new IllegalStateException(
- "Expected pull_request_review_comment payload, but got something else. Maybe we've got another type of event?");
- super.lateBind();
- comment.wrapUp(pullRequest);
-
- GHRepository repository = getRepository();
- if (repository != null) {
- pullRequest.wrapUp(repository);
- }
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHRepository getForkee() {
+ return forkee;
}
}
+ // List of events that still need to be added:
+ // ContentReferenceEvent
+ // DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
+ // InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
+ // MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
+ // ProjectCardEvent ProjectColumnEvent ProjectEvent RepositoryDispatchEvent RepositoryImportEvent
+ // RepositoryVulnerabilityAlertEvent SecurityAdvisoryEvent StarEvent StatusEvent TeamEvent TeamAddEvent WatchEvent
+
/**
- * A Issue has been assigned, unassigned, labeled, unlabeled, opened, edited, milestoned, demilestoned, closed, or
- * reopened.
+ * An installation has been installed, uninstalled, or its permissions have been changed.
*
- * @see
- * issues events
- * @see Issues Comments
+ * @see
+ * installation event
+ * @see GitHub App Installation
*/
- public static class Issue extends GHEventPayload {
+ public static class Installation extends GHEventPayload {
/**
- * Create default Issue instance
+ * A special minimal implementation of a {@link GHRepository} which contains only fields from "Properties of
+ * repositories" from here
*/
- public Issue() {
- }
+ public static class Repository {
- private GHIssue issue;
+ private String fullName;
- private GHLabel label;
+ private long id;
+ @JsonProperty(value = "private")
+ private boolean isPrivate;
+ private String name;
+ private String nodeId;
+ /**
+ * Create default Repository instance
+ */
+ public Repository() {
+ }
- private GHIssueChanges changes;
+ /**
+ * Gets the full name.
+ *
+ * @return the full name
+ */
+ public String getFullName() {
+ return fullName;
+ }
+
+ /**
+ * Get the id.
+ *
+ * @return the id
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the node id.
+ *
+ * @return the node id
+ */
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ /**
+ * Gets the repository private flag.
+ *
+ * @return whether the repository is private
+ */
+ public boolean isPrivate() {
+ return isPrivate;
+ }
+ }
+
+ private List ghRepositories = null;
+ private List repositories;
/**
- * Gets issue.
- *
- * @return the issue
+ * Create default Installation instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHIssue getIssue() {
- return issue;
+ public Installation() {
}
/**
- * Gets the added or removed label for labeled/unlabeled events.
+ * Returns a list of raw, unpopulated repositories. Useful when calling from within Installation event with
+ * action "deleted". You can't fetch the info for repositories of an already deleted installation.
*
- * @return label the added or removed label
+ * @return the list of raw Repository records
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHLabel getLabel() {
- return label;
+ public List getRawRepositories() {
+ return Collections.unmodifiableList(repositories);
}
/**
- * Get changes (for action="edited").
+ * Gets repositories. For the "deleted" action please rather call {@link #getRawRepositories()}
*
- * @return changes
+ * @return the repositories
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHIssueChanges getChanges() {
- return changes;
+ public List getRepositories() {
+ if ("deleted".equalsIgnoreCase(getAction())) {
+ throw new IllegalStateException("Can't call #getRepositories() on Installation event "
+ + "with 'deleted' action. Call #getRawRepositories() instead.");
+ }
+
+ if (ghRepositories == null) {
+ ghRepositories = new ArrayList<>(repositories.size());
+ try {
+ for (Repository singleRepo : repositories) {
+ // populate each repository
+ // the repository information provided here is so limited
+ // as to be unusable without populating, so we do it eagerly
+ ghRepositories.add(this.root().getRepositoryById(singleRepo.getId()));
+ }
+ } catch (IOException e) {
+ throw new GHException("Failed to refresh repositories", e);
+ }
+ }
+
+ return Collections.unmodifiableList(ghRepositories);
}
/**
@@ -734,42 +657,109 @@ public GHIssueChanges getChanges() {
*/
@Override
void lateBind() {
- super.lateBind();
- GHRepository repository = getRepository();
- if (repository != null) {
- issue.wrap(repository);
+ if (getInstallation() == null) {
+ throw new IllegalStateException(
+ "Expected installation payload, but got something else. Maybe we've got another type of event?");
}
+ super.lateBind();
}
}
/**
- * A comment was added to an issue.
+ * A repository has been added or removed from an installation.
*
* @see
- * issue_comment event
- * @see Issue Comments
- */
- public static class IssueComment extends GHEventPayload {
+ * "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#installation_repositories">
+ * installation_repositories event
+ * @see GitHub App installation
+ */
+ public static class InstallationRepositories extends GHEventPayload {
+
+ private List repositoriesAdded;
+ private List repositoriesRemoved;
+ private String repositorySelection;
/**
- * Create default IssueComment instance
+ * Create default InstallationRepositories instance
*/
- public IssueComment() {
+ public InstallationRepositories() {
}
- private GHIssueComment comment;
- private GHIssue issue;
- private CommentChanges changes;
+ /**
+ * Gets repositories added.
+ *
+ * @return the repositories
+ */
+ public List getRepositoriesAdded() {
+ return Collections.unmodifiableList(repositoriesAdded);
+ }
/**
- * Gets comment.
+ * Gets repositories removed.
*
- * @return the comment
+ * @return the repositories
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHIssueComment getComment() {
- return comment;
+ public List getRepositoriesRemoved() {
+ return Collections.unmodifiableList(repositoriesRemoved);
+ }
+
+ /**
+ * Gets installation selection.
+ *
+ * @return the installation selection
+ */
+ public String getRepositorySelection() {
+ return repositorySelection;
+ }
+
+ /**
+ * Late bind.
+ */
+ @Override
+ void lateBind() {
+ if (getInstallation() == null) {
+ throw new IllegalStateException(
+ "Expected installation_repositories payload, but got something else. Maybe we've got another type of event?");
+ }
+ super.lateBind();
+ List repositories;
+ if ("added".equals(getAction()))
+ repositories = repositoriesAdded;
+ else // action == "removed"
+ repositories = repositoriesRemoved;
+
+ if (repositories != null && !repositories.isEmpty()) {
+ try {
+ for (GHRepository singleRepo : repositories) { // warp each of the repository
+ singleRepo.populate();
+ }
+ } catch (IOException e) {
+ throw new GHException("Failed to refresh repositories", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * A Issue has been assigned, unassigned, labeled, unlabeled, opened, edited, milestoned, demilestoned, closed, or
+ * reopened.
+ *
+ * @see
+ * issues events
+ * @see Issues Comments
+ */
+ public static class Issue extends GHEventPayload {
+
+ private GHIssueChanges changes;
+
+ private GHIssue issue;
+
+ private GHLabel label;
+
+ /**
+ * Create default Issue instance
+ */
+ public Issue() {
}
/**
@@ -777,7 +767,8 @@ public GHIssueComment getComment() {
*
* @return changes
*/
- public CommentChanges getChanges() {
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHIssueChanges getChanges() {
return changes;
}
@@ -791,6 +782,16 @@ public GHIssue getIssue() {
return issue;
}
+ /**
+ * Gets the added or removed label for labeled/unlabeled events.
+ *
+ * @return label the added or removed label
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHLabel getLabel() {
+ return label;
+ }
+
/**
* Late bind.
*/
@@ -801,27 +802,37 @@ void lateBind() {
if (repository != null) {
issue.wrap(repository);
}
- comment.wrapUp(issue);
}
}
/**
- * A comment was added to a commit.
+ * A comment was added to an issue.
*
* @see
- * commit comment
- * @see Comments
+ * "https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#issue_comment">
+ * issue_comment event
+ * @see Issue Comments
*/
- public static class CommitComment extends GHEventPayload {
+ public static class IssueComment extends GHEventPayload {
+ private CommentChanges changes;
+
+ private GHIssueComment comment;
+ private GHIssue issue;
/**
- * Create default CommitComment instance
+ * Create default IssueComment instance
*/
- public CommitComment() {
+ public IssueComment() {
}
- private GHCommitComment comment;
+ /**
+ * Get changes (for action="edited").
+ *
+ * @return changes
+ */
+ public CommentChanges getChanges() {
+ return changes;
+ }
/**
* Gets comment.
@@ -829,10 +840,20 @@ public CommitComment() {
* @return the comment
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHCommitComment getComment() {
+ public GHIssueComment getComment() {
return comment;
}
+ /**
+ * Gets issue.
+ *
+ * @return the issue
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHIssue getIssue() {
+ return issue;
+ }
+
/**
* Late bind.
*/
@@ -841,132 +862,122 @@ void lateBind() {
super.lateBind();
GHRepository repository = getRepository();
if (repository != null) {
- comment.wrap(repository);
+ issue.wrap(repository);
}
+ comment.wrapUp(issue);
}
}
/**
- * A repository, branch, or tag was created.
+ * A label was created, edited or deleted.
*
- * @see
- * create event
- * @see Git data
+ * @see
+ * label event
*/
- public static class Create extends GHEventPayload {
-
- /**
- * Create default Create instance
- */
- public Create() {
- }
+ public static class Label extends GHEventPayload {
- private String ref;
- private String refType;
- private String masterBranch;
- private String description;
+ private GHLabelChanges changes;
- /**
- * Gets ref.
- *
- * @return the ref
- */
- public String getRef() {
- return ref;
- }
+ private GHLabel label;
/**
- * Gets ref type.
- *
- * @return the ref type
+ * Create default Label instance
*/
- public String getRefType() {
- return refType;
+ public Label() {
}
/**
- * Gets default branch.
- *
- * Name is an artifact of when "master" was the most common default.
+ * Gets changes (for action="edited").
*
- * @return the default branch
+ * @return changes
*/
- public String getMasterBranch() {
- return masterBranch;
+ public GHLabelChanges getChanges() {
+ return changes;
}
/**
- * Gets description.
+ * Gets the label.
*
- * @return the description
+ * @return the label
*/
- public String getDescription() {
- return description;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHLabel getLabel() {
+ return label;
}
}
/**
- * A branch, or tag was deleted.
+ * A member event was triggered.
*
- * @see
- * delete event
- * @see Git data
+ * @see member event
*/
- public static class Delete extends GHEventPayload {
+ public static class Member extends GHEventPayload {
+
+ private GHMemberChanges changes;
+
+ private GHUser member;
/**
- * Create default Delete instance
+ * Create default Member instance
*/
- public Delete() {
+ public Member() {
}
- private String ref;
- private String refType;
-
/**
- * Gets ref.
+ * Gets the changes made to the member.
*
- * @return the ref
+ * @return the changes made to the member
*/
- public String getRef() {
- return ref;
+ public GHMemberChanges getChanges() {
+ return changes;
}
/**
- * Gets ref type.
+ * Gets the member.
*
- * @return the ref type
+ * @return the member
*/
- public String getRefType() {
- return refType;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHUser getMember() {
+ return member;
}
}
/**
- * A deployment.
+ * A membership event was triggered.
*
- * @see
- * deployment event
- * @see Deployments
+ * @see membership event
*/
- public static class Deployment extends GHEventPayload {
+ public static class Membership extends GHEventPayload {
+
+ private GHUser member;
+
+ private GHTeam team;
/**
- * Create default Deployment instance
+ * Create default Membership instance
*/
- public Deployment() {
+ public Membership() {
}
- private GHDeployment deployment;
+ /**
+ * Gets the member.
+ *
+ * @return the member
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHUser getMember() {
+ return member;
+ }
/**
- * Gets deployment.
+ * Gets the team.
*
- * @return the deployment
+ * @return the team
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHDeployment getDeployment() {
- return deployment;
+ public GHTeam getTeam() {
+ return team;
}
/**
@@ -974,109 +985,71 @@ public GHDeployment getDeployment() {
*/
@Override
void lateBind() {
+ if (team == null) {
+ throw new IllegalStateException(
+ "Expected membership payload, but got something else. Maybe we've got another type of event?");
+ }
super.lateBind();
- GHRepository repository = getRepository();
- if (repository != null) {
- deployment.wrap(repository);
+ GHOrganization organization = getOrganization();
+ if (organization == null) {
+ throw new IllegalStateException("Organization must not be null");
}
+ team.wrapUp(organization);
}
}
/**
- * A deployment status.
+ * A ping.
*
- * @see
- * deployment_status event
- * @see Deployments
+ * ping
+ * event
*/
- public static class DeploymentStatus extends GHEventPayload {
-
- /**
- * Create default DeploymentStatus instance
- */
- public DeploymentStatus() {
- }
-
- private GHDeploymentStatus deploymentStatus;
- private GHDeployment deployment;
-
- /**
- * Gets deployment status.
- *
- * @return the deployment status
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHDeploymentStatus getDeploymentStatus() {
- return deploymentStatus;
- }
+ public static class Ping extends GHEventPayload {
/**
- * Gets deployment.
- *
- * @return the deployment
+ * Create default Ping instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHDeployment getDeployment() {
- return deployment;
+ public Ping() {
}
- /**
- * Late bind.
- */
- @Override
- void lateBind() {
- super.lateBind();
- GHRepository repository = getRepository();
- if (repository != null) {
- deployment.wrap(repository);
- deploymentStatus.lateBind(repository);
- }
- }
}
/**
- * A user forked a repository.
+ * A project v2 item was archived, converted, created, edited, restored, deleted, or reordered.
*
- * @see fork
+ * @see projects_v2_item
* event
- * @see Forks
*/
- public static class Fork extends GHEventPayload {
+ public static class ProjectsV2Item extends GHEventPayload {
+
+ private GHProjectsV2ItemChanges changes;
+ private GHProjectsV2Item projectsV2Item;
/**
- * Create default Fork instance
+ * Create default ProjectsV2Item instance
*/
- public Fork() {
+ public ProjectsV2Item() {
}
- private GHRepository forkee;
-
/**
- * Gets forkee.
+ * Gets the changes.
*
- * @return the forkee
+ * @return the changes
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRepository getForkee() {
- return forkee;
+ public GHProjectsV2ItemChanges getChanges() {
+ return changes;
}
- }
-
- /**
- * A ping.
- *
- * ping
- * event
- */
- public static class Ping extends GHEventPayload {
/**
- * Create default Ping instance
+ * Gets the projects V 2 item.
+ *
+ * @return the projects V 2 item
*/
- public Ping() {
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHProjectsV2Item getProjectsV2Item() {
+ return projectsV2Item;
}
-
}
/**
@@ -1096,183 +1069,240 @@ public Public() {
}
/**
- * A commit was pushed.
+ * A pull request status has changed.
*
- * @see push
- * event
+ * @see
+ * pull_request event
+ * @see Pull Requests
*/
- public static class Push extends GHEventPayload {
-
- /**
- * Create default Push instance
- */
- public Push() {
- }
+ @SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD" }, justification = "JSON API")
+ public static class PullRequest extends GHEventPayload {
- private String head, before;
- private boolean created, deleted, forced;
- private String ref;
- private int size;
- private List commits;
- private PushCommit headCommit;
- private Pusher pusher;
- private String compare;
+ private GHPullRequestChanges changes;
+ private GHLabel label;
+ private int number;
+ private GHPullRequest pullRequest;
/**
- * The SHA of the HEAD commit on the repository.
- *
- * @return the head
+ * Create default PullRequest instance
*/
- public String getHead() {
- return head;
+ public PullRequest() {
}
/**
- * This is undocumented, but it looks like this captures the commit that the ref was pointing to before the
- * push.
+ * Get changes (for action="edited").
*
- * @return the before
+ * @return changes
*/
- public String getBefore() {
- return before;
- }
-
- @JsonSetter // alias
- private void setAfter(String after) {
- head = after;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHPullRequestChanges getChanges() {
+ return changes;
}
/**
- * The full Git ref that was pushed. Example: “refs/heads/main”
+ * Gets the added or removed label for labeled/unlabeled events.
*
- * @return the ref
+ * @return label the added or removed label
*/
- public String getRef() {
- return ref;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHLabel getLabel() {
+ return label;
}
/**
- * The number of commits in the push. Is this always the same as {@code getCommits().size()}?
+ * Gets number.
*
- * @return the size
+ * @return the number
*/
- public int getSize() {
- return size;
+ public int getNumber() {
+ return number;
}
/**
- * Is created boolean.
+ * Gets pull request.
*
- * @return the boolean
+ * @return the pull request
*/
- public boolean isCreated() {
- return created;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHPullRequest getPullRequest() {
+ return pullRequest;
}
/**
- * Is deleted boolean.
- *
- * @return the boolean
+ * Late bind.
*/
- public boolean isDeleted() {
- return deleted;
+ @Override
+ void lateBind() {
+ if (pullRequest == null)
+ throw new IllegalStateException(
+ "Expected pull_request payload, but got something else. Maybe we've got another type of event?");
+ super.lateBind();
+ GHRepository repository = getRepository();
+ if (repository != null) {
+ pullRequest.wrapUp(repository);
+ }
}
+ }
+
+ /**
+ * A review was added to a pull request.
+ *
+ * @see
+ * pull_request_review event
+ * @see Pull Request Reviews
+ */
+ public static class PullRequestReview extends GHEventPayload {
+
+ private GHPullRequest pullRequest;
+ private GHPullRequestReview review;
/**
- * Is forced boolean.
- *
- * @return the boolean
+ * Create default PullRequestReview instance
*/
- public boolean isForced() {
- return forced;
+ public PullRequestReview() {
}
/**
- * The list of pushed commits.
+ * Gets pull request.
*
- * @return the commits
+ * @return the pull request
*/
- public List getCommits() {
- return Collections.unmodifiableList(commits);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHPullRequest getPullRequest() {
+ return pullRequest;
}
/**
- * The head commit of the push.
+ * Gets review.
*
- * @return the commit
+ * @return the review
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public PushCommit getHeadCommit() {
- return headCommit;
+ public GHPullRequestReview getReview() {
+ return review;
}
/**
- * Gets pusher.
- *
- * @return the pusher
+ * Late bind.
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public Pusher getPusher() {
- return pusher;
+ @Override
+ void lateBind() {
+ if (review == null)
+ throw new IllegalStateException(
+ "Expected pull_request_review payload, but got something else. Maybe we've got another type of event?");
+ super.lateBind();
+
+ review.wrapUp(pullRequest);
+
+ GHRepository repository = getRepository();
+ if (repository != null) {
+ pullRequest.wrapUp(repository);
+ }
}
+ }
+ /**
+ * A review comment was added to a pull request.
+ *
+ * @see
+ * pull_request_review_comment event
+ * @see Pull Request Review Comments
+ */
+ public static class PullRequestReviewComment extends GHEventPayload {
+
+ private CommentChanges changes;
+
+ private GHPullRequestReviewComment comment;
+ private GHPullRequest pullRequest;
/**
- * Gets compare.
- *
- * @return compare
+ * Create default PullRequestReviewComment instance
*/
- public String getCompare() {
- return compare;
+ public PullRequestReviewComment() {
}
/**
- * The type Pusher.
+ * Get changes (for action="edited").
+ *
+ * @return changes
*/
- public static class Pusher {
+ public CommentChanges getChanges() {
+ return changes;
+ }
- /**
- * Create default Pusher instance
- */
- public Pusher() {
- }
+ /**
+ * Gets comment.
+ *
+ * @return the comment
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHPullRequestReviewComment getComment() {
+ return comment;
+ }
- private String name, email;
+ /**
+ * Gets pull request.
+ *
+ * @return the pull request
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHPullRequest getPullRequest() {
+ return pullRequest;
+ }
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ /**
+ * Late bind.
+ */
+ @Override
+ void lateBind() {
+ if (comment == null)
+ throw new IllegalStateException(
+ "Expected pull_request_review_comment payload, but got something else. Maybe we've got another type of event?");
+ super.lateBind();
+ comment.wrapUp(pullRequest);
- /**
- * Gets email.
- *
- * @return the email
- */
- public String getEmail() {
- return email;
+ GHRepository repository = getRepository();
+ if (repository != null) {
+ pullRequest.wrapUp(repository);
}
}
+ }
+
+ /**
+ * A commit was pushed.
+ *
+ * @see push
+ * event
+ */
+ public static class Push extends GHEventPayload {
/**
* Commit in a push. Note: sha is an alias for id.
*/
public static class PushCommit {
+ private List added, removed, modified;
+
+ private GitUser author;
+ private GitUser committer;
+ private boolean distinct;
+ private String url, sha, message, timestamp;
/**
* Create default PushCommit instance
*/
public PushCommit() {
}
- private GitUser author;
- private GitUser committer;
- private String url, sha, message, timestamp;
- private boolean distinct;
- private List added, removed, modified;
+ /**
+ * Gets added.
+ *
+ * @return the added
+ */
+ public List getAdded() {
+ return Collections.unmodifiableList(added);
+ }
/**
* Gets author.
@@ -1292,29 +1322,6 @@ public GitUser getCommitter() {
return committer;
}
- /**
- * Points to the commit API resource.
- *
- * @return the url
- */
- public String getUrl() {
- return url;
- }
-
- /**
- * Gets sha (id).
- *
- * @return the sha
- */
- public String getSha() {
- return sha;
- }
-
- @JsonSetter
- private void setId(String id) {
- sha = id;
- }
-
/**
* Gets message.
*
@@ -1325,21 +1332,12 @@ public String getMessage() {
}
/**
- * Whether this commit is distinct from any that have been pushed before.
- *
- * @return the boolean
- */
- public boolean isDistinct() {
- return distinct;
- }
-
- /**
- * Gets added.
+ * Gets modified.
*
- * @return the added
+ * @return the modified
*/
- public List getAdded() {
- return Collections.unmodifiableList(added);
+ public List getModified() {
+ return Collections.unmodifiableList(modified);
}
/**
@@ -1352,12 +1350,12 @@ public List getRemoved() {
}
/**
- * Gets modified.
+ * Gets sha (id).
*
- * @return the modified
+ * @return the sha
*/
- public List getModified() {
- return Collections.unmodifiableList(modified);
+ public String getSha() {
+ return sha;
}
/**
@@ -1370,490 +1368,409 @@ public Instant getTimestamp() {
return GitHubClient.parseInstant(timestamp);
}
- }
- }
+ /**
+ * Points to the commit API resource.
+ *
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
- /**
- * A release was added to the repo.
- *
- * @see
- * release event
- * @see Releases
- */
- @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" },
- justification = "Constructed by JSON deserialization")
- public static class Release extends GHEventPayload {
+ /**
+ * Whether this commit is distinct from any that have been pushed before.
+ *
+ * @return the boolean
+ */
+ public boolean isDistinct() {
+ return distinct;
+ }
- /**
- * Create default Release instance
- */
- public Release() {
- }
+ @JsonSetter
+ private void setId(String id) {
+ sha = id;
+ }
- private GHRelease release;
+ }
/**
- * Gets release.
- *
- * @return the release
+ * The type Pusher.
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRelease getRelease() {
- return release;
- }
- }
+ public static class Pusher {
- /**
- * A repository was created, deleted, made public, or made private.
- *
- * @see
- * repository event
- * @see Repositories
- */
- public static class Repository extends GHEventPayload {
+ private String name, email;
- /**
- * Create default Repository instance
- */
- public Repository() {
- }
+ /**
+ * Create default Pusher instance
+ */
+ public Pusher() {
+ }
- private GHRepositoryChanges changes;
+ /**
+ * Gets email.
+ *
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
- /**
- * Get changes.
- *
- * @return GHRepositoryChanges
- */
- public GHRepositoryChanges getChanges() {
- return changes;
+ /**
+ * Gets name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
}
+ private List commits;
+ private String compare;
+ private boolean created, deleted, forced;
+ private String head, before;
+ private PushCommit headCommit;
+ private Pusher pusher;
+ private String ref;
- }
-
- /**
- * A git commit status was changed.
- *
- * @see
- * status event
- * @see Repository Statuses
- */
- public static class Status extends GHEventPayload {
+ private int size;
/**
- * Create default Status instance
+ * Create default Push instance
*/
- public Status() {
+ public Push() {
}
- private String context;
- private String description;
- private GHCommitState state;
- private GHCommit commit;
- private String targetUrl;
-
/**
- * Gets the status content.
+ * This is undocumented, but it looks like this captures the commit that the ref was pointing to before the
+ * push.
*
- * @return status content
+ * @return the before
*/
- public String getContext() {
- return context;
+ public String getBefore() {
+ return before;
}
/**
- * The optional link added to the status.
+ * The list of pushed commits.
*
- * @return a url
+ * @return the commits
*/
- public String getTargetUrl() {
- return targetUrl;
+ public List getCommits() {
+ return Collections.unmodifiableList(commits);
}
/**
- * Gets the status description.
+ * Gets compare.
*
- * @return status description
+ * @return compare
*/
- public String getDescription() {
- return description;
+ public String getCompare() {
+ return compare;
}
/**
- * Gets the status state.
+ * The SHA of the HEAD commit on the repository.
*
- * @return status state
+ * @return the head
*/
- public GHCommitState getState() {
- return state;
+ public String getHead() {
+ return head;
}
/**
- * Gets the commit associated with the status event.
+ * The head commit of the push.
*
- * @return commit
+ * @return the commit
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHCommit getCommit() {
- return commit;
- }
-
- /**
- * Late bind.
- */
- @Override
- void lateBind() {
-
- if (state == null) {
- throw new IllegalStateException(
- "Expected status payload, but got something else. Maybe we've got another type of event?");
- }
- super.lateBind();
-
- GHRepository repository = getRepository();
- if (repository != null) {
- commit.wrapUp(repository);
- }
- }
- }
-
- /**
- * Occurs when someone triggered a workflow run or sends a POST request to the "Create a workflow dispatch event"
- * endpoint.
- *
- * @see
- * workflow dispatch event
- * @see Events that
- * trigger workflows
- */
- public static class WorkflowDispatch extends GHEventPayload {
-
- /**
- * Create default WorkflowDispatch instance
- */
- public WorkflowDispatch() {
+ public PushCommit getHeadCommit() {
+ return headCommit;
}
- private Map inputs;
- private String ref;
- private String workflow;
-
/**
- * Gets the map of input parameters passed to the workflow.
+ * Gets pusher.
*
- * @return the map of input parameters
+ * @return the pusher
*/
- public Map getInputs() {
- return Collections.unmodifiableMap(inputs);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public Pusher getPusher() {
+ return pusher;
}
/**
- * Gets the ref of the branch (e.g. refs/heads/main)
+ * The full Git ref that was pushed. Example: “refs/heads/main”
*
- * @return the ref of the branch
+ * @return the ref
*/
public String getRef() {
return ref;
}
/**
- * Gets the path of the workflow file (e.g. .github/workflows/hello-world-workflow.yml).
- *
- * @return the path of the workflow file
- */
- public String getWorkflow() {
- return workflow;
- }
- }
-
- /**
- * A workflow run was requested or completed.
- *
- * @see
- * workflow run event
- * @see Actions Workflow Runs
- */
- public static class WorkflowRun extends GHEventPayload {
-
- /**
- * Create default WorkflowRun instance
- */
- public WorkflowRun() {
- }
-
- private GHWorkflowRun workflowRun;
- private GHWorkflow workflow;
-
- /**
- * Gets the workflow run.
- *
- * @return the workflow run
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHWorkflowRun getWorkflowRun() {
- return workflowRun;
- }
-
- /**
- * Gets the associated workflow.
+ * The number of commits in the push. Is this always the same as {@code getCommits().size()}?
*
- * @return the associated workflow
- */
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHWorkflow getWorkflow() {
- return workflow;
- }
-
- /**
- * Late bind.
+ * @return the size
*/
- @Override
- void lateBind() {
- if (workflowRun == null || workflow == null) {
- throw new IllegalStateException(
- "Expected workflow and workflow_run payload, but got something else. Maybe we've got another type of event?");
- }
- super.lateBind();
- GHRepository repository = getRepository();
- if (repository == null) {
- throw new IllegalStateException("Repository must not be null");
- }
- workflowRun.wrapUp(repository);
- workflow.wrapUp(repository);
- }
- }
-
- /**
- * A workflow job has been queued, is in progress, or has been completed.
- *
- * @see
- * workflow job event
- * @see Actions Workflow Jobs
- */
- public static class WorkflowJob extends GHEventPayload {
+ public int getSize() {
+ return size;
+ }
/**
- * Create default WorkflowJob instance
+ * Is created boolean.
+ *
+ * @return the boolean
*/
- public WorkflowJob() {
+ public boolean isCreated() {
+ return created;
}
- private GHWorkflowJob workflowJob;
-
/**
- * Gets the workflow job.
+ * Is deleted boolean.
*
- * @return the workflow job
+ * @return the boolean
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHWorkflowJob getWorkflowJob() {
- return workflowJob;
+ public boolean isDeleted() {
+ return deleted;
}
/**
- * Late bind.
+ * Is forced boolean.
+ *
+ * @return the boolean
*/
- @Override
- void lateBind() {
- if (workflowJob == null) {
- throw new IllegalStateException(
- "Expected workflow_job payload, but got something else. Maybe we've got another type of event?");
- }
- super.lateBind();
- GHRepository repository = getRepository();
- if (repository == null) {
- throw new IllegalStateException("Repository must not be null");
- }
- workflowJob.wrapUp(repository);
+ public boolean isForced() {
+ return forced;
+ }
+
+ @JsonSetter // alias
+ private void setAfter(String after) {
+ head = after;
}
}
/**
- * A label was created, edited or deleted.
+ * A release was added to the repo.
*
- * @see
- * label event
+ * @see
+ * release event
+ * @see Releases
*/
- public static class Label extends GHEventPayload {
+ @SuppressFBWarnings(value = { "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", "NP_UNWRITTEN_FIELD" },
+ justification = "Constructed by JSON deserialization")
+ public static class Release extends GHEventPayload {
+
+ private GHRelease release;
/**
- * Create default Label instance
+ * Create default Release instance
*/
- public Label() {
+ public Release() {
}
- private GHLabel label;
+ /**
+ * Gets release.
+ *
+ * @return the release
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHRelease getRelease() {
+ return release;
+ }
+ }
- private GHLabelChanges changes;
+ /**
+ * A repository was created, deleted, made public, or made private.
+ *
+ * @see
+ * repository event
+ * @see Repositories
+ */
+ public static class Repository extends GHEventPayload {
+
+ private GHRepositoryChanges changes;
/**
- * Gets the label.
- *
- * @return the label
+ * Create default Repository instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHLabel getLabel() {
- return label;
+ public Repository() {
}
/**
- * Gets changes (for action="edited").
+ * Get changes.
*
- * @return changes
+ * @return GHRepositoryChanges
*/
- public GHLabelChanges getChanges() {
+ public GHRepositoryChanges getChanges() {
return changes;
}
+
}
/**
- * A discussion was closed, reopened, created, edited, deleted, pinned, unpinned, locked, unlocked, transferred,
- * category_changed, answered, or unanswered.
+ * A star was created or deleted on a repository.
*
* @see
- * discussion event
+ * "https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#star">star
+ * event
*/
- public static class Discussion extends GHEventPayload {
-
- /**
- * Create default Discussion instance
- */
- public Discussion() {
- }
-
- private GHRepositoryDiscussion discussion;
+ public static class Star extends GHEventPayload {
- private GHLabel label;
+ private String starredAt;
/**
- * Gets discussion.
- *
- * @return the discussion
+ * Create default Star instance
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRepositoryDiscussion getDiscussion() {
- return discussion;
+ public Star() {
}
/**
- * Gets the added or removed label for labeled/unlabeled events.
+ * Gets the date when the star is added. Is null when the star is deleted.
*
- * @return label the added or removed label
+ * @return the date when the star is added
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHLabel getLabel() {
- return label;
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getStarredAt() {
+ return GitHubClient.parseInstant(starredAt);
}
}
/**
- * A discussion comment was created, deleted, or edited.
+ * A git commit status was changed.
*
- * @see
- * discussion event
+ * @see
+ * status event
+ * @see Repository Statuses
*/
- public static class DiscussionComment extends GHEventPayload {
+ public static class Status extends GHEventPayload {
+
+ private GHCommit commit;
+ private String context;
+ private String description;
+ private GHCommitState state;
+ private String targetUrl;
/**
- * Create default DiscussionComment instance
+ * Create default Status instance
*/
- public DiscussionComment() {
+ public Status() {
}
- private GHRepositoryDiscussion discussion;
-
- private GHRepositoryDiscussionComment comment;
-
/**
- * Gets discussion.
+ * Gets the commit associated with the status event.
*
- * @return the discussion
+ * @return commit
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRepositoryDiscussion getDiscussion() {
- return discussion;
+ public GHCommit getCommit() {
+ return commit;
}
/**
- * Gets discussion comment.
+ * Gets the status content.
*
- * @return the discussion
+ * @return status content
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHRepositoryDiscussionComment getComment() {
- return comment;
+ public String getContext() {
+ return context;
}
- }
-
- /**
- * A star was created or deleted on a repository.
- *
- * @see star
- * event
- */
- public static class Star extends GHEventPayload {
/**
- * Create default Star instance
+ * Gets the status description.
+ *
+ * @return status description
*/
- public Star() {
+ public String getDescription() {
+ return description;
}
- private String starredAt;
+ /**
+ * Gets the status state.
+ *
+ * @return status state
+ */
+ public GHCommitState getState() {
+ return state;
+ }
/**
- * Gets the date when the star is added. Is null when the star is deleted.
+ * The optional link added to the status.
*
- * @return the date when the star is added
+ * @return a url
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getStarredAt() {
- return GitHubClient.parseInstant(starredAt);
+ public String getTargetUrl() {
+ return targetUrl;
+ }
+
+ /**
+ * Late bind.
+ */
+ @Override
+ void lateBind() {
+
+ if (state == null) {
+ throw new IllegalStateException(
+ "Expected status payload, but got something else. Maybe we've got another type of event?");
+ }
+ super.lateBind();
+
+ GHRepository repository = getRepository();
+ if (repository != null) {
+ commit.wrapUp(repository);
+ }
}
}
/**
- * A project v2 item was archived, converted, created, edited, restored, deleted, or reordered.
+ * A team event was triggered.
*
- * @see projects_v2_item
- * event
+ * @see team event
*/
- public static class ProjectsV2Item extends GHEventPayload {
+ public static class Team extends GHEventPayload {
+
+ private GHTeamChanges changes;
+
+ private GHTeam team;
/**
- * Create default ProjectsV2Item instance
+ * Create default Team instance
*/
- public ProjectsV2Item() {
+ public Team() {
}
- private GHProjectsV2Item projectsV2Item;
- private GHProjectsV2ItemChanges changes;
+ /**
+ * Gets the changes made to the team.
+ *
+ * @return the changes made to the team, null unless action is "edited".
+ */
+ public GHTeamChanges getChanges() {
+ return changes;
+ }
/**
- * Gets the projects V 2 item.
+ * Gets the team.
*
- * @return the projects V 2 item
+ * @return the team
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHProjectsV2Item getProjectsV2Item() {
- return projectsV2Item;
+ public GHTeam getTeam() {
+ return team;
}
/**
- * Gets the changes.
- *
- * @return the changes
+ * Late bind.
*/
- public GHProjectsV2ItemChanges getChanges() {
- return changes;
+ @Override
+ void lateBind() {
+ if (team == null) {
+ throw new IllegalStateException(
+ "Expected team payload, but got something else. Maybe we've got another type of event?");
+ }
+ super.lateBind();
+ GHOrganization organization = getOrganization();
+ if (organization == null) {
+ throw new IllegalStateException("Organization must not be null");
+ }
+ team.wrapUp(organization);
}
}
@@ -1864,14 +1781,14 @@ public GHProjectsV2ItemChanges getChanges() {
*/
public static class TeamAdd extends GHEventPayload {
+ private GHTeam team;
+
/**
* Create default TeamAdd instance
*/
public TeamAdd() {
}
- private GHTeam team;
-
/**
* Gets the team.
*
@@ -1901,131 +1818,139 @@ void lateBind() {
}
/**
- * A team event was triggered.
+ * Occurs when someone triggered a workflow run or sends a POST request to the "Create a workflow dispatch event"
+ * endpoint.
*
- * @see team event
+ * @see
+ * workflow dispatch event
+ * @see Events that
+ * trigger workflows
*/
- public static class Team extends GHEventPayload {
+ public static class WorkflowDispatch extends GHEventPayload {
+
+ private Map inputs;
+ private String ref;
+ private String workflow;
/**
- * Create default Team instance
+ * Create default WorkflowDispatch instance
*/
- public Team() {
+ public WorkflowDispatch() {
}
- private GHTeam team;
-
- private GHTeamChanges changes;
-
/**
- * Gets the team.
+ * Gets the map of input parameters passed to the workflow.
*
- * @return the team
+ * @return the map of input parameters
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHTeam getTeam() {
- return team;
+ public Map getInputs() {
+ return Collections.unmodifiableMap(inputs);
}
/**
- * Gets the changes made to the team.
+ * Gets the ref of the branch (e.g. refs/heads/main)
*
- * @return the changes made to the team, null unless action is "edited".
+ * @return the ref of the branch
*/
- public GHTeamChanges getChanges() {
- return changes;
+ public String getRef() {
+ return ref;
}
/**
- * Late bind.
+ * Gets the path of the workflow file (e.g. .github/workflows/hello-world-workflow.yml).
+ *
+ * @return the path of the workflow file
*/
- @Override
- void lateBind() {
- if (team == null) {
- throw new IllegalStateException(
- "Expected team payload, but got something else. Maybe we've got another type of event?");
- }
- super.lateBind();
- GHOrganization organization = getOrganization();
- if (organization == null) {
- throw new IllegalStateException("Organization must not be null");
- }
- team.wrapUp(organization);
+ public String getWorkflow() {
+ return workflow;
}
}
/**
- * A member event was triggered.
+ * A workflow job has been queued, is in progress, or has been completed.
*
- * @see member event
+ * @see
+ * workflow job event
+ * @see Actions Workflow Jobs
*/
- public static class Member extends GHEventPayload {
+ public static class WorkflowJob extends GHEventPayload {
+
+ private GHWorkflowJob workflowJob;
/**
- * Create default Member instance
+ * Create default WorkflowJob instance
*/
- public Member() {
+ public WorkflowJob() {
}
- private GHUser member;
-
- private GHMemberChanges changes;
-
/**
- * Gets the member.
+ * Gets the workflow job.
*
- * @return the member
+ * @return the workflow job
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHUser getMember() {
- return member;
+ public GHWorkflowJob getWorkflowJob() {
+ return workflowJob;
}
/**
- * Gets the changes made to the member.
- *
- * @return the changes made to the member
+ * Late bind.
*/
- public GHMemberChanges getChanges() {
- return changes;
+ @Override
+ void lateBind() {
+ if (workflowJob == null) {
+ throw new IllegalStateException(
+ "Expected workflow_job payload, but got something else. Maybe we've got another type of event?");
+ }
+ super.lateBind();
+ GHRepository repository = getRepository();
+ if (repository == null) {
+ throw new IllegalStateException("Repository must not be null");
+ }
+ workflowJob.wrapUp(repository);
}
}
/**
- * A membership event was triggered.
+ * A workflow run was requested or completed.
*
- * @see membership event
+ * @see
+ * workflow run event
+ * @see Actions Workflow Runs
*/
- public static class Membership extends GHEventPayload {
+ public static class WorkflowRun extends GHEventPayload {
+
+ private GHWorkflow workflow;
+ private GHWorkflowRun workflowRun;
/**
- * Create default Membership instance
+ * Create default WorkflowRun instance
*/
- public Membership() {
+ public WorkflowRun() {
}
- private GHTeam team;
-
- private GHUser member;
-
/**
- * Gets the team.
+ * Gets the associated workflow.
*
- * @return the team
+ * @return the associated workflow
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHTeam getTeam() {
- return team;
+ public GHWorkflow getWorkflow() {
+ return workflow;
}
/**
- * Gets the member.
+ * Gets the workflow run.
*
- * @return the member
+ * @return the workflow run
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
- public GHUser getMember() {
- return member;
+ public GHWorkflowRun getWorkflowRun() {
+ return workflowRun;
}
/**
@@ -2033,16 +1958,91 @@ public GHUser getMember() {
*/
@Override
void lateBind() {
- if (team == null) {
+ if (workflowRun == null || workflow == null) {
throw new IllegalStateException(
- "Expected membership payload, but got something else. Maybe we've got another type of event?");
+ "Expected workflow and workflow_run payload, but got something else. Maybe we've got another type of event?");
}
super.lateBind();
- GHOrganization organization = getOrganization();
- if (organization == null) {
- throw new IllegalStateException("Organization must not be null");
+ GHRepository repository = getRepository();
+ if (repository == null) {
+ throw new IllegalStateException("Repository must not be null");
}
- team.wrapUp(organization);
+ workflowRun.wrapUp(repository);
+ workflow.wrapUp(repository);
}
}
+
+ // https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object-common-properties
+ // Webhook payload object common properties: action, sender, repository, organization, installation
+ private String action;
+
+ private GHAppInstallation installation;
+
+ private GHOrganization organization;
+
+ private GHRepository repository;
+
+ private GHUser sender;
+
+ /**
+ * Instantiates a new GH event payload.
+ */
+ GHEventPayload() {
+ }
+
+ /**
+ * Gets the action for the triggered event. Most but not all webhook payloads contain an action property that
+ * contains the specific activity that triggered the event.
+ *
+ * @return event action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * Gets installation.
+ *
+ * @return the installation
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHAppInstallation getInstallation() {
+ return installation;
+ }
+
+ /**
+ * Gets organization.
+ *
+ * @return the organization
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHOrganization getOrganization() {
+ return organization;
+ }
+
+ /**
+ * Gets repository.
+ *
+ * @return the repository
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHRepository getRepository() {
+ return repository;
+ }
+
+ /**
+ * Gets the sender or {@code null} if accessed via the events API.
+ *
+ * @return the sender or {@code null} if accessed via the events API.
+ */
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
+ public GHUser getSender() {
+ return sender;
+ }
+
+ /**
+ * Late bind.
+ */
+ void lateBind() {
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GHExternalGroup.java b/src/main/java/org/kohsuke/github/GHExternalGroup.java
index c40608d0f5..f5fb69a78d 100644
--- a/src/main/java/org/kohsuke/github/GHExternalGroup.java
+++ b/src/main/java/org/kohsuke/github/GHExternalGroup.java
@@ -16,61 +16,16 @@
*/
public class GHExternalGroup extends GitHubInteractiveObject implements Refreshable {
- /**
- * A reference of a team linked to an external group
- *
- * @author Miguel Esteban Gutiérrez
- */
- public static class GHLinkedTeam {
-
- /**
- * Create default GHLinkedTeam instance
- */
- public GHLinkedTeam() {
- }
-
- /**
- * The identifier of the team
- */
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private long teamId;
-
- /**
- * The name of the team
- */
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private String teamName;
-
- /**
- * Get the linked team identifier
- *
- * @return the id
- */
- public long getId() {
- return teamId;
- }
-
- /**
- * Get the linked team name
- *
- * @return the name
- */
- public String getName() {
- return teamName;
- }
-
- }
-
/**
* A reference of an external member linked to an external group
*/
public static class GHLinkedExternalMember {
/**
- * Create default GHLinkedExternalMember instance
+ * The email attached to the user
*/
- public GHLinkedExternalMember() {
- }
+ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
+ private String memberEmail;
/**
* The internal user ID of the identity
@@ -91,10 +46,19 @@ public GHLinkedExternalMember() {
private String memberName;
/**
- * The email attached to the user
+ * Create default GHLinkedExternalMember instance
*/
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private String memberEmail;
+ public GHLinkedExternalMember() {
+ }
+
+ /**
+ * Get the linked member email
+ *
+ * @return the email
+ */
+ public String getEmail() {
+ return memberEmail;
+ }
/**
* Get the linked member identifier
@@ -123,13 +87,49 @@ public String getName() {
return memberName;
}
+ }
+
+ /**
+ * A reference of a team linked to an external group
+ *
+ * @author Miguel Esteban Gutiérrez
+ */
+ public static class GHLinkedTeam {
+
+ /**
+ * The identifier of the team
+ */
+ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
+ private long teamId;
+
+ /**
+ * The name of the team
+ */
+ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
+ private String teamName;
+
+ /**
+ * Create default GHLinkedTeam instance
+ */
+ public GHLinkedTeam() {
+ }
+
/**
- * Get the linked member email
+ * Get the linked team identifier
*
- * @return the email
+ * @return the id
*/
- public String getEmail() {
- return memberEmail;
+ public long getId() {
+ return teamId;
+ }
+
+ /**
+ * Get the linked team name
+ *
+ * @return the name
+ */
+ public String getName() {
+ return teamName;
}
}
@@ -147,10 +147,12 @@ public String getEmail() {
private String groupName;
/**
- * The date when the group was last updated at
+ * The external members linked to this group
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private String updatedAt;
+ private List members;
+
+ private GHOrganization organization;
/**
* The teams linked to this group
@@ -159,56 +161,32 @@ public String getEmail() {
private List teams;
/**
- * The external members linked to this group
+ * The date when the group was last updated at
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
- private List members;
+ private String updatedAt;
GHExternalGroup() {
this.teams = Collections.emptyList();
this.members = Collections.emptyList();
}
- private GHOrganization organization;
-
- /**
- * Wrap up.
- *
- * @param owner
- * the owner
- */
- GHExternalGroup wrapUp(final GHOrganization owner) {
- this.organization = owner;
- return this;
- }
-
/**
- * Wrap up.
- *
- * @param root
- * the root
- */
- void wrapUp(final GitHub root) { // auto-wrapUp when organization is known from GET /orgs/{org}/external-groups
- wrapUp(organization);
- }
-
- /**
- * Gets organization.
+ * Get the external group id.
*
- * @return the organization
+ * @return the id
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHOrganization getOrganization() {
- return organization;
+ public long getId() {
+ return groupId;
}
/**
- * Get the external group id.
+ * Get the external members linked to this group.
*
- * @return the id
+ * @return the external members
*/
- public long getId() {
- return groupId;
+ public List getMembers() {
+ return Collections.unmodifiableList(members);
}
/**
@@ -221,13 +199,13 @@ public String getName() {
}
/**
- * Get the external group last update date.
+ * Gets organization.
*
- * @return the date
+ * @return the organization
*/
- @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
- public Instant getUpdatedAt() {
- return GitHubClient.parseInstant(updatedAt);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHOrganization getOrganization() {
+ return organization;
}
/**
@@ -240,12 +218,13 @@ public List getTeams() {
}
/**
- * Get the external members linked to this group.
+ * Get the external group last update date.
*
- * @return the external members
+ * @return the date
*/
- public List getMembers() {
- return Collections.unmodifiableList(members);
+ @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
+ public Instant getUpdatedAt() {
+ return GitHubClient.parseInstant(updatedAt);
}
/**
@@ -263,4 +242,25 @@ private String api(final String tail) {
return "/orgs/" + organization.getLogin() + "/external-group/" + getId() + tail;
}
+ /**
+ * Wrap up.
+ *
+ * @param owner
+ * the owner
+ */
+ GHExternalGroup wrapUp(final GHOrganization owner) {
+ this.organization = owner;
+ return this;
+ }
+
+ /**
+ * Wrap up.
+ *
+ * @param root
+ * the root
+ */
+ void wrapUp(final GitHub root) { // auto-wrapUp when organization is known from GET /orgs/{org}/external-groups
+ wrapUp(organization);
+ }
+
}
diff --git a/src/main/java/org/kohsuke/github/GHFork.java b/src/main/java/org/kohsuke/github/GHFork.java
index 34434e137f..620cab32e0 100644
--- a/src/main/java/org/kohsuke/github/GHFork.java
+++ b/src/main/java/org/kohsuke/github/GHFork.java
@@ -7,18 +7,18 @@
public enum GHFork {
/**
- * Search in the parent repository and in forks with more stars than the parent repository.
+ * Search only in forks with more stars than the parent repository.
*
- * Forks with the same or fewer stars than the parent repository are still ignored.
+ * The parent repository is ignored. If no forks have more stars than the parent, no results will be returned.
*/
- PARENT_AND_FORKS("true"),
+ FORKS_ONLY("only"),
/**
- * Search only in forks with more stars than the parent repository.
+ * Search in the parent repository and in forks with more stars than the parent repository.
*
- * The parent repository is ignored. If no forks have more stars than the parent, no results will be returned.
+ * Forks with the same or fewer stars than the parent repository are still ignored.
*/
- FORKS_ONLY("only"),
+ PARENT_AND_FORKS("true"),
/**
* (Default) Search only the parent repository.
diff --git a/src/main/java/org/kohsuke/github/GHGist.java b/src/main/java/org/kohsuke/github/GHGist.java
index 60106dc5b8..e7c4042f5b 100644
--- a/src/main/java/org/kohsuke/github/GHGist.java
+++ b/src/main/java/org/kohsuke/github/GHGist.java
@@ -23,21 +23,21 @@
*/
public class GHGist extends GHObject {
- /** The owner. */
- final GHUser owner;
-
- private String forksUrl, commitsUrl, id, gitPullUrl, gitPushUrl, htmlUrl;
+ private int comments;
- @JsonProperty("public")
- private boolean isPublic;
+ private String commentsUrl;
private String description;
- private int comments;
+ private final Map files;
- private String commentsUrl;
+ private String forksUrl, commitsUrl, id, gitPullUrl, gitPushUrl, htmlUrl;
- private final Map files;
+ @JsonProperty("public")
+ private boolean isPublic;
+
+ /** The owner. */
+ final GHUser owner;
@JsonCreator
private GHGist(@JsonProperty("owner") GHUser owner, @JsonProperty("files") Map files) {
@@ -49,46 +49,60 @@ private GHGist(@JsonProperty("owner") GHUser owner, @JsonProperty("files") Map getFiles() {
+ return Collections.unmodifiableMap(files);
}
/**
- * Is public boolean.
+ * Gets forks url.
*
- * @return the boolean
+ * @return the forks url
*/
- public boolean isPublic() {
- return isPublic;
+ public String getForksUrl() {
+ return forksUrl;
}
/**
- * Gets description.
+ * Gets the id for this Gist. Unlike most other GitHub objects, the id for Gists can be non-numeric, such as
+ * "aa5a315d61ae9438b18d". This should be used instead of {@link #getId()}.
*
- * @return the description
+ * @return id of this Gist
*/
- public String getDescription() {
- return description;
+ public String getGistId() {
+ return this.id;
}
/**
- * Gets comment count.
+ * Gets git pull url.
*
- * @return the comment count
+ * @return URL like https://gist.github.com/gists/12345.git
*/
- public int getCommentCount() {
- return comments;
+ public String getGitPullUrl() {
+ return gitPullUrl;
}
/**
- * Gets comments url.
+ * Gets git push url.
*
- * @return API URL of listing comments.
+ * @return the git push url
*/
- public String getCommentsUrl() {
- return commentsUrl;
+ public String getGitPushUrl() {
+ return gitPushUrl;
}
/**
- * Gets file.
+ * Get the html url.
*
- * @param name
- * the name
- * @return the file
+ * @return the github html url
*/
- public GHGistFile getFile(String name) {
- return files.get(name);
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
/**
- * Gets files.
+ * Unlike most other GitHub objects, the id for Gists can be non-numeric, such as "aa5a315d61ae9438b18d". If the id
+ * is numeric, this method will get it. If id is not numeric, this will throw a runtime
+ * {@link NumberFormatException}.
*
- * @return the files
+ * @return id of the Gist.
+ * @deprecated Use {@link #getGistId()} instead.
*/
- public Map getFiles() {
- return Collections.unmodifiableMap(files);
+ @Deprecated
+ @Override
+ public long getId() {
+ return Long.parseLong(getGistId());
}
/**
- * Gets the api tail url.
+ * Gets owner.
*
- * @param tail
- * the tail
- * @return the api tail url
+ * @return User that owns this Gist.
*/
- String getApiTailUrl(String tail) {
- String result = "/gists/" + id;
- if (!StringUtils.isBlank(tail)) {
- result += StringUtils.prependIfMissing(tail, "/");
- }
- return result;
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHUser getOwner() {
+ return owner;
}
/**
- * Star.
+ * Hash code.
*
- * @throws IOException
- * the io exception
+ * @return the int
*/
- public void star() throws IOException {
- root().createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
+ @Override
+ public int hashCode() {
+ return id.hashCode();
}
/**
- * Unstar.
+ * Is public boolean.
*
- * @throws IOException
- * the io exception
+ * @return the boolean
*/
- public void unstar() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
+ public boolean isPublic() {
+ return isPublic;
}
/**
@@ -229,17 +243,6 @@ public boolean isStarred() throws IOException {
return root().createRequest().withUrlPath(getApiTailUrl("star")).fetchHttpStatusCode() / 100 == 2;
}
- /**
- * Forks this gist into your own.
- *
- * @return the gh gist
- * @throws IOException
- * the io exception
- */
- public GHGist fork() throws IOException {
- return root().createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class);
- }
-
/**
* List forks paged iterable.
*
@@ -250,49 +253,46 @@ public PagedIterable listForks() {
}
/**
- * Deletes this gist.
+ * Star.
*
* @throws IOException
* the io exception
*/
- public void delete() throws IOException {
- root().createRequest().method("DELETE").withUrlPath("/gists/" + id).send();
+ public void star() throws IOException {
+ root().createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
}
/**
- * Updates this gist via a builder.
+ * Unstar.
*
- * @return the gh gist updater
+ * @throws IOException
+ * the io exception
*/
- public GHGistUpdater update() {
- return new GHGistUpdater(this);
+ public void unstar() throws IOException {
+ root().createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
}
/**
- * Equals.
+ * Updates this gist via a builder.
*
- * @param o
- * the o
- * @return true, if successful
+ * @return the gh gist updater
*/
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
- GHGist ghGist = (GHGist) o;
- return id.equals(ghGist.id);
-
+ public GHGistUpdater update() {
+ return new GHGistUpdater(this);
}
/**
- * Hash code.
+ * Gets the api tail url.
*
- * @return the int
+ * @param tail
+ * the tail
+ * @return the api tail url
*/
- @Override
- public int hashCode() {
- return id.hashCode();
+ String getApiTailUrl(String tail) {
+ String result = "/gists/" + id;
+ if (!StringUtils.isBlank(tail)) {
+ result += StringUtils.prependIfMissing(tail, "/");
+ }
+ return result;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHGistBuilder.java b/src/main/java/org/kohsuke/github/GHGistBuilder.java
index c2797b628c..5d7cb908d9 100644
--- a/src/main/java/org/kohsuke/github/GHGistBuilder.java
+++ b/src/main/java/org/kohsuke/github/GHGistBuilder.java
@@ -14,8 +14,8 @@
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
- private final Requester req;
private final LinkedHashMap files = new LinkedHashMap();
+ private final Requester req;
/**
* Instantiates a new Gh gist builder.
@@ -28,26 +28,26 @@ public GHGistBuilder(GitHub root) {
}
/**
- * Description gh gist builder.
+ * Creates a Gist based on the parameters specified thus far.
*
- * @param desc
- * the desc
- * @return the gh gist builder
+ * @return created Gist
+ * @throws IOException
+ * if Gist cannot be created.
*/
- public GHGistBuilder description(String desc) {
- req.with("description", desc);
- return this;
+ public GHGist create() throws IOException {
+ req.with("files", files);
+ return req.withUrlPath("/gists").fetch(GHGist.class);
}
/**
- * Public gh gist builder.
+ * Description gh gist builder.
*
- * @param v
- * the v
+ * @param desc
+ * the desc
* @return the gh gist builder
*/
- public GHGistBuilder public_(boolean v) {
- req.with("public", v);
+ public GHGistBuilder description(String desc) {
+ req.with("description", desc);
return this;
}
@@ -66,14 +66,14 @@ public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) {
}
/**
- * Creates a Gist based on the parameters specified thus far.
+ * Public gh gist builder.
*
- * @return created Gist
- * @throws IOException
- * if Gist cannot be created.
+ * @param v
+ * the v
+ * @return the gh gist builder
*/
- public GHGist create() throws IOException {
- req.with("files", files);
- return req.withUrlPath("/gists").fetch(GHGist.class);
+ public GHGistBuilder public_(boolean v) {
+ req.with("public", v);
+ return this;
}
}
diff --git a/src/main/java/org/kohsuke/github/GHGistFile.java b/src/main/java/org/kohsuke/github/GHGistFile.java
index 50b50973d0..da60cc902d 100644
--- a/src/main/java/org/kohsuke/github/GHGistFile.java
+++ b/src/main/java/org/kohsuke/github/GHGistFile.java
@@ -10,18 +10,27 @@
*/
public class GHGistFile {
+ private String rawUrl, type, language, content;
+
+ private int size;
+
+ private boolean truncated;
+ /** The file name. */
+ /* package almost final */ String fileName;
/**
* Create default GHGistFile instance
*/
public GHGistFile() {
}
- /** The file name. */
- /* package almost final */ String fileName;
-
- private int size;
- private String rawUrl, type, language, content;
- private boolean truncated;
+ /**
+ * Content of this file.
+ *
+ * @return the content
+ */
+ public String getContent() {
+ return content;
+ }
/**
* Gets file name.
@@ -33,12 +42,12 @@ public String getFileName() {
}
/**
- * File size in bytes.
+ * Gets language.
*
- * @return the size
+ * @return the language
*/
- public int getSize() {
- return size;
+ public String getLanguage() {
+ return language;
}
/**
@@ -51,30 +60,21 @@ public String getRawUrl() {
}
/**
- * Content type of this Gist, such as "text/plain".
- *
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * Gets language.
+ * File size in bytes.
*
- * @return the language
+ * @return the size
*/
- public String getLanguage() {
- return language;
+ public int getSize() {
+ return size;
}
/**
- * Content of this file.
+ * Content type of this Gist, such as "text/plain".
*
- * @return the content
+ * @return the type
*/
- public String getContent() {
- return content;
+ public String getType() {
+ return type;
}
/**
diff --git a/src/main/java/org/kohsuke/github/GHGistUpdater.java b/src/main/java/org/kohsuke/github/GHGistUpdater.java
index 8dbd15a479..cc67de6f89 100644
--- a/src/main/java/org/kohsuke/github/GHGistUpdater.java
+++ b/src/main/java/org/kohsuke/github/GHGistUpdater.java
@@ -59,6 +59,18 @@ public GHGistUpdater deleteFile(@Nonnull String fileName) {
return this;
}
+ /**
+ * Description gh gist updater.
+ *
+ * @param desc
+ * the desc
+ * @return the gh gist updater
+ */
+ public GHGistUpdater description(String desc) {
+ builder.with("description", desc);
+ return this;
+ }
+
/**
* Rename file gh gist updater.
*
@@ -74,6 +86,18 @@ public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFil
return this;
}
+ /**
+ * Updates the Gist based on the parameters specified thus far.
+ *
+ * @return the gh gist
+ * @throws IOException
+ * the io exception
+ */
+ public GHGist update() throws IOException {
+ builder.with("files", files);
+ return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class);
+ }
+
/**
* Update file gh gist updater.
*
@@ -107,28 +131,4 @@ public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String newFil
files.put(fileName, file);
return this;
}
-
- /**
- * Description gh gist updater.
- *
- * @param desc
- * the desc
- * @return the gh gist updater
- */
- public GHGistUpdater description(String desc) {
- builder.with("description", desc);
- return this;
- }
-
- /**
- * Updates the Gist based on the parameters specified thus far.
- *
- * @return the gh gist
- * @throws IOException
- * the io exception
- */
- public GHGist update() throws IOException {
- builder.with("files", files);
- return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class);
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHHook.java b/src/main/java/org/kohsuke/github/GHHook.java
index d9e1fc3bd4..cc41288b7f 100644
--- a/src/main/java/org/kohsuke/github/GHHook.java
+++ b/src/main/java/org/kohsuke/github/GHHook.java
@@ -19,31 +19,41 @@
justification = "JSON API")
public abstract class GHHook extends GHObject {
- /**
- * Create default GHHook instance
- */
- public GHHook() {
- }
+ /** The active. */
+ boolean active;
- /** The name. */
- String name;
+ /** The config. */
+ Map config;
/** The events. */
List events;
- /** The active. */
- boolean active;
+ /** The name. */
+ String name;
- /** The config. */
- Map config;
+ /**
+ * Create default GHHook instance
+ */
+ public GHHook() {
+ }
/**
- * Gets name.
+ * Deletes this hook.
*
- * @return the name
+ * @throws IOException
+ * the io exception
*/
- public String getName() {
- return name;
+ public void delete() throws IOException {
+ root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
+ }
+
+ /**
+ * Gets config.
+ *
+ * @return the config
+ */
+ public Map getConfig() {
+ return Collections.unmodifiableMap(config);
}
/**
@@ -60,21 +70,21 @@ public EnumSet getEvents() {
}
/**
- * Is active boolean.
+ * Gets name.
*
- * @return the boolean
+ * @return the name
*/
- public boolean isActive() {
- return active;
+ public String getName() {
+ return name;
}
/**
- * Gets config.
+ * Is active boolean.
*
- * @return the config
+ * @return the boolean
*/
- public Map getConfig() {
- return Collections.unmodifiableMap(config);
+ public boolean isActive() {
+ return active;
}
/**
@@ -89,14 +99,11 @@ public void ping() throws IOException {
}
/**
- * Deletes this hook.
+ * Gets the api route.
*
- * @throws IOException
- * the io exception
+ * @return the api route
*/
- public void delete() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
- }
+ abstract String getApiRoute();
/**
* Root.
@@ -104,11 +111,4 @@ public void delete() throws IOException {
* @return the git hub
*/
abstract GitHub root();
-
- /**
- * Gets the api route.
- *
- * @return the api route
- */
- abstract String getApiRoute();
}
diff --git a/src/main/java/org/kohsuke/github/GHHooks.java b/src/main/java/org/kohsuke/github/GHHooks.java
index addcad3179..25fe143d82 100644
--- a/src/main/java/org/kohsuke/github/GHHooks.java
+++ b/src/main/java/org/kohsuke/github/GHHooks.java
@@ -14,6 +14,66 @@
*/
class GHHooks {
+ private static class OrgContext extends Context {
+ private final GHOrganization organization;
+
+ private OrgContext(GHOrganization organization) {
+ super(organization.root());
+ this.organization = organization;
+ }
+
+ @Override
+ Class extends GHHook> clazz() {
+ return GHOrgHook.class;
+ }
+
+ @Override
+ String collection() {
+ return String.format("/orgs/%s/hooks", organization.getLogin());
+ }
+
+ @Override
+ Class extends GHHook[]> collectionClass() {
+ return GHOrgHook[].class;
+ }
+
+ @Override
+ GHHook wrap(GHHook hook) {
+ return ((GHOrgHook) hook).wrap(organization);
+ }
+ }
+
+ private static class RepoContext extends Context {
+ private final GHUser owner;
+ private final GHRepository repository;
+
+ private RepoContext(GHRepository repository, GHUser owner) {
+ super(repository.root());
+ this.repository = repository;
+ this.owner = owner;
+ }
+
+ @Override
+ Class extends GHHook> clazz() {
+ return GHRepoHook.class;
+ }
+
+ @Override
+ String collection() {
+ return String.format("/repos/%s/%s/hooks", owner.getLogin(), repository.getName());
+ }
+
+ @Override
+ Class extends GHHook[]> collectionClass() {
+ return GHRepoHook[].class;
+ }
+
+ @Override
+ GHHook wrap(GHHook hook) {
+ return ((GHRepoHook) hook).wrap(repository);
+ }
+ }
+
/**
* The Class Context.
*/
@@ -23,39 +83,6 @@ private Context(GitHub root) {
super(root);
}
- /**
- * Gets hooks.
- *
- * @return the hooks
- * @throws IOException
- * the io exception
- */
- public List getHooks() throws IOException {
-
- // jdk/eclipse bug
- GHHook[] hookArray = root().createRequest().withUrlPath(collection()).fetch(collectionClass());
- // requires this
- // to be on separate line
- List list = new ArrayList(Arrays.asList(hookArray));
- for (GHHook h : list)
- wrap(h);
- return list;
- }
-
- /**
- * Gets hook.
- *
- * @param id
- * the id
- * @return the hook
- * @throws IOException
- * the io exception
- */
- public GHHook getHook(int id) throws IOException {
- GHHook hook = root().createRequest().withUrlPath(collection() + "/" + id).fetch(clazz());
- return wrap(hook);
- }
-
/**
* Create hook gh hook.
*
@@ -105,18 +132,37 @@ public void deleteHook(int id) throws IOException {
}
/**
- * Collection.
+ * Gets hook.
*
- * @return the string
+ * @param id
+ * the id
+ * @return the hook
+ * @throws IOException
+ * the io exception
*/
- abstract String collection();
+ public GHHook getHook(int id) throws IOException {
+ GHHook hook = root().createRequest().withUrlPath(collection() + "/" + id).fetch(clazz());
+ return wrap(hook);
+ }
/**
- * Collection class.
+ * Gets hooks.
*
- * @return the class extends GH hook[]>
+ * @return the hooks
+ * @throws IOException
+ * the io exception
*/
- abstract Class extends GHHook[]> collectionClass();
+ public List getHooks() throws IOException {
+
+ // jdk/eclipse bug
+ GHHook[] hookArray = root().createRequest().withUrlPath(collection()).fetch(collectionClass());
+ // requires this
+ // to be on separate line
+ List list = new ArrayList(Arrays.asList(hookArray));
+ for (GHHook h : list)
+ wrap(h);
+ return list;
+ }
/**
* Clazz.
@@ -125,6 +171,20 @@ public void deleteHook(int id) throws IOException {
*/
abstract Class extends GHHook> clazz();
+ /**
+ * Collection.
+ *
+ * @return the string
+ */
+ abstract String collection();
+
+ /**
+ * Collection class.
+ *
+ * @return the class extends GH hook[]>
+ */
+ abstract Class extends GHHook[]> collectionClass();
+
/**
* Wrap.
*
@@ -135,64 +195,15 @@ public void deleteHook(int id) throws IOException {
abstract GHHook wrap(GHHook hook);
}
- private static class RepoContext extends Context {
- private final GHRepository repository;
- private final GHUser owner;
-
- private RepoContext(GHRepository repository, GHUser owner) {
- super(repository.root());
- this.repository = repository;
- this.owner = owner;
- }
-
- @Override
- String collection() {
- return String.format("/repos/%s/%s/hooks", owner.getLogin(), repository.getName());
- }
-
- @Override
- Class extends GHHook[]> collectionClass() {
- return GHRepoHook[].class;
- }
-
- @Override
- Class extends GHHook> clazz() {
- return GHRepoHook.class;
- }
-
- @Override
- GHHook wrap(GHHook hook) {
- return ((GHRepoHook) hook).wrap(repository);
- }
- }
-
- private static class OrgContext extends Context {
- private final GHOrganization organization;
-
- private OrgContext(GHOrganization organization) {
- super(organization.root());
- this.organization = organization;
- }
-
- @Override
- String collection() {
- return String.format("/orgs/%s/hooks", organization.getLogin());
- }
-
- @Override
- Class extends GHHook[]> collectionClass() {
- return GHOrgHook[].class;
- }
-
- @Override
- Class extends GHHook> clazz() {
- return GHOrgHook.class;
- }
-
- @Override
- GHHook wrap(GHHook hook) {
- return ((GHOrgHook) hook).wrap(organization);
- }
+ /**
+ * Org context.
+ *
+ * @param organization
+ * the organization
+ * @return the context
+ */
+ static Context orgContext(GHOrganization organization) {
+ return new OrgContext(organization);
}
/**
@@ -207,15 +218,4 @@ GHHook wrap(GHHook hook) {
static Context repoContext(GHRepository repository, GHUser owner) {
return new RepoContext(repository, owner);
}
-
- /**
- * Org context.
- *
- * @param organization
- * the organization
- * @return the context
- */
- static Context orgContext(GHOrganization organization) {
- return new OrgContext(organization);
- }
}
diff --git a/src/main/java/org/kohsuke/github/GHInvitation.java b/src/main/java/org/kohsuke/github/GHInvitation.java
index c9cfff8d9a..726179d897 100644
--- a/src/main/java/org/kohsuke/github/GHInvitation.java
+++ b/src/main/java/org/kohsuke/github/GHInvitation.java
@@ -18,18 +18,18 @@
justification = "JSON API")
public class GHInvitation extends GHObject {
+ private String htmlUrl;
+
+ private int id;
+ private GHUser invitee, inviter;
+ private String permissions;
+ private GHRepository repository;
/**
* Create default GHInvitation instance
*/
public GHInvitation() {
}
- private int id;
- private GHRepository repository;
- private GHUser invitee, inviter;
- private String permissions;
- private String htmlUrl;
-
/**
* Accept a repository invitation.
*
diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java
index c8db830ff5..e2d5e39bdb 100644
--- a/src/main/java/org/kohsuke/github/GHIssue.java
+++ b/src/main/java/org/kohsuke/github/GHIssue.java
@@ -56,15 +56,63 @@
public class GHIssue extends GHObject implements Reactable {
/**
- * Create default GHIssue instance
+ * The type PullRequest.
*/
- public GHIssue() {
+ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
+ public static class PullRequest {
+
+ private String diffUrl, patchUrl, htmlUrl;
+
+ /**
+ * Create default PullRequest instance
+ */
+ public PullRequest() {
+ }
+
+ /**
+ * Gets diff url.
+ *
+ * @return the diff url
+ */
+ public URL getDiffUrl() {
+ return GitHubClient.parseURL(diffUrl);
+ }
+
+ /**
+ * Gets patch url.
+ *
+ * @return the patch url
+ */
+ public URL getPatchUrl() {
+ return GitHubClient.parseURL(patchUrl);
+ }
+
+ /**
+ * Gets url.
+ *
+ * @return the url
+ */
+ public URL getUrl() {
+ return GitHubClient.parseURL(htmlUrl);
+ }
}
private static final String ASSIGNEES = "assignees";
- /** The owner. */
- GHRepository owner;
+ /**
+ * Gets the logins.
+ *
+ * @param users
+ * the users
+ * @return the logins
+ */
+ protected static List getLogins(Collection users) {
+ List names = new ArrayList(users.size());
+ for (GHUser a : users) {
+ names.add(a.getLogin());
+ }
+ return names;
+ }
/** The assignee. */
// API v3
@@ -73,162 +121,241 @@ public GHIssue() {
/** The assignees. */
protected GHUser[] assignees;
- /** The state. */
- protected String state;
-
- /** The state reason. */
- protected String stateReason;
-
- /** The number. */
- protected int number;
+ /** The body. */
+ @SkipFromToString
+ protected String body;
/** The closed at. */
protected String closedAt;
+ /** The closed by. */
+ protected GHUser closedBy;
+
/** The comments. */
protected int comments;
- /** The body. */
- @SkipFromToString
- protected String body;
-
/** The labels. */
protected List labels;
- /** The user. */
- protected GHUser user;
+ /** The locked. */
+ protected boolean locked;
- /** The html url. */
- protected String title, htmlUrl;
+ /** The milestone. */
+ protected GHMilestone milestone;
+
+ /** The number. */
+ protected int number;
/** The pull request. */
protected GHIssue.PullRequest pullRequest;
- /** The milestone. */
- protected GHMilestone milestone;
+ /** The state. */
+ protected String state;
- /** The closed by. */
- protected GHUser closedBy;
+ /** The state reason. */
+ protected String stateReason;
- /** The locked. */
- protected boolean locked;
+ /** The html url. */
+ protected String title, htmlUrl;
+
+ /** The user. */
+ protected GHUser user;
+
+ /** The owner. */
+ GHRepository owner;
/**
- * Wrap.
+ * Create default GHIssue instance
+ */
+ public GHIssue() {
+ }
+
+ /**
+ * Add assignees.
*
- * @param owner
- * the owner
- * @return the GH issue
+ * @param assignees
+ * the assignees
+ * @throws IOException
+ * the io exception
*/
- GHIssue wrap(GHRepository owner) {
- this.owner = owner;
- if (milestone != null)
- milestone.lateBind(owner);
- return this;
+ public void addAssignees(Collection assignees) throws IOException {
+ root().createRequest()
+ .method("POST")
+ .with(ASSIGNEES, getLogins(assignees))
+ .withUrlPath(getIssuesApiRoute() + "/assignees")
+ .fetchInto(this);
}
- private String getRepositoryUrlPath() {
- String url = getUrl().toString();
- int index = url.indexOf("/issues");
- if (index == -1) {
- index = url.indexOf("/pulls");
- }
- return url.substring(0, index);
+ /**
+ * Add assignees.
+ *
+ * @param assignees
+ * the assignees
+ * @throws IOException
+ * the io exception
+ */
+ public void addAssignees(GHUser... assignees) throws IOException {
+ addAssignees(Arrays.asList(assignees));
}
/**
- * Repository to which the issue belongs.
+ * Add labels.
*
- * @return the repository
+ * Labels that are already present on the target are ignored.
+ *
+ * @param labels
+ * the labels
+ * @return the complete list of labels including the new additions
+ * @throws IOException
+ * the io exception
*/
- @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
- public GHRepository getRepository() {
- try {
- synchronized (this) {
- if (owner == null) {
- String repositoryUrlPath = getRepositoryUrlPath();
- wrap(root().createRequest().withUrlPath(repositoryUrlPath).fetch(GHRepository.class));
- }
- }
- } catch (IOException e) {
- throw new GHException("Failed to fetch repository", e);
- }
- return owner;
+ public List addLabels(Collection labels) throws IOException {
+ return _addLabels(GHLabel.toNames(labels));
}
/**
- * The description of this pull request.
+ * Add labels.
*
- * @return the body
+ * Labels that are already present on the target are ignored.
+ *
+ * @param labels
+ * the labels
+ * @return the complete list of labels including the new additions
+ * @throws IOException
+ * the io exception
*/
- public String getBody() {
- return body;
+ public List addLabels(GHLabel... labels) throws IOException {
+ return addLabels(Arrays.asList(labels));
}
/**
- * ID.
+ * Adds labels to the issue.
*
- * @return the number
+ * Labels that are already present on the target are ignored.
+ *
+ * @param names
+ * Names of the label
+ * @return the complete list of labels including the new additions
+ * @throws IOException
+ * the io exception
*/
- public int getNumber() {
- return number;
+ public List addLabels(String... names) throws IOException {
+ return _addLabels(Arrays.asList(names));
}
/**
- * The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
+ * Assign to.
*
- * @return the html url
+ * @param user
+ * the user
+ * @throws IOException
+ * the io exception
*/
- public URL getHtmlUrl() {
- return GitHubClient.parseURL(htmlUrl);
+ public void assignTo(GHUser user) throws IOException {
+ setAssignees(user);
}
/**
- * Gets title.
+ * Closes this issue.
*
- * @return the title
+ * @throws IOException
+ * the io exception
*/
- public String getTitle() {
- return title;
+ public void close() throws IOException {
+ edit("state", "closed");
}
/**
- * Is locked boolean.
+ * Closes this issue.
*
- * @return the boolean
+ * @param reason
+ * the reason the issue was closed
+ * @throws IOException
+ * the io exception
*/
- public boolean isLocked() {
- return locked;
+ public void close(GHIssueStateReason reason) throws IOException {
+ Map map = new HashMap<>();
+ map.put("state", "closed");
+ map.put("state_reason", reason.name().toLowerCase(Locale.ENGLISH));
+ edit(map);
}
/**
- * Gets state.
+ * Updates the issue by adding a comment.
*
- * @return the state
+ * @param message
+ * the message
+ * @return Newly posted comment.
+ * @throws IOException
+ * the io exception
*/
- public GHIssueState getState() {
- return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
+ public GHIssueComment comment(String message) throws IOException {
+ GHIssueComment r = root().createRequest()
+ .method("POST")
+ .with("body", message)
+ .withUrlPath(getIssuesApiRoute() + "/comments")
+ .fetch(GHIssueComment.class);
+ return r.wrapUp(this);
}
/**
- * Gets state reason.
+ * Creates the reaction.
*
- * @return the state reason
+ * @param content
+ * the content
+ * @return the GH reaction
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
*/
- public GHIssueStateReason getStateReason() {
- return EnumUtils.getNullableEnumOrDefault(GHIssueStateReason.class, stateReason, GHIssueStateReason.UNKNOWN);
+ public GHReaction createReaction(ReactionContent content) throws IOException {
+ return root().createRequest()
+ .method("POST")
+ .with("content", content.getContent())
+ .withUrlPath(getIssuesApiRoute() + "/reactions")
+ .fetch(GHReaction.class);
}
/**
- * Gets labels.
+ * Delete reaction.
*
- * @return the labels
+ * @param reaction
+ * the reaction
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
*/
- public Collection getLabels() {
- if (labels == null) {
- return Collections.emptyList();
- }
- return Collections.unmodifiableList(labels);
+ public void deleteReaction(GHReaction reaction) throws IOException {
+ owner.root()
+ .createRequest()
+ .method("DELETE")
+ .withUrlPath(getIssuesApiRoute(), "reactions", String.valueOf(reaction.getId()))
+ .send();
+ }
+
+ /**
+ * Gets assignee.
+ *
+ * @return the assignee
+ */
+ public GHUser getAssignee() {
+ return root().intern(assignee);
+ }
+
+ /**
+ * Gets assignees.
+ *
+ * @return the assignees
+ */
+ public List getAssignees() {
+ return Collections.unmodifiableList(Arrays.asList(assignees));
+ }
+
+ /**
+ * The description of this pull request.
+ *
+ * @return the body
+ */
+ public String getBody() {
+ return body;
}
/**
@@ -242,212 +369,251 @@ public Instant getClosedAt() {
}
/**
- * Lock.
+ * Reports who has closed the issue.
*
- * @throws IOException
- * the io exception
+ *
+ * Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See
+ * https://github.com/kohsuke/github-api/issues/60.
+ *
+ * @return the closed by
*/
- public void lock() throws IOException {
- root().createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
+ public GHUser getClosedBy() {
+ if (!"closed".equals(state))
+ return null;
+
+ // TODO
+ /*
+ * if (closed_by==null) { closed_by = owner.getIssue(number).getClosed_by(); }
+ */
+ return root().intern(closedBy);
}
/**
- * Unlock.
+ * Obtains all the comments associated with this issue.
*
+ * @return the comments
* @throws IOException
* the io exception
+ * @see #listComments() #listComments()
*/
- public void unlock() throws IOException {
- root().createRequest().method("DELETE").withUrlPath(getApiRoute() + "/lock").send();
+ public List getComments() throws IOException {
+ return listComments().toList();
}
/**
- * Updates the issue by adding a comment.
+ * Gets comments count.
*
- * @param message
- * the message
- * @return Newly posted comment.
- * @throws IOException
- * the io exception
+ * @return the comments count
*/
- public GHIssueComment comment(String message) throws IOException {
- GHIssueComment r = root().createRequest()
- .method("POST")
- .with("body", message)
- .withUrlPath(getIssuesApiRoute() + "/comments")
- .fetch(GHIssueComment.class);
- return r.wrapUp(this);
+ public int getCommentsCount() {
+ return comments;
}
- private void edit(String key, Object value) throws IOException {
- root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
+ /**
+ * The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
+ *
+ * @return the html url
+ */
+ public URL getHtmlUrl() {
+ return GitHubClient.parseURL(htmlUrl);
}
- private void edit(Map map) throws IOException {
- root().createRequest().with(map).method("PATCH").withUrlPath(getApiRoute()).send();
+ /**
+ * Gets labels.
+ *
+ * @return the labels
+ */
+ public Collection getLabels() {
+ if (labels == null) {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(labels);
}
/**
- * Identical to edit(), but allows null for the value.
+ * Gets milestone.
+ *
+ * @return the milestone
*/
- private void editNullable(String key, Object value) throws IOException {
- root().createRequest().withNullable(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHMilestone getMilestone() {
+ return milestone;
}
- private void editIssue(String key, Object value) throws IOException {
- root().createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
+ /**
+ * ID.
+ *
+ * @return the number
+ */
+ public int getNumber() {
+ return number;
}
/**
- * Closes this issue.
+ * Returns non-null if this issue is a shadow of a pull request.
*
- * @throws IOException
- * the io exception
+ * @return the pull request
*/
- public void close() throws IOException {
- edit("state", "closed");
+ public PullRequest getPullRequest() {
+ return pullRequest;
}
/**
- * Closes this issue.
+ * Repository to which the issue belongs.
*
- * @param reason
- * the reason the issue was closed
- * @throws IOException
- * the io exception
+ * @return the repository
*/
- public void close(GHIssueStateReason reason) throws IOException {
- Map map = new HashMap<>();
- map.put("state", "closed");
- map.put("state_reason", reason.name().toLowerCase(Locale.ENGLISH));
- edit(map);
+ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
+ public GHRepository getRepository() {
+ try {
+ synchronized (this) {
+ if (owner == null) {
+ String repositoryUrlPath = getRepositoryUrlPath();
+ wrap(root().createRequest().withUrlPath(repositoryUrlPath).fetch(GHRepository.class));
+ }
+ }
+ } catch (IOException e) {
+ throw new GHException("Failed to fetch repository", e);
+ }
+ return owner;
+ }
+
+ /**
+ * Gets state.
+ *
+ * @return the state
+ */
+ public GHIssueState getState() {
+ return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
+ }
+
+ /**
+ * Gets state reason.
+ *
+ * @return the state reason
+ */
+ public GHIssueStateReason getStateReason() {
+ return EnumUtils.getNullableEnumOrDefault(GHIssueStateReason.class, stateReason, GHIssueStateReason.UNKNOWN);
+ }
+
+ /**
+ * Gets title.
+ *
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * User who submitted the issue.
+ *
+ * @return the user
+ */
+ public GHUser getUser() {
+ return root().intern(user);
}
/**
- * Reopens this issue.
+ * Is locked boolean.
*
- * @throws IOException
- * the io exception
+ * @return the boolean
*/
- public void reopen() throws IOException {
- edit("state", "open");
+ public boolean isLocked() {
+ return locked;
}
/**
- * Sets title.
+ * Is pull request boolean.
*
- * @param title
- * the title
- * @throws IOException
- * the io exception
+ * @return the boolean
*/
- public void setTitle(String title) throws IOException {
- edit("title", title);
+ public boolean isPullRequest() {
+ return pullRequest != null;
}
/**
- * Sets body.
+ * Obtains all the comments associated with this issue, without any filter.
*
- * @param body
- * the body
- * @throws IOException
- * the io exception
+ * @return the paged iterable
+ * @see List issue comments
+ * @see #queryComments() queryComments to apply filters.
*/
- public void setBody(String body) throws IOException {
- edit("body", body);
+ public PagedIterable listComments() {
+ return root().createRequest()
+ .withUrlPath(getIssuesApiRoute() + "/comments")
+ .toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
}
/**
- * Sets the milestone for this issue.
+ * Lists events for this issue. See https://developer.github.com/v3/issues/events/
*
- * @param milestone
- * The milestone to assign this issue to. Use null to remove the milestone for this issue.
- * @throws IOException
- * The io exception
+ * @return the paged iterable
*/
- public void setMilestone(GHMilestone milestone) throws IOException {
- if (milestone == null) {
- editIssue("milestone", null);
- } else {
- editIssue("milestone", milestone.getNumber());
- }
+ public PagedIterable listEvents() {
+ return root().createRequest()
+ .withUrlPath(getRepository().getApiTailUrl(String.format("/issues/%s/events", number)))
+ .toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));
}
/**
- * Assign to.
+ * List reactions.
*
- * @param user
- * the user
- * @throws IOException
- * the io exception
+ * @return the paged iterable
*/
- public void assignTo(GHUser user) throws IOException {
- setAssignees(user);
+ public PagedIterable listReactions() {
+ return root().createRequest()
+ .withUrlPath(getIssuesApiRoute() + "/reactions")
+ .toIterable(GHReaction[].class, null);
}
/**
- * Sets labels on the target to a specific list.
+ * Lock.
*
- * @param labels
- * the labels
* @throws IOException
* the io exception
*/
- public void setLabels(String... labels) throws IOException {
- editIssue("labels", labels);
+ public void lock() throws IOException {
+ root().createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
}
/**
- * Adds labels to the issue.
- *
- * Labels that are already present on the target are ignored.
+ * Search comments on this issue by specifying filters through a builder pattern.
*
- * @param names
- * Names of the label
- * @return the complete list of labels including the new additions
- * @throws IOException
- * the io exception
+ * @return the query builder
+ * @see List issue comments
*/
- public List addLabels(String... names) throws IOException {
- return _addLabels(Arrays.asList(names));
+ public GHIssueCommentQueryBuilder queryComments() {
+ return new GHIssueCommentQueryBuilder(this);
}
/**
- * Add labels.
- *
- * Labels that are already present on the target are ignored.
+ * Remove assignees.
*
- * @param labels
- * the labels
- * @return the complete list of labels including the new additions
+ * @param assignees
+ * the assignees
* @throws IOException
* the io exception
*/
- public List addLabels(GHLabel... labels) throws IOException {
- return addLabels(Arrays.asList(labels));
+ public void removeAssignees(Collection assignees) throws IOException {
+ root().createRequest()
+ .method("DELETE")
+ .with(ASSIGNEES, getLogins(assignees))
+ .inBody()
+ .withUrlPath(getIssuesApiRoute() + "/assignees")
+ .fetchInto(this);
}
/**
- * Add labels.
- *
- * Labels that are already present on the target are ignored.
+ * Remove assignees.
*
- * @param labels
- * the labels
- * @return the complete list of labels including the new additions
+ * @param assignees
+ * the assignees
* @throws IOException
* the io exception
*/
- public List addLabels(Collection labels) throws IOException {
- return _addLabels(GHLabel.toNames(labels));
- }
-
- private List _addLabels(Collection names) throws IOException {
- return Arrays.asList(root().createRequest()
- .with("labels", names)
- .method("POST")
- .withUrlPath(getIssuesApiRoute() + "/labels")
- .fetch(GHLabel[].class));
+ public void removeAssignees(GHUser... assignees) throws IOException {
+ removeAssignees(Arrays.asList(assignees));
}
/**
@@ -473,14 +639,14 @@ public List removeLabel(String name) throws IOException {
*
* Attempting to remove labels that are not present on the target are ignored.
*
- * @param names
- * the names
+ * @param labels
+ * the labels
* @return the remaining list of labels
* @throws IOException
* the io exception
*/
- public List removeLabels(String... names) throws IOException {
- return _removeLabels(Arrays.asList(names));
+ public List removeLabels(Collection labels) throws IOException {
+ return _removeLabels(GHLabel.toNames(labels));
}
/**
@@ -500,149 +666,28 @@ public List removeLabels(GHLabel... labels) throws IOException {
}
/**
- * Remove a collection of labels.
- *
- * Attempting to remove labels that are not present on the target are ignored.
- *
- * @param labels
- * the labels
- * @return the remaining list of labels
- * @throws IOException
- * the io exception
- */
- public List removeLabels(Collection labels) throws IOException {
- return _removeLabels(GHLabel.toNames(labels));
- }
-
- private List _removeLabels(Collection names) throws IOException {
- List remainingLabels = Collections.emptyList();
- for (String name : names) {
- try {
- remainingLabels = removeLabel(name);
- } catch (GHFileNotFoundException e) {
- // when trying to remove multiple labels, we ignore already removed
- }
- }
- return remainingLabels;
- }
-
- /**
- * Obtains all the comments associated with this issue.
- *
- * @return the comments
- * @throws IOException
- * the io exception
- * @see #listComments() #listComments()
- */
- public List