From 3b19e95b53aa12cc108a3bc4c43a0ddcfb8ae6f3 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 30 Sep 2024 22:16:38 +0000 Subject: [PATCH] wiring up globlas --- packages/core/src/git.ts | 26 ++++++++++++++++++++++++++ packages/core/src/globals.ts | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 packages/core/src/git.ts diff --git a/packages/core/src/git.ts b/packages/core/src/git.ts new file mode 100644 index 0000000000..98c2454d68 --- /dev/null +++ b/packages/core/src/git.ts @@ -0,0 +1,26 @@ +import { runtimeHost } from "./host" + +export class GitClient implements Git { + async selectModifiedFiles( + scope: "branch" | "staged" | "modified", + options?: { + endsWith?: ElementOrArray + glob?: ElementOrArray + } + ): Promise { + let args: string[] = [] + switch (scope) { + case "branch": { + } + case "staged": { + args = ["diff", "--cached", "--name-only", "--diff-filter=AM"] + break + } + case "modified": { + args = ["diff", "--name-only", "--diff-filter=AM"] + break + } + } + return undefined + } +} diff --git a/packages/core/src/globals.ts b/packages/core/src/globals.ts index b15dd90df6..7898a7e673 100644 --- a/packages/core/src/globals.ts +++ b/packages/core/src/globals.ts @@ -15,6 +15,7 @@ import { createFetch } from "./fetch" import { readText } from "./fs" import { logVerbose } from "./util" import { GitHubClient } from "./github" +import { GitClient } from "./git" /** * Resolves the global context depending on the environment. @@ -107,6 +108,8 @@ export function installGlobals() { glb.github = new GitHubClient() + glb.git = new GitClient() + /** * Asynchronous function to fetch text from a URL or file. * Handles both HTTP(S) URLs and local workspace files.