Skip to content

Commit

Permalink
fix: return GitHub no-squash commits in order
Browse files Browse the repository at this point in the history
  • Loading branch information
earl-warren committed Apr 1, 2024
1 parent 8b96538 commit e1aa36c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/service/git/github/github-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class GitHubClient implements GitClient {
}
}

return this.mapper.mapPullRequest(data as PullRequest, commits);
return this.mapper.mapPullRequest(data as PullRequest, commits.reverse());
}

async getPullRequestFromUrl(prUrl: string, squash = true): Promise<GitPullRequest> {
Expand Down
17 changes: 17 additions & 0 deletions test/service/git/github/github-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,21 @@ describe("github service", () => {
expect(res.commits).toEqual(["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"]);
});

test("get pull request no squash: success", async () => {
const res: GitPullRequest = await gitClient.getPullRequest(TARGET_OWNER, REPO, MERGED_PR_FIXTURE.number, false);
expect(res.sourceRepo).toEqual({
owner: "fork",
project: "reponame",
cloneUrl: "https://github.com/fork/reponame.git"
});
expect(res.targetRepo).toEqual({
owner: "owner",
project: "reponame",
cloneUrl: "https://github.com/owner/reponame.git"
});
expect(res.title).toBe("PR Title");
expect(res.commits!.length).toBe(2);
expect(res.commits).toEqual(["???", "???"]);
});

});

0 comments on commit e1aa36c

Please sign in to comment.