From 504db98e546bc4776c36197abebead7aa9ec4184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Dostie?= <35579930+gdostie@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:51:03 -0500 Subject: [PATCH] feat(git): allow additional args on gitDiff and getSHA1FromRef (#277) --- src/git/doGitDiff.ts | 8 ++++++-- src/git/getSHA1FromRef.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/git/doGitDiff.ts b/src/git/doGitDiff.ts index 8281a24f..ac039cd8 100644 --- a/src/git/doGitDiff.ts +++ b/src/git/doGitDiff.ts @@ -1,9 +1,13 @@ import spawn from "../utils/spawn.js"; import gitLogger from "./utils/gitLogger.js"; -export default async function gitDiff() { +export default async function gitDiff(args: string[] = []): Promise { return ( - await spawn("git", ["--no-pager", "diff", "--name-only"], gitLogger) + await spawn( + "git", + ["--no-pager", "diff", "--name-only", ...args], + gitLogger, + ) ).stdout .trim() .split("\n"); diff --git a/src/git/getSHA1FromRef.ts b/src/git/getSHA1FromRef.ts index f92ffcf5..36e05c96 100644 --- a/src/git/getSHA1FromRef.ts +++ b/src/git/getSHA1FromRef.ts @@ -1,6 +1,11 @@ import spawn from "../utils/spawn.js"; import gitLogger from "./utils/gitLogger.js"; -export default async function (ref: string) { - return (await spawn("git", ["rev-parse", ref], gitLogger)).stdout.trim(); +export default async function ( + ref: string, + args: string[] = [], +): Promise { + return ( + await spawn("git", ["rev-parse", ...args, ref], gitLogger) + ).stdout.trim(); }