@catamorphic/git 0.0.0-stage → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -0
- package/NOTICE.txt +32 -0
- package/dist/checkout-remote-backend.d.ts +12 -0
- package/dist/checkout-remote-backend.d.ts.map +1 -0
- package/dist/file-reads.d.ts +15 -0
- package/dist/file-reads.d.ts.map +1 -0
- package/dist/fs-backend.d.ts +30 -0
- package/dist/fs-backend.d.ts.map +1 -0
- package/dist/fs-remote-backend.d.ts +47 -0
- package/dist/fs-remote-backend.d.ts.map +1 -0
- package/dist/git-object-codec.d.ts +31 -0
- package/dist/git-object-codec.d.ts.map +1 -0
- package/dist/git-sync.d.ts +61 -0
- package/dist/git-sync.d.ts.map +1 -0
- package/dist/in-memory-object-store.d.ts +23 -0
- package/dist/in-memory-object-store.d.ts.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4746 -0
- package/dist/index.js.map +32 -0
- package/dist/migrate-workflow.d.ts +12 -0
- package/dist/migrate-workflow.d.ts.map +1 -0
- package/dist/native-git.d.ts +25 -0
- package/dist/native-git.d.ts.map +1 -0
- package/dist/native-project-repo.d.ts +57 -0
- package/dist/native-project-repo.d.ts.map +1 -0
- package/dist/network-sync.d.ts +58 -0
- package/dist/network-sync.d.ts.map +1 -0
- package/dist/network.d.ts +81 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/object-remote-backend.d.ts +95 -0
- package/dist/object-remote-backend.d.ts.map +1 -0
- package/dist/object-store.d.ts +42 -0
- package/dist/object-store.d.ts.map +1 -0
- package/dist/origin-draft.d.ts +264 -0
- package/dist/origin-draft.d.ts.map +1 -0
- package/dist/origin-objects.d.ts +201 -0
- package/dist/origin-objects.d.ts.map +1 -0
- package/dist/personal-files.d.ts +6 -0
- package/dist/personal-files.d.ts.map +1 -0
- package/dist/project-manager.d.ts +214 -0
- package/dist/project-manager.d.ts.map +1 -0
- package/dist/project-repo.d.ts +79 -0
- package/dist/project-repo.d.ts.map +1 -0
- package/dist/ref-moved-error.d.ts +13 -0
- package/dist/ref-moved-error.d.ts.map +1 -0
- package/dist/ref-names.d.ts +18 -0
- package/dist/ref-names.d.ts.map +1 -0
- package/dist/types.d.ts +276 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workspace-mirror.d.ts +110 -0
- package/dist/workspace-mirror.d.ts.map +1 -0
- package/package.json +53 -4
- package/src/checkout-remote-backend.ts +154 -0
- package/src/diff3.d.ts +16 -0
- package/src/file-reads.ts +53 -0
- package/src/fs-backend.ts +206 -0
- package/src/fs-remote-backend.ts +252 -0
- package/src/git-object-codec.ts +87 -0
- package/src/git-sync.ts +539 -0
- package/src/in-memory-object-store.ts +60 -0
- package/src/index.ts +110 -0
- package/src/migrate-workflow.ts +30 -0
- package/src/native-git.ts +177 -0
- package/src/native-project-repo.ts +515 -0
- package/src/network-sync.ts +239 -0
- package/src/network.ts +269 -0
- package/src/object-remote-backend.ts +366 -0
- package/src/object-store.ts +41 -0
- package/src/origin-draft.ts +1033 -0
- package/src/origin-objects.ts +906 -0
- package/src/personal-files.ts +57 -0
- package/src/project-manager.ts +743 -0
- package/src/project-repo.ts +800 -0
- package/src/ref-moved-error.ts +18 -0
- package/src/ref-names.ts +47 -0
- package/src/types.ts +289 -0
- package/src/workspace-mirror.ts +400 -0
- package/README.md +0 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
isProjectPathWithin,
|
|
5
|
+
PROJECT_PERSONAL_DIR,
|
|
6
|
+
} from "@catamorphic/workflow/project-layout";
|
|
7
|
+
|
|
8
|
+
export function isPersonalFile(filePath: string): boolean {
|
|
9
|
+
const normalized = path.posix.normalize(filePath.replaceAll("\\", "/"));
|
|
10
|
+
return isProjectPathWithin(normalized, PROJECT_PERSONAL_DIR);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Also protects native git add/checkpoint operations, including linked worktrees. */
|
|
14
|
+
export async function ensurePersonalFilesExcluded({
|
|
15
|
+
repoPath,
|
|
16
|
+
}: {
|
|
17
|
+
repoPath: string;
|
|
18
|
+
}): Promise<void> {
|
|
19
|
+
const dotGit = path.join(repoPath, ".git");
|
|
20
|
+
const entry = await fs.stat(dotGit).catch((error: unknown) => {
|
|
21
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
22
|
+
return null;
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
if (!entry) return;
|
|
26
|
+
const gitDir = entry.isDirectory()
|
|
27
|
+
? dotGit
|
|
28
|
+
: path.resolve(
|
|
29
|
+
repoPath,
|
|
30
|
+
(await fs.readFile(dotGit, "utf8")).trim().replace(/^gitdir:\s*/, ""),
|
|
31
|
+
);
|
|
32
|
+
const common = await fs
|
|
33
|
+
.readFile(path.join(gitDir, "commondir"), "utf8")
|
|
34
|
+
.catch((error: unknown) => {
|
|
35
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
36
|
+
return "";
|
|
37
|
+
throw error;
|
|
38
|
+
});
|
|
39
|
+
const commonDir = common.trim()
|
|
40
|
+
? path.resolve(gitDir, common.trim())
|
|
41
|
+
: gitDir;
|
|
42
|
+
const excludePath = path.join(commonDir, "info", "exclude");
|
|
43
|
+
const current = await fs
|
|
44
|
+
.readFile(excludePath, "utf8")
|
|
45
|
+
.catch((error: unknown) => {
|
|
46
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
47
|
+
return "";
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
const rule = `/${PROJECT_PERSONAL_DIR}/`;
|
|
51
|
+
if (current.split(/\r?\n/).includes(rule)) return;
|
|
52
|
+
await fs.mkdir(path.dirname(excludePath), { recursive: true });
|
|
53
|
+
await fs.appendFile(
|
|
54
|
+
excludePath,
|
|
55
|
+
`${current && !current.endsWith("\n") ? "\n" : ""}${rule}\n`,
|
|
56
|
+
);
|
|
57
|
+
}
|