Context7 Platform -- Up-to-date docs for AI agents
fix(cli): recover Scoop Git Bash library IDs (#3085)
Fahreddin Özcan3abc99a5cfb9
diff --git a/.changeset/cli-scoop-git-bash-path.md b/.changeset/cli-scoop-git-bash-path.mdnew file mode 100644index 00000000..1de242b9--- /dev/null+++ b/.changeset/cli-scoop-git-bash-path.md@@ -0,0 +1,5 @@+---+"ctx7": patch+---++Recover library IDs mangled by Git Bash when Git is installed through Scoop.diff --git a/packages/cli/src/__tests__/library-id.test.ts b/packages/cli/src/__tests__/library-id.test.tsindex 13f75d2e..acce79c1 100644--- a/packages/cli/src/__tests__/library-id.test.ts+++ b/packages/cli/src/__tests__/library-id.test.ts@@ -26,6 +26,21 @@ describe("recoverLibraryId", () => {expect(recoverLibraryId("D:/tools/PortableGit/facebook/react")).toBe("/facebook/react");});+ test("recovers from a versioned Scoop Git install", () => {+ expect(recoverLibraryId("D:/Scoop/apps/git/2.54.0/vercel/next.js")).toBe("/vercel/next.js");+ expect(recoverLibraryId("D:\\Scoop\\apps\\git\\2.54.0.windows.1\\vercel\\next.js")).toBe(+ "/vercel/next.js"+ );+ });++ test("recovers from an unresolved Scoop current junction", () => {+ expect(recoverLibraryId("D:/Scoop/apps/git/current/vercel/next.js")).toBe("/vercel/next.js");+ });++ test("does not treat a version-like owner in a standard Git install as a Scoop version", () => {+ expect(recoverLibraryId("C:/Program Files/Git/2.54.0/vercel")).toBe("/2.54.0/vercel");+ });+test("recovers an owner that looks like a system dir", () => {expect(recoverLibraryId("C:/Program Files/Git/usr/some-repo")).toBe("/usr/some-repo");});diff --git a/packages/cli/src/utils/library-id.ts b/packages/cli/src/utils/library-id.tsindex f189d748..757d58a2 100644--- a/packages/cli/src/utils/library-id.ts+++ b/packages/cli/src/utils/library-id.ts@@ -17,6 +17,14 @@ export function recoverLibraryId(input: string): string {// Strip the Git install dir, keeping the "/owner/repo[/version]" tail.const normalized = input.replace(/\\/g, "/");++ // Scoop installs Git under apps/git/<version> with a "current" junction.+ // Discard either form before recovering the library ID.+ const scoopMatch = normalized.match(+ /^[A-Za-z]:\/.*\/apps\/git\/(?:v?\d+(?:\.\d+)+[^/]*|current)\/(.+)$/i+ );+ if (scoopMatch) return `/${scoopMatch[1]}`;+const match = normalized.match(/^[A-Za-z]:\/.*?\/(?:Git|PortableGit|git-bash)\/(.+)$/i);return match ? `/${match[1]}` : input;}