mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-04-25 21:02:13 +00:00
30 lines
No EOL
957 B
TypeScript
30 lines
No EOL
957 B
TypeScript
import { GitPullRequest } from "@bp/service/git/git.types";
|
|
import { PullRequest, User } from "@octokit/webhooks-types";
|
|
|
|
export default class GitHubMapper {
|
|
|
|
mapPullRequest(pr: PullRequest): GitPullRequest {
|
|
return {
|
|
author: pr.user.login,
|
|
url: pr.url,
|
|
htmlUrl: pr.html_url,
|
|
title: pr.title,
|
|
body: pr.body ?? "",
|
|
state: pr.state,
|
|
merged: pr.merged ?? false,
|
|
mergedBy: pr.merged_by?.login,
|
|
reviewers: pr.requested_reviewers.filter(r => "login" in r).map((r => (r as User)?.login)),
|
|
sourceRepo: {
|
|
owner: pr.head.repo.full_name.split("/")[0],
|
|
project: pr.head.repo.full_name.split("/")[1],
|
|
cloneUrl: pr.head.repo.clone_url
|
|
},
|
|
targetRepo: {
|
|
owner: pr.base.repo.full_name.split("/")[0],
|
|
project: pr.base.repo.full_name.split("/")[1],
|
|
cloneUrl: pr.base.repo.clone_url
|
|
},
|
|
commits: [pr.merge_commit_sha as string]
|
|
};
|
|
}
|
|
} |