Skip to content

Commit

Permalink
Support the pull request title key in GitPullRequest (#210)
Browse files Browse the repository at this point in the history
Part of [request #23441](https://tuleap.net/plugins/tracker/?aid=23441) Display the title of the PR instead of TLP-PR-<id>

This commit introduce the request

Co-authored-by: Clarck Robinson <[email protected]>
  • Loading branch information
robinsoc and Clarck Robinson authored Oct 15, 2021
1 parent ace3d21 commit a9766b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
public interface GitPullRequest {
String getId();

String getTitle();

GitRepositoryReference getSourceRepository();

GitRepositoryReference getDestinationRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class GitPullRequestEntity implements GitPullRequest {

private final String id;
private final String title;
private final GitRepositoryReference sourceRepository;
private final GitRepositoryReference destinationRepository;
private final String sourceBranch;
Expand All @@ -16,12 +17,14 @@ public class GitPullRequestEntity implements GitPullRequest {

public GitPullRequestEntity(
@JsonProperty("id") String id,
@JsonProperty("title") String title,
@JsonProperty("repository") GitRepositoryReferenceEntity sourceRepository,
@JsonProperty("repository_dest") GitRepositoryReferenceEntity destinationRepository,
@JsonProperty("branch_src") String sourceBranch,
@JsonProperty("branch_dest") String destinationBranch,
@JsonProperty("head") GitHeadEntity head) {
this.id = id;
this.title = title;
this.sourceRepository = sourceRepository;
this.destinationRepository = destinationRepository;
this.sourceBranch = sourceBranch;
Expand All @@ -34,6 +37,11 @@ public String getId() {
return this.id;
}

@Override
public String getTitle() {
return this.title;
}

@Override
public GitRepositoryReference getSourceRepository() {
return this.sourceRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ public void itReturnsThePullRequests() throws IOException {

TuleapAccessToken accessToken = this.getTuleapAccessTokenStubClass();

GitPullRequest pr1 = new GitPullRequestEntity("1", new GitRepositoryReferenceEntity("repo001", 4), new GitRepositoryReferenceEntity("repo001", 4), "pr1", "master", new GitHeadEntity("9e419faf4a8cc2614ae536e995fa0528dad44b01"));
GitPullRequest pr2 = new GitPullRequestEntity("2", new GitRepositoryReferenceEntity("u/darwinw/repo001", 18), new GitRepositoryReferenceEntity("repo001", 4), "from-fork", "pr5", new GitHeadEntity("95fd78ba6238cfeac8d6a10874353130da04b1d7"));
GitPullRequest pr1 = new GitPullRequestEntity("1","add file in pr1", new GitRepositoryReferenceEntity("repo001", 4), new GitRepositoryReferenceEntity("repo001", 4), "pr1", "master", new GitHeadEntity("9e419faf4a8cc2614ae536e995fa0528dad44b01"));
GitPullRequest pr2 = new GitPullRequestEntity("2", "new message from fork", new GitRepositoryReferenceEntity("u/darwinw/repo001", 18), new GitRepositoryReferenceEntity("repo001", 4), "from-fork", "pr5", new GitHeadEntity("95fd78ba6238cfeac8d6a10874353130da04b1d7"));

List<GitPullRequest> expectedPullRequests = ImmutableList.of(pr1,pr2);
List<GitPullRequest> currentPullRequests = this.tuleapApiClient.getPullRequests("4", accessToken);
Expand All @@ -580,6 +580,7 @@ public void itReturnsThePullRequests() throws IOException {
.orElseThrow(RuntimeException::new);

assertEquals(expectedPullRequest.getId(), pullRequest.getId());
assertEquals(expectedPullRequest.getTitle(), pullRequest.getTitle());
assertEquals(expectedPullRequest.getSourceBranch(), pullRequest.getSourceBranch());
assertEquals(expectedPullRequest.getDestinationBranch(), pullRequest.getDestinationBranch());
assertEquals(expectedPullRequest.getSourceRepository().getId(), pullRequest.getSourceRepository().getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"id": 2,
"title": "new lessage from fork",
"title": "new message from fork",
"uri": "pull_requests/4",
"repository": {
"name": "u/darwinw/repo001",
Expand Down

0 comments on commit a9766b3

Please sign in to comment.