Skip to content

Commit

Permalink
feat: Flow through source branch metadata about the PR to the rules f…
Browse files Browse the repository at this point in the history
…unction

Signed-off-by: Yoriyasu Yano <[email protected]>
  • Loading branch information
yorinasub17 committed Oct 18, 2023
1 parent 10d506e commit 9bf6c67
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 106 deletions.
12 changes: 11 additions & 1 deletion src/engine/from_github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as nodecrypto from "crypto";
import { Octokit } from "@octokit/rest";

import { parseUnifiedDiff } from "./patch.ts";
import { IPatch, PatchOp } from "./patch_types.ts";
import { IChangeSetMetadata, IPatch, PatchOp } from "./patch_types.ts";
import { SourcePlatform } from "./from.ts";

const crypto = nodecrypto.webcrypto;
Expand All @@ -29,6 +29,7 @@ export interface IGitHubRepository {
* the sha256 hash of the URL with a random salt.
*/
export interface IGitHubPullRequestPatches {
metadata: IChangeSetMetadata;
patchList: IPatch[];
patchFetchMap: Record<string, URL>;
}
Expand All @@ -46,6 +47,12 @@ export async function patchFromGitHubPullRequest(
repo: IGitHubRepository,
prNum: number,
): Promise<IGitHubPullRequestPatches> {
const { data: pullReq } = await clt.pulls.get({
owner: repo.owner,
repo: repo.name,
pull_number: prNum,
});

const iter = clt.paginate.iterator(clt.pulls.listFiles, {
owner: repo.owner,
repo: repo.name,
Expand All @@ -61,6 +68,9 @@ export async function patchFromGitHubPullRequest(
const fetchMapSalt = hexEncode(a);

const out: IGitHubPullRequestPatches = {
metadata: {
sourceBranch: pullReq.head.ref,
},
patchList: [],
patchFetchMap: {},
};
Expand Down
Loading

0 comments on commit 9bf6c67

Please sign in to comment.