mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-07-18 04:28:24 +02:00
feat(issue-54): backport pr commits without squash (#55)
* feat(issue-54): backport pr commits without squash fix https://github.com/kiegroup/git-backporting/issues/54 * feat(issue-54): fixed readme
This commit is contained in:
parent
a737aa7c4c
commit
c4dbb26c1d
29 changed files with 990 additions and 145 deletions
|
@ -13,7 +13,7 @@ export default class GitHubMapper implements GitResponseMapper<PullRequest, "ope
|
|||
}
|
||||
}
|
||||
|
||||
async mapPullRequest(pr: PullRequest): Promise<GitPullRequest> {
|
||||
async mapPullRequest(pr: PullRequest, commits?: string[]): Promise<GitPullRequest> {
|
||||
return {
|
||||
number: pr.number,
|
||||
author: pr.user.login,
|
||||
|
@ -30,11 +30,16 @@ export default class GitHubMapper implements GitResponseMapper<PullRequest, "ope
|
|||
sourceRepo: await this.mapSourceRepo(pr),
|
||||
targetRepo: await this.mapTargetRepo(pr),
|
||||
nCommits: pr.commits,
|
||||
// if pr is open use latest commit sha otherwise use merge_commit_sha
|
||||
commits: pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha as string]
|
||||
// if commits is provided use them, otherwise fetch the single sha representing the whole pr
|
||||
commits: (commits && commits.length > 0) ? commits : this.getSha(pr),
|
||||
};
|
||||
}
|
||||
|
||||
private getSha(pr: PullRequest) {
|
||||
// if pr is open use latest commit sha otherwise use merge_commit_sha
|
||||
return pr.state === "open" ? [pr.head.sha] : [pr.merge_commit_sha as string];
|
||||
}
|
||||
|
||||
async mapSourceRepo(pr: PullRequest): Promise<GitRepository> {
|
||||
return Promise.resolve({
|
||||
owner: pr.head.repo.full_name.split("/")[0],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue