mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Follow up from https://github.com/garronej/github_actions_toolkit
This commit is contained in:
commit
5297ab00ab
54 changed files with 18162 additions and 0 deletions
55
src/tools/octokit-addons/getCommitAhead.ts
Normal file
55
src/tools/octokit-addons/getCommitAhead.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
import { getCommonOriginFactory } from "./getCommonOrigin";
|
||||
import { listCommitFactory } from "./listCommit";
|
||||
import type { Commit } from "./getCommitAsyncIterable";
|
||||
import type { Octokit } from "@octokit/rest";
|
||||
|
||||
/** Take two branch that have a common origin and list all the
|
||||
* commit that have been made on the branch that is ahead since it
|
||||
* has been forked from the branch that is behind.
|
||||
* From the older to the newest.
|
||||
* */
|
||||
export function getCommitAheadFactory(
|
||||
params: { octokit: Octokit; }
|
||||
) {
|
||||
|
||||
const { octokit } = params;
|
||||
|
||||
const { getCommonOrigin } = getCommonOriginFactory({ octokit });
|
||||
const { listCommit } = listCommitFactory({ octokit });
|
||||
|
||||
async function getCommitAhead(
|
||||
params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
branchBehind: string;
|
||||
branchAhead: string;
|
||||
}
|
||||
): Promise<{ commits: Commit[]; }> {
|
||||
|
||||
const { owner, repo, branchBehind, branchAhead } = params;
|
||||
|
||||
const { sha } = await getCommonOrigin({
|
||||
owner,
|
||||
repo,
|
||||
"branch1": branchBehind,
|
||||
"branch2": branchAhead
|
||||
});
|
||||
|
||||
const commits = await listCommit({
|
||||
owner,
|
||||
repo,
|
||||
"branch": branchAhead,
|
||||
sha
|
||||
});
|
||||
|
||||
return { commits };
|
||||
|
||||
|
||||
}
|
||||
|
||||
return { getCommitAhead };
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue