Skip to content

Commit

Permalink
Add head_reference to the PullRequest interface (#198)
Browse files Browse the repository at this point in the history
This change is a needed patch to fix [Tuleap #23048](https://tuleap.net/plugins/tracker/?aid=23048)

We are now storing the `head_reference` field into the PullRequest
interface
  • Loading branch information
Erwyn authored Sep 22, 2021
1 parent 97f9fe2 commit c1f3033
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public interface PullRequest {

String getStatus();

String getHeadReference();

GitHead getHead();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class PullRequestEntity implements PullRequest {
private final String sourceReference;
private final String destinationReference;
private final String status;
private final String headReference;
private final GitHeadEntity head;

public PullRequestEntity(
Expand All @@ -27,6 +28,7 @@ public PullRequestEntity(
@JsonProperty("reference_src") String sourceReference,
@JsonProperty("reference_dest") String destinationReference,
@JsonProperty("status") String status,
@JsonProperty("head_reference") String headReference,
@JsonProperty("head") GitHeadEntity head
) {
this.id = id;
Expand All @@ -37,6 +39,7 @@ public PullRequestEntity(
this.sourceReference = sourceReference;
this.destinationReference = destinationReference;
this.status = status;
this.headReference = headReference;
this.head = head;
}

Expand Down Expand Up @@ -80,6 +83,11 @@ public String getStatus() {
return this.status;
}

@Override
public String getHeadReference() {
return this.headReference;
}

@Override
public GitHead getHead() {
return this.head;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public void itReturnsASinglePullRequest() throws IOException {

TuleapAccessToken accessToken = this.getTuleapAccessTokenStubClass();

PullRequest expectedPullRequest = new PullRequestEntity("4", new GitRepositoryReferenceEntity("u/darwinw/repo001", 18), new GitRepositoryReferenceEntity("repo001", 4), "from-fork", "pr5","95fd78ba6238cfeac8d6a10874353130da04b1d7","10c9cddf27ee6cd2ab15b652922c9da7d8cf60fd","review", new GitHeadEntity("95fd78ba6238cfeac8d6a10874353130da04b1d7"));
PullRequest expectedPullRequest = new PullRequestEntity("4", new GitRepositoryReferenceEntity("u/darwinw/repo001", 18), new GitRepositoryReferenceEntity("repo001", 4), "from-fork", "pr5","95fd78ba6238cfeac8d6a10874353130da04b1d7","10c9cddf27ee6cd2ab15b652922c9da7d8cf60fd","review", "refs/tlpr/4/head", new GitHeadEntity("95fd78ba6238cfeac8d6a10874353130da04b1d7"));

PullRequest currentPullRequest = this.tuleapApiClient.getPullRequest("4", accessToken);

Expand All @@ -632,6 +632,7 @@ public void itReturnsASinglePullRequest() throws IOException {
assertEquals(expectedPullRequest.getSourceRepository().getId(), currentPullRequest.getSourceRepository().getId());
assertEquals(expectedPullRequest.getSourceRepository().getName(), currentPullRequest.getSourceRepository().getName());
assertEquals(expectedPullRequest.getDestinationRepository().getName(), currentPullRequest.getDestinationRepository().getName());
assertEquals(expectedPullRequest.getHeadReference(), currentPullRequest.getHeadReference());
assertEquals(expectedPullRequest.getHead().getId(), currentPullRequest.getHead().getId());
}

Expand Down

0 comments on commit c1f3033

Please sign in to comment.