From 537f3aeb6132255688c9d04815b4a1a796fb1653 Mon Sep 17 00:00:00 2001 From: Aaron Jeske Date: Thu, 3 Jul 2025 09:44:56 -0500 Subject: [PATCH 1/3] Feature: add Git pull request iteration models and builder --- azd/pom.xml | 2 +- .../PullRequestBaseRequestBuilder.java | 9 + .../PullRequestIterationsBuilder.java | 51 ++++ .../azd/git/types/GitPullRequestChange.java | 34 +++ .../git/types/GitPullRequestIteration.java | 233 ++++++++++++++++++ .../git/types/GitPullRequestIterations.java | 20 ++ .../java/org/azd/git/types/GitStatus.java | 15 ++ .../org/azd/git/types/IterationReason.java | 26 ++ 8 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 azd/src/main/java/org/azd/git/pullrequest/PullRequestIterationsBuilder.java create mode 100644 azd/src/main/java/org/azd/git/types/GitPullRequestChange.java create mode 100644 azd/src/main/java/org/azd/git/types/GitPullRequestIteration.java create mode 100644 azd/src/main/java/org/azd/git/types/GitPullRequestIterations.java create mode 100644 azd/src/main/java/org/azd/git/types/IterationReason.java diff --git a/azd/pom.xml b/azd/pom.xml index 1cbcbad3..3bedea5a 100644 --- a/azd/pom.xml +++ b/azd/pom.xml @@ -6,7 +6,7 @@ io.github.hkarthik7 azd - 6.0.3 + 6.0.4 jar azd diff --git a/azd/src/main/java/org/azd/git/pullrequest/PullRequestBaseRequestBuilder.java b/azd/src/main/java/org/azd/git/pullrequest/PullRequestBaseRequestBuilder.java index da174bae..fa6e0f41 100644 --- a/azd/src/main/java/org/azd/git/pullrequest/PullRequestBaseRequestBuilder.java +++ b/azd/src/main/java/org/azd/git/pullrequest/PullRequestBaseRequestBuilder.java @@ -53,5 +53,14 @@ public PullRequestReviewersRequestBuilder reviewers() { public PullRequestStatusRequestBuilder statuses() { return new PullRequestStatusRequestBuilder(organizationUrl, accessTokenCredential); } + + /** + * Provides functionality to manage Pull request iterations Api. + * + * @return PullRequestIterationsBuilder {@link PullRequestIterationsBuilder} + */ + public PullRequestIterationsBuilder iterations() { + return new PullRequestIterationsBuilder(organizationUrl, accessTokenCredential); + } } diff --git a/azd/src/main/java/org/azd/git/pullrequest/PullRequestIterationsBuilder.java b/azd/src/main/java/org/azd/git/pullrequest/PullRequestIterationsBuilder.java new file mode 100644 index 00000000..c068b6d5 --- /dev/null +++ b/azd/src/main/java/org/azd/git/pullrequest/PullRequestIterationsBuilder.java @@ -0,0 +1,51 @@ +package org.azd.git.pullrequest; + +import org.azd.abstractions.BaseRequestBuilder; +import org.azd.authentication.AccessTokenCredential; +import org.azd.common.ApiVersion; +import org.azd.exceptions.AzDException; +import org.azd.git.types.GitPullRequestIteration; +import org.azd.git.types.GitPullRequestIterations; + +import java.util.concurrent.CompletableFuture; + +public class PullRequestIterationsBuilder extends BaseRequestBuilder { + + public PullRequestIterationsBuilder(String organizationUrl, AccessTokenCredential accessTokenCredential) { + super(organizationUrl, accessTokenCredential, "git", "4e080c62-fa21-4fbc-8fef-2a10a2b38049", ApiVersion.GIT); + } + + public CompletableFuture getAsync(String repositoryId, int pullRequestId, int iterationId) throws AzDException { + return builder() + .serviceEndpoint("repositoryId", repositoryId) + .serviceEndpoint("pullRequestId", pullRequestId) + .serviceEndpoint("iterationId", iterationId) + .build() + .executeAsync(GitPullRequestIteration.class); + } + + public CompletableFuture listAsync(String repositoryId, int pullRequestId) throws AzDException { + return builder() + .serviceEndpoint("repositoryId", repositoryId) + .serviceEndpoint("pullRequestId", pullRequestId) + .build() + .executeAsync(GitPullRequestIterations.class); + } + + public GitPullRequestIteration get(String repositoryId, int pullRequestId, int iterationId) throws AzDException { + return builder() + .serviceEndpoint("repositoryId", repositoryId) + .serviceEndpoint("pullRequestId", pullRequestId) + .serviceEndpoint("iterationId", iterationId) + .build() + .execute(GitPullRequestIteration.class); + } + + public GitPullRequestIterations list(String repositoryId, int pullRequestId) throws AzDException { + return builder() + .serviceEndpoint("repositoryId", repositoryId) + .serviceEndpoint("pullRequestId", pullRequestId) + .build() + .execute(GitPullRequestIterations.class); + } +} diff --git a/azd/src/main/java/org/azd/git/types/GitPullRequestChange.java b/azd/src/main/java/org/azd/git/types/GitPullRequestChange.java new file mode 100644 index 00000000..c39ce8fc --- /dev/null +++ b/azd/src/main/java/org/azd/git/types/GitPullRequestChange.java @@ -0,0 +1,34 @@ +package org.azd.git.types; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.azd.abstractions.serializer.SerializableEntity; +import org.azd.enums.VersionControlChangeType; + +public class GitPullRequestChange extends SerializableEntity { + @JsonProperty("changeId") + public int changeId; + + @JsonProperty("changeTrackingId") + public int changeTrackingId; + + @JsonProperty("changeType") + public VersionControlChangeType changeType; + + @JsonProperty("item") + public String item; + + @JsonProperty("newContent") + public ItemContent newContent; + + @JsonProperty("newContentTemplate") + public GitTemplate newContentTemplate; + + @JsonProperty("originalPath") + public String originalPath; + + @JsonProperty("sourceServerItem") + public String sourceServerItem; + + @JsonProperty("url") + public String url; +} diff --git a/azd/src/main/java/org/azd/git/types/GitPullRequestIteration.java b/azd/src/main/java/org/azd/git/types/GitPullRequestIteration.java new file mode 100644 index 00000000..2c1bb50c --- /dev/null +++ b/azd/src/main/java/org/azd/git/types/GitPullRequestIteration.java @@ -0,0 +1,233 @@ +package org.azd.git.types; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.azd.abstractions.serializer.SerializableEntity; +import org.azd.common.types.ReferenceLinks; +import org.azd.test.types.IdentityRef; + +public class GitPullRequestIteration extends SerializableEntity { + + /** + * A collection of related REST reference links.. + **/ + @JsonProperty("_links") + private ReferenceLinks links; + + /** + * Author of the pull request iteration. + **/ + @JsonProperty("author") + private IdentityRef author; + + /** + * Changes included with the pull request iteration. + */ + @JsonProperty("changeList") + private GitPullRequestChange changeList; + + /** + * The commits included with the pull request iteration. + */ + @JsonProperty("commits") + private GitCommitRef[] commits; + + /** + * The first common Git commit of the source and target refs. + */ + @JsonProperty("commonRefCommit") + private GitCommitRef commonRefCommit; + + /** + * The creation date of the pull request iteration. + **/ + @JsonProperty("createdDate") + private String createdDate; + + /** + * Description of the pull request iteration. + **/ + @JsonProperty("description") + private String description; + + /** + * Indicates if the Commits property contains a truncated list of commits in this pull request iteration. + **/ + @JsonProperty("hasMoreCommits") + private boolean hasMoreCommits; + + /** + * ID of the pull request iteration. Iterations are created as a result of creating and pushing updates to a pull request. + **/ + @JsonProperty("id") + private int id; + + /** + * If the iteration reason is Retarget, this is the refName of the new target + **/ + @JsonProperty("newTargetRefName") + private String newTargetRefName; + + /** + * If the iteration reason is Retarget, this is the original target refName + **/ + @JsonProperty("oldTargetRefName") + private String oldTargetRefName; + + /** + * The Git push information associated with this pull request iteration. + */ + @JsonProperty("push") + private GitPushRef push; + + /** + * The reason for which the pull request iteration was created. + */ + @JsonProperty("reason") + private IterationReason reason; + + /** + * The source Git commit of this iteration. + */ + @JsonProperty("sourceRefCommit") + private GitCommitRef sourceRefCommit; + + /** + * The target Git commit of this iteration. + */ + @JsonProperty("targetRefCommit") + private GitCommitRef targetRefCommit; + + /** + * The updated date of the pull request iteration. + */ + @JsonProperty("updatedDate") + private String updatedDate; + + public ReferenceLinks getLinks() { + return links; + } + + public void setLinks(ReferenceLinks links) { + this.links = links; + } + + public IdentityRef getAuthor() { + return author; + } + + public void setAuthor(IdentityRef author) { + this.author = author; + } + + public GitPullRequestChange getChangeList() { + return changeList; + } + + public void setChangeList(GitPullRequestChange changeList) { + this.changeList = changeList; + } + + public GitCommitRef[] getCommits() { + return commits; + } + + public void setCommits(GitCommitRef[] commits) { + this.commits = commits; + } + + public GitCommitRef getCommonRefCommit() { + return commonRefCommit; + } + + public void setCommonRefCommit(GitCommitRef commonRefCommit) { + this.commonRefCommit = commonRefCommit; + } + + public String getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(String createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isHasMoreCommits() { + return hasMoreCommits; + } + + public void setHasMoreCommits(boolean hasMoreCommits) { + this.hasMoreCommits = hasMoreCommits; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNewTargetRefName() { + return newTargetRefName; + } + + public void setNewTargetRefName(String newTargetRefName) { + this.newTargetRefName = newTargetRefName; + } + + public String getOldTargetRefName() { + return oldTargetRefName; + } + + public void setOldTargetRefName(String oldTargetRefName) { + this.oldTargetRefName = oldTargetRefName; + } + + public GitPushRef getPush() { + return push; + } + + public void setPush(GitPushRef push) { + this.push = push; + } + + public IterationReason getReason() { + return reason; + } + + public void setReason(IterationReason reason) { + this.reason = reason; + } + + public GitCommitRef getSourceRefCommit() { + return sourceRefCommit; + } + + public void setSourceRefCommit(GitCommitRef sourceRefCommit) { + this.sourceRefCommit = sourceRefCommit; + } + + public GitCommitRef getTargetRefCommit() { + return targetRefCommit; + } + + public void setTargetRefCommit(GitCommitRef targetRefCommit) { + this.targetRefCommit = targetRefCommit; + } + + public String getUpdatedDate() { + return updatedDate; + } + + public void setUpdatedDate(String updatedDate) { + this.updatedDate = updatedDate; + } +} diff --git a/azd/src/main/java/org/azd/git/types/GitPullRequestIterations.java b/azd/src/main/java/org/azd/git/types/GitPullRequestIterations.java new file mode 100644 index 00000000..c3f9ff63 --- /dev/null +++ b/azd/src/main/java/org/azd/git/types/GitPullRequestIterations.java @@ -0,0 +1,20 @@ +package org.azd.git.types; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.azd.abstractions.serializer.SerializableEntity; + +import java.util.List; + +public class GitPullRequestIterations extends SerializableEntity { + + @JsonProperty("value") + private List iterations; + + public List getIterations() { + return iterations; + } + + public void setIterations(List iterations) { + this.iterations = iterations; + } +} diff --git a/azd/src/main/java/org/azd/git/types/GitStatus.java b/azd/src/main/java/org/azd/git/types/GitStatus.java index 586fe32f..401f2759 100644 --- a/azd/src/main/java/org/azd/git/types/GitStatus.java +++ b/azd/src/main/java/org/azd/git/types/GitStatus.java @@ -46,6 +46,13 @@ public class GitStatus extends SerializableEntity { **/ @JsonProperty("id") private int id; + + /** + * ID of the iteration to associate status with. Minimum value is 1. + */ + @JsonProperty("iterationId") + private int iterationId; + /** * Custom properties of the status. */ @@ -146,4 +153,12 @@ public PropertiesCollection getProperties() { public void setProperties(PropertiesCollection properties) { this.properties = properties; } + + public int getIterationId() { + return iterationId; + } + + public void setIterationId(int iterationId) { + this.iterationId = iterationId; + } } diff --git a/azd/src/main/java/org/azd/git/types/IterationReason.java b/azd/src/main/java/org/azd/git/types/IterationReason.java new file mode 100644 index 00000000..d0709703 --- /dev/null +++ b/azd/src/main/java/org/azd/git/types/IterationReason.java @@ -0,0 +1,26 @@ +package org.azd.git.types; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum IterationReason { + @JsonProperty("create") + CREATE, + + @JsonProperty("forcePush") + FORCE_PUSH, + + @JsonProperty("push") + PUSH, + + @JsonProperty("rebase") + REBASE, + + @JsonProperty("resolveConflicts") + RESOLVE_CONFLICTS, + + @JsonProperty("retarget") + RETARGET, + + @JsonProperty("unkown") + UNKNOWN; +} From 585882a02815e1f72061754a50491003eb584753 Mon Sep 17 00:00:00 2001 From: Aaron Jeske Date: Thu, 3 Jul 2025 09:48:27 -0500 Subject: [PATCH 2/3] readme update --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f48811a..3d6a1a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +#6.0.4 +- Added support for Pull Request Iterations in **GitApi**. + # 6.0.3 - Fixes issues: From 0ec2e2691d2b79968726480c3dcf3c7f7e3e0f83 Mon Sep 17 00:00:00 2001 From: Aaron Jeske Date: Thu, 3 Jul 2025 10:26:13 -0500 Subject: [PATCH 3/3] readme update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6a1a3e..7314fab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -#6.0.4 +# 6.0.4 - Added support for Pull Request Iterations in **GitApi**. # 6.0.3