Skip to content

Commit

Permalink
feat(git): allow additional args on gitDiff and getSHA1FromRef (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdostie authored Dec 3, 2024
1 parent 115c7d5 commit 504db98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/git/doGitDiff.ts
Original file line number Diff line number Diff line change
@@ -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<string[]> {
return (
await spawn("git", ["--no-pager", "diff", "--name-only"], gitLogger)
await spawn(
"git",
["--no-pager", "diff", "--name-only", ...args],
gitLogger,
)
).stdout
.trim()
.split("\n");
Expand Down
9 changes: 7 additions & 2 deletions src/git/getSHA1FromRef.ts
Original file line number Diff line number Diff line change
@@ -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<string> {
return (
await spawn("git", ["rev-parse", ...args, ref], gitLogger)
).stdout.trim();
}

0 comments on commit 504db98

Please sign in to comment.