@ligeti/step-git-worktree 0.0.0-stage → 2.0.3
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 +201 -0
- package/README.md +539 -2
- package/dist/fast-forward.d.ts +23 -0
- package/dist/fast-forward.d.ts.map +1 -0
- package/dist/fast-forward.js +126 -0
- package/dist/fast-forward.js.map +1 -0
- package/dist/git-dir-file.d.ts +34 -0
- package/dist/git-dir-file.d.ts.map +1 -0
- package/dist/git-dir-file.js +108 -0
- package/dist/git-dir-file.js.map +1 -0
- package/dist/git-exec.d.ts +33 -0
- package/dist/git-exec.d.ts.map +1 -0
- package/dist/git-exec.js +214 -0
- package/dist/git-exec.js.map +1 -0
- package/dist/head-commit.d.ts +17 -0
- package/dist/head-commit.d.ts.map +1 -0
- package/dist/head-commit.js +65 -0
- package/dist/head-commit.js.map +1 -0
- package/dist/herdr.d.ts +21 -0
- package/dist/herdr.d.ts.map +1 -0
- package/dist/herdr.js +175 -0
- package/dist/herdr.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +48 -0
- package/dist/paths.js.map +1 -0
- package/dist/push.d.ts +9 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +205 -0
- package/dist/push.js.map +1 -0
- package/dist/rebase.d.ts +45 -0
- package/dist/rebase.d.ts.map +1 -0
- package/dist/rebase.js +340 -0
- package/dist/rebase.js.map +1 -0
- package/dist/remote-url.d.ts +17 -0
- package/dist/remote-url.d.ts.map +1 -0
- package/dist/remote-url.js +54 -0
- package/dist/remote-url.js.map +1 -0
- package/dist/remove-file.d.ts +23 -0
- package/dist/remove-file.d.ts.map +1 -0
- package/dist/remove-file.js +95 -0
- package/dist/remove-file.js.map +1 -0
- package/dist/settings.d.ts +7 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +26 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-file.d.ts +20 -0
- package/dist/show-file.d.ts.map +1 -0
- package/dist/show-file.js +88 -0
- package/dist/show-file.js.map +1 -0
- package/dist/start-branch.d.ts +31 -0
- package/dist/start-branch.d.ts.map +1 -0
- package/dist/start-branch.js +168 -0
- package/dist/start-branch.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +86 -0
- package/dist/types.js.map +1 -0
- package/dist/worktree.d.ts +5 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +124 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +26 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// ABOUTME: git.show-file, the plain step that reads a file's content at a given commit from a worktree's
|
|
2
|
+
// ABOUTME: repository, reporting a file that does not exist at that commit as null rather than throwing.
|
|
3
|
+
import { defineStep, z } from "@ligeti/sdk";
|
|
4
|
+
import pkg from "../package.json" with { type: "json" };
|
|
5
|
+
import { buildGitEnv, GitCommandError, QUICK_GIT_TIMEOUT_MS, runGit, GIT_ENV_VARS, } from "./git-exec.js";
|
|
6
|
+
import { CommitSha } from "./types.js";
|
|
7
|
+
export function isSafeRepoRelativePath(candidate) {
|
|
8
|
+
if (candidate.startsWith("/") || candidate.includes("\0") || candidate.includes("\\")) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return candidate.split("/").every((segment) => segment !== ".." && segment !== ".");
|
|
12
|
+
}
|
|
13
|
+
export const GitShowFileInput = z.object({
|
|
14
|
+
worktreePath: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.describe("Absolute path of the git working tree whose repository holds the commit."),
|
|
18
|
+
commit: CommitSha.describe("The commit to read the file from."),
|
|
19
|
+
path: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.refine(isSafeRepoRelativePath, {
|
|
23
|
+
message: 'must be a repo-relative path: not absolute, no ".." or "." segments, no backslash',
|
|
24
|
+
})
|
|
25
|
+
.describe("The file's path relative to the repository root."),
|
|
26
|
+
});
|
|
27
|
+
export const GitShowFileOutput = z.object({
|
|
28
|
+
content: z
|
|
29
|
+
.string()
|
|
30
|
+
.nullable()
|
|
31
|
+
.describe("The file's content at `commit`, or null when the file does not exist there."),
|
|
32
|
+
});
|
|
33
|
+
export const gitShowFile = defineStep({
|
|
34
|
+
name: "git.show-file",
|
|
35
|
+
envVars: GIT_ENV_VARS,
|
|
36
|
+
description: "Reads a file's content at a given commit, or null when the file does not exist at that commit.",
|
|
37
|
+
package: { name: pkg.name, version: pkg.version },
|
|
38
|
+
input: GitShowFileInput,
|
|
39
|
+
output: GitShowFileOutput,
|
|
40
|
+
retry: { maxAttempts: 3 },
|
|
41
|
+
async run(sctx, input) {
|
|
42
|
+
const { worktreePath, commit, path } = input;
|
|
43
|
+
const env = buildGitEnv(sctx.logger);
|
|
44
|
+
const options = { env, timeoutMs: QUICK_GIT_TIMEOUT_MS, signal: sctx.signal };
|
|
45
|
+
const fail = (what, err) => {
|
|
46
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
47
|
+
return new Error(`git.show-file: ${what} in "${worktreePath}": ${detail}`, { cause: err });
|
|
48
|
+
};
|
|
49
|
+
const rethrowAbort = (err) => {
|
|
50
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
await runGit(["-C", worktreePath, "cat-file", "-e", `${commit}^{commit}`], options);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
rethrowAbort(err);
|
|
59
|
+
throw fail(`commit ${commit} is not available`, err);
|
|
60
|
+
}
|
|
61
|
+
let objectId;
|
|
62
|
+
try {
|
|
63
|
+
const { stdout } = await runGit(["-C", worktreePath, "rev-parse", "--verify", "--quiet", `${commit}:${path}`], options);
|
|
64
|
+
objectId = stdout.trim();
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
rethrowAbort(err);
|
|
68
|
+
if (err instanceof GitCommandError && err.exitCode === 1) {
|
|
69
|
+
sctx.logger.info("git.show-file: file absent", { worktreePath, commit, path });
|
|
70
|
+
return { content: null };
|
|
71
|
+
}
|
|
72
|
+
throw fail(`failed to look up "${path}" at ${commit}`, err);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const { stdout: objectType } = await runGit(["-C", worktreePath, "cat-file", "-t", objectId], options);
|
|
76
|
+
if (objectType.trim() !== "blob") {
|
|
77
|
+
throw new Error(`"${path}" at ${commit} is a ${objectType.trim()}, not a file`);
|
|
78
|
+
}
|
|
79
|
+
const { stdout } = await runGit(["-C", worktreePath, "show", `${commit}:${path}`], options);
|
|
80
|
+
return { content: stdout };
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
rethrowAbort(err);
|
|
84
|
+
throw fail(`failed to read "${path}" at ${commit}`, err);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=show-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-file.js","sourceRoot":"","sources":["../src/show-file.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,yGAAyG;AACzG,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxD,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,MAAM,EACN,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,UAAU,sBAAsB,CAAC,SAAiB;IACtD,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,QAAQ,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CAAC;QAC3D,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "@ligeti/sdk";
|
|
2
|
+
export declare const GitStartBranchInput: z.ZodObject<{
|
|
3
|
+
worktreePath: z.ZodString;
|
|
4
|
+
branch: z.ZodString;
|
|
5
|
+
from: z.ZodString;
|
|
6
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
7
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
continueFromBranch: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
discardChanges: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type GitStartBranchInput = z.infer<typeof GitStartBranchInput>;
|
|
12
|
+
export declare const GitStartBranchOutput: z.ZodObject<{
|
|
13
|
+
branch: z.ZodString;
|
|
14
|
+
commit: z.ZodString;
|
|
15
|
+
continued: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type GitStartBranchOutput = z.infer<typeof GitStartBranchOutput>;
|
|
18
|
+
export declare const gitStartBranch: import("@ligeti/sdk").StepDefinition<z.ZodObject<{
|
|
19
|
+
worktreePath: z.ZodString;
|
|
20
|
+
branch: z.ZodString;
|
|
21
|
+
from: z.ZodString;
|
|
22
|
+
remote: z.ZodDefault<z.ZodString>;
|
|
23
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
continueFromBranch: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
discardChanges: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
branch: z.ZodString;
|
|
28
|
+
commit: z.ZodString;
|
|
29
|
+
continued: z.ZodBoolean;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
//# sourceMappingURL=start-branch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-branch.d.ts","sourceRoot":"","sources":["../src/start-branch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,CAAC,EAAE,MAAM,aAAa,CAAC;AAe5C,eAAO,MAAM,mBAAmB;;;;;;;;iBA+B9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB;;;;iBAS/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,cAAc;;;;;;;;;;;;kBA4JzB,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// ABOUTME: git.start-branch, the plain step that creates (or resets) a local branch from a remote
|
|
2
|
+
// ABOUTME: branch's current tip, so a workflow starts each plan step from the spec branch as GitLab has it.
|
|
3
|
+
import { defineStep, z } from "@ligeti/sdk";
|
|
4
|
+
import pkg from "../package.json" with { type: "json" };
|
|
5
|
+
import { buildGitEnv, fetchArgs, discardDirtyWorktree, GitCommandError, QUICK_GIT_TIMEOUT_MS, runGit, GIT_ENV_VARS, } from "./git-exec.js";
|
|
6
|
+
import { branchNameSchema } from "./types.js";
|
|
7
|
+
const DEFAULT_FETCH_TIMEOUT_SECONDS = 300;
|
|
8
|
+
export const GitStartBranchInput = z.object({
|
|
9
|
+
worktreePath: z
|
|
10
|
+
.string()
|
|
11
|
+
.min(1)
|
|
12
|
+
.describe("Absolute path of the git working tree to start the branch in."),
|
|
13
|
+
branch: branchNameSchema("The local branch to create (or reset), from refs/remotes/<remote>/<from>."),
|
|
14
|
+
from: branchNameSchema("The remote branch to start from, as it currently is on remote."),
|
|
15
|
+
remote: z.string().min(1).default("origin").describe("The git remote to fetch from."),
|
|
16
|
+
timeoutSeconds: z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.positive()
|
|
20
|
+
.default(DEFAULT_FETCH_TIMEOUT_SECONDS)
|
|
21
|
+
.describe("Bounds the git fetch. Defaults to 300 (5 minutes)."),
|
|
22
|
+
continueFromBranch: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.default(false)
|
|
25
|
+
.describe("When true and `branch` already exists on `remote`, start from that remote branch's tip " +
|
|
26
|
+
"instead of from `from`, so a re-run keeps the work an earlier run pushed. When `branch` " +
|
|
27
|
+
"is not on `remote`, start from `from` as usual. Defaults to false."),
|
|
28
|
+
discardChanges: z
|
|
29
|
+
.boolean()
|
|
30
|
+
.default(false)
|
|
31
|
+
.describe("When true, a dirty worktree is discarded (git reset --hard, then git clean -fd) instead " +
|
|
32
|
+
"of failing the step. Defaults to false, which keeps the throw."),
|
|
33
|
+
});
|
|
34
|
+
export const GitStartBranchOutput = z.object({
|
|
35
|
+
branch: z.string(),
|
|
36
|
+
commit: z.string().describe("The SHA of the new branch's tip, after switching."),
|
|
37
|
+
continued: z
|
|
38
|
+
.boolean()
|
|
39
|
+
.describe("True when the branch was started from its own remote branch (continueFromBranch was set " +
|
|
40
|
+
"and the remote had it), false when it was started from `from`."),
|
|
41
|
+
});
|
|
42
|
+
export const gitStartBranch = defineStep({
|
|
43
|
+
name: "git.start-branch",
|
|
44
|
+
envVars: GIT_ENV_VARS,
|
|
45
|
+
description: "Creates (or resets) a local branch at a remote branch's current tip, so a workflow starts each " +
|
|
46
|
+
"unit of work from that branch as the remote currently has it, deterministically.",
|
|
47
|
+
package: { name: pkg.name, version: pkg.version },
|
|
48
|
+
input: GitStartBranchInput,
|
|
49
|
+
output: GitStartBranchOutput,
|
|
50
|
+
retry: { maxAttempts: 3 },
|
|
51
|
+
async run(sctx, input) {
|
|
52
|
+
const { worktreePath, branch, from, remote, timeoutSeconds, discardChanges } = input;
|
|
53
|
+
const { continueFromBranch } = input;
|
|
54
|
+
const env = buildGitEnv(sctx.logger);
|
|
55
|
+
sctx.logger.info("git.start-branch: fetching", { worktreePath, remote, from, timeoutSeconds });
|
|
56
|
+
const refspec = `+refs/heads/${from}:refs/remotes/${remote}/${from}`;
|
|
57
|
+
try {
|
|
58
|
+
await runGit(fetchArgs(worktreePath, remote, refspec), {
|
|
59
|
+
env,
|
|
60
|
+
timeoutMs: timeoutSeconds * 1000,
|
|
61
|
+
signal: sctx.signal,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
const detail = err instanceof GitCommandError && err.timedOut
|
|
69
|
+
? `timed out after ${String(timeoutSeconds)}s (signal ${String(err.signal)})`
|
|
70
|
+
: err instanceof Error
|
|
71
|
+
? err.message
|
|
72
|
+
: String(err);
|
|
73
|
+
throw new Error(`git.start-branch: "git fetch ${remote} ${refspec}" failed in "${worktreePath}": ${detail}`, { cause: err });
|
|
74
|
+
}
|
|
75
|
+
let continued = false;
|
|
76
|
+
if (continueFromBranch) {
|
|
77
|
+
const branchRefspec = `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`;
|
|
78
|
+
try {
|
|
79
|
+
await runGit(fetchArgs(worktreePath, remote, branchRefspec), {
|
|
80
|
+
env,
|
|
81
|
+
timeoutMs: timeoutSeconds * 1000,
|
|
82
|
+
signal: sctx.signal,
|
|
83
|
+
});
|
|
84
|
+
continued = true;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
const timedOut = err instanceof GitCommandError && err.timedOut;
|
|
91
|
+
const detail = timedOut
|
|
92
|
+
? `timed out after ${String(timeoutSeconds)}s (signal ${String(err.signal)})`
|
|
93
|
+
: err instanceof Error
|
|
94
|
+
? err.message
|
|
95
|
+
: String(err);
|
|
96
|
+
if (timedOut || !/couldn't find remote ref/i.test(detail)) {
|
|
97
|
+
throw new Error(`git.start-branch: "git fetch ${remote} ${branchRefspec}" failed in "${worktreePath}": ${detail}`, { cause: err });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const startRef = `refs/remotes/${remote}/${continued ? branch : from}`;
|
|
102
|
+
let statusOutput;
|
|
103
|
+
try {
|
|
104
|
+
const { stdout } = await runGit(["-C", worktreePath, "status", "--porcelain"], {
|
|
105
|
+
env,
|
|
106
|
+
timeoutMs: QUICK_GIT_TIMEOUT_MS,
|
|
107
|
+
signal: sctx.signal,
|
|
108
|
+
});
|
|
109
|
+
statusOutput = stdout;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
116
|
+
throw new Error(`git.start-branch: failed to check "${worktreePath}" for a clean worktree: ${detail}`, { cause: err });
|
|
117
|
+
}
|
|
118
|
+
if (statusOutput.trim().length > 0) {
|
|
119
|
+
if (!discardChanges) {
|
|
120
|
+
throw new Error(`git.start-branch: "${worktreePath}" has uncommitted changes (including possibly ` +
|
|
121
|
+
`untracked files) -- refusing to switch onto "${branch}":\n${statusOutput}`);
|
|
122
|
+
}
|
|
123
|
+
await discardDirtyWorktree(worktreePath, statusOutput, env, sctx.signal, sctx.logger, "git.start-branch");
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
await runGit(["-C", worktreePath, "switch", "-C", branch, startRef], {
|
|
127
|
+
env,
|
|
128
|
+
timeoutMs: QUICK_GIT_TIMEOUT_MS,
|
|
129
|
+
signal: sctx.signal,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
137
|
+
throw new Error(`git.start-branch: "git switch -C ${branch} ${startRef}" failed in ` +
|
|
138
|
+
`"${worktreePath}": ${detail}`, { cause: err });
|
|
139
|
+
}
|
|
140
|
+
let commit;
|
|
141
|
+
try {
|
|
142
|
+
const { stdout } = await runGit(["-C", worktreePath, "rev-parse", "HEAD"], {
|
|
143
|
+
env,
|
|
144
|
+
timeoutMs: QUICK_GIT_TIMEOUT_MS,
|
|
145
|
+
signal: sctx.signal,
|
|
146
|
+
});
|
|
147
|
+
commit = stdout.trim();
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
154
|
+
throw new Error(`git.start-branch: failed to resolve HEAD in "${worktreePath}" after switching to ` +
|
|
155
|
+
`"${branch}": ${detail}`, { cause: err });
|
|
156
|
+
}
|
|
157
|
+
sctx.logger.info("git.start-branch: started", {
|
|
158
|
+
worktreePath,
|
|
159
|
+
remote,
|
|
160
|
+
from,
|
|
161
|
+
branch,
|
|
162
|
+
commit,
|
|
163
|
+
continued,
|
|
164
|
+
});
|
|
165
|
+
return { branch, commit, continued };
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
//# sourceMappingURL=start-branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-branch.js","sourceRoot":"","sources":["../src/start-branch.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,4GAA4G;AAC5G,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxD,OAAO,EACL,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,MAAM,EACN,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAE1C,MAAM,CAAC,M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,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChE,MAAM,IAAI,KAAK,CACb,gDAAgD,YAAY,uBAAuB;gBACjF,IAAI,MAAM,MAAM,MAAM,EAAE,EAC1B,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;YAC5C,YAAY;YACZ,MAAM;YACN,IAAI;YACJ,MAAM;YACN,MAAM;YACN,SAAS;SACV,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "@ligeti/sdk";
|
|
2
|
+
export declare const SAFE_BRANCH_NAME_MESSAGE: string;
|
|
3
|
+
export declare function isSafeBranchName(name: string): boolean;
|
|
4
|
+
export declare const branchNameSchema: (describe: string) => z.ZodString;
|
|
5
|
+
export declare const GitWorktreeInput: z.ZodObject<{
|
|
6
|
+
repoPath: z.ZodString;
|
|
7
|
+
worktreeName: z.ZodString;
|
|
8
|
+
branchName: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type GitWorktreeInput = z.infer<typeof GitWorktreeInput>;
|
|
11
|
+
export declare const GitWorktreeOutput: z.ZodObject<{
|
|
12
|
+
repoPath: z.ZodString;
|
|
13
|
+
worktreePath: z.ZodString;
|
|
14
|
+
branchName: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type GitWorktreeOutput = z.infer<typeof GitWorktreeOutput>;
|
|
17
|
+
export declare function isSafeRemoteName(name: string): boolean;
|
|
18
|
+
export declare const CommitSha: z.ZodString;
|
|
19
|
+
export declare const GitPushInput: z.ZodObject<{
|
|
20
|
+
worktreePath: z.ZodString;
|
|
21
|
+
remote: z.ZodString;
|
|
22
|
+
sha: z.ZodString;
|
|
23
|
+
branch: z.ZodString;
|
|
24
|
+
noVerify: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
expectedRemoteSha: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type GitPushInput = z.infer<typeof GitPushInput>;
|
|
28
|
+
export declare const GitPushOutput: z.ZodObject<{
|
|
29
|
+
remote: z.ZodString;
|
|
30
|
+
branch: z.ZodString;
|
|
31
|
+
sha: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type GitPushOutput = z.infer<typeof GitPushOutput>;
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,eAAO,MAAM,wBAAwB,QAEiB,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,gBAO1B,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;;iBAc3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED,eAAO,MAAM,SAAS,aAEsE,CAAC;AAE7F,eAAO,MAAM,YAAY;;;;;;;iBAuBvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,aAAa;;;;iBAIxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// ABOUTME: Zod schemas for gitWorktree's input/output -- the repo/branch to check out, and the
|
|
2
|
+
// ABOUTME: resolved paths/branch created -- plus gitPush's input/output for a commit/branch/remote/sha push.
|
|
3
|
+
import { z } from "@ligeti/sdk";
|
|
4
|
+
export const SAFE_BRANCH_NAME_MESSAGE = 'must be a safe git ref name: no leading "-", no whitespace, no "..", none of ~^:?*[\\, ' +
|
|
5
|
+
'no leading/trailing "/", and not ending in ".lock"';
|
|
6
|
+
export function isSafeBranchName(name) {
|
|
7
|
+
if (name.startsWith("-"))
|
|
8
|
+
return false;
|
|
9
|
+
if (name.startsWith("/") || name.endsWith("/"))
|
|
10
|
+
return false;
|
|
11
|
+
if (name.endsWith(".lock"))
|
|
12
|
+
return false;
|
|
13
|
+
if (name.includes(".."))
|
|
14
|
+
return false;
|
|
15
|
+
if (/[\s~^:?*[\\]/.test(name))
|
|
16
|
+
return false;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
export const branchNameSchema = (describe) => z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.refine(isSafeBranchName, {
|
|
23
|
+
message: SAFE_BRANCH_NAME_MESSAGE,
|
|
24
|
+
})
|
|
25
|
+
.describe(describe);
|
|
26
|
+
export const GitWorktreeInput = z.object({
|
|
27
|
+
repoPath: z.string().min(1),
|
|
28
|
+
worktreeName: z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.regex(/^[A-Za-z0-9._-]+$/)
|
|
32
|
+
.refine((name) => name !== "." && name !== "..", { message: 'must not be "." or ".."' }),
|
|
33
|
+
branchName: z
|
|
34
|
+
.string()
|
|
35
|
+
.min(1)
|
|
36
|
+
.refine(isSafeBranchName, {
|
|
37
|
+
message: SAFE_BRANCH_NAME_MESSAGE,
|
|
38
|
+
})
|
|
39
|
+
.optional(),
|
|
40
|
+
});
|
|
41
|
+
export const GitWorktreeOutput = z.object({
|
|
42
|
+
repoPath: z.string(),
|
|
43
|
+
worktreePath: z.string(),
|
|
44
|
+
branchName: z.string(),
|
|
45
|
+
});
|
|
46
|
+
export function isSafeRemoteName(name) {
|
|
47
|
+
if (name.startsWith("-"))
|
|
48
|
+
return false;
|
|
49
|
+
if (/\s/.test(name))
|
|
50
|
+
return false;
|
|
51
|
+
if (name.includes("://"))
|
|
52
|
+
return false;
|
|
53
|
+
if (name.includes("@"))
|
|
54
|
+
return false;
|
|
55
|
+
if (name.includes(".."))
|
|
56
|
+
return false;
|
|
57
|
+
return /^[A-Za-z0-9._/-]+$/.test(name);
|
|
58
|
+
}
|
|
59
|
+
export const CommitSha = z
|
|
60
|
+
.string()
|
|
61
|
+
.regex(/^[0-9a-f]{40}$|^[0-9a-f]{64}$/, "must be a lowercase 40- or 64-character hex sha");
|
|
62
|
+
export const GitPushInput = z.object({
|
|
63
|
+
worktreePath: z.string().min(1),
|
|
64
|
+
remote: z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1)
|
|
67
|
+
.refine(isSafeRemoteName, {
|
|
68
|
+
message: 'must be a safe remote name: no leading "-", no whitespace, no "..", and not a URL ' +
|
|
69
|
+
'(no "://" or "@")',
|
|
70
|
+
}),
|
|
71
|
+
sha: CommitSha,
|
|
72
|
+
branch: z.string().min(1).refine(isSafeBranchName, {
|
|
73
|
+
message: SAFE_BRANCH_NAME_MESSAGE,
|
|
74
|
+
}),
|
|
75
|
+
noVerify: z
|
|
76
|
+
.boolean()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Passes --no-verify, so git skips the target repository's pre-push hook. Only for a commit that needs no gate of its own, such as a branch still exactly at its base."),
|
|
79
|
+
expectedRemoteSha: CommitSha.optional().describe("When set, pushes with --force-with-lease=refs/heads/<branch>:<expectedRemoteSha> instead of a plain push. Absent, a plain non-force push."),
|
|
80
|
+
});
|
|
81
|
+
export const GitPushOutput = z.object({
|
|
82
|
+
remote: z.string(),
|
|
83
|
+
branch: z.string(),
|
|
84
|
+
sha: z.string(),
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,6GAA6G;AAC7G,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,MAAM,CAAC,MAAM,wBAAwB,GACnC,yFAAyF;IACzF,oDAAoD,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7D,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE,CACnD,CAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,MAAM,CAAC,gBAAgB,EAAE;IACxB,OAAO,EAAE,wBAAwB;CAClC,CAAC;KACD,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,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AAC;AAE7F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,MAAM,CAAC,gBAAgB,EAAE;QACxB,OAAO,EACL,oFAAoF;YACpF,mBAAmB;KACtB,CAAC;IACJ,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,EAAE;QACjD,OAAO,EAAE,wBAAwB;KAClC,CAAC;IACF,QAAQ,EAAE,CAAC;SACR,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CACP,sKAAsK,CACvK;IACH,iBAAiB,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAC9C,2IAA2I,CAC5I;CACF,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ResourceStepDefinition } from "@ligeti/sdk";
|
|
2
|
+
import { GitWorktreeOutput, GitWorktreeInput } from "./types.js";
|
|
3
|
+
export declare function slugifyBranch(branchName: string): string;
|
|
4
|
+
export declare const gitWorktree: ResourceStepDefinition<typeof GitWorktreeInput, typeof GitWorktreeOutput, undefined>;
|
|
5
|
+
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmC,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAc3F,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAOxD;AA6BD,eAAO,MAAM,WAAW,EAAE,sBAAsB,CAC9C,OAAO,gBAAgB,EACvB,OAAO,iBAAiB,EACxB,SAAS,CAsGT,CAAC"}
|
package/dist/worktree.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// ABOUTME: gitWorktree, the resource step that creates a git worktree via herdr for a workflow to
|
|
2
|
+
// ABOUTME: use across many steps/tools, and removes it when the workflow is done (spawn/find/close).
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { appendFile, readFile } from "node:fs/promises";
|
|
5
|
+
import { realpath } from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { defineResourceStep } from "@ligeti/sdk";
|
|
8
|
+
import pkg from "../package.json" with { type: "json" };
|
|
9
|
+
import { childEnv, gitWorktreeRemoveFallback, herdrWorktreeCreate, herdrWorktreeList, herdrWorktreeRemove, isGitRepo, pathExists, XDG_ENV_VARS, } from "./herdr.js";
|
|
10
|
+
import { pathsFor, readMeta, writeMeta } from "./paths.js";
|
|
11
|
+
import { loadGitWorktreeSettings } from "./settings.js";
|
|
12
|
+
import { GitWorktreeOutput, GitWorktreeInput } from "./types.js";
|
|
13
|
+
export function slugifyBranch(branchName) {
|
|
14
|
+
const cleaned = branchName
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
17
|
+
.replace(/^-+|-+$/g, "");
|
|
18
|
+
const hash = createHash("sha256").update(branchName).digest("hex").slice(0, 8);
|
|
19
|
+
return cleaned.length > 0 ? `${cleaned}-${hash}` : hash;
|
|
20
|
+
}
|
|
21
|
+
const WORKTREES_EXCLUDE_LINE = ".worktrees/";
|
|
22
|
+
async function excludeWorktreesDir(repoPath, sctx) {
|
|
23
|
+
const excludePath = path.join(repoPath, ".git", "info", "exclude");
|
|
24
|
+
try {
|
|
25
|
+
let existing = "";
|
|
26
|
+
try {
|
|
27
|
+
existing = await readFile(excludePath, "utf8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
existing = "";
|
|
31
|
+
}
|
|
32
|
+
const alreadyPresent = existing
|
|
33
|
+
.split("\n")
|
|
34
|
+
.some((line) => line.trim() === WORKTREES_EXCLUDE_LINE);
|
|
35
|
+
if (alreadyPresent) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
39
|
+
await appendFile(excludePath, `${prefix}${WORKTREES_EXCLUDE_LINE}\n`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
sctx.logger.warn(`git.worktree: failed to add ".worktrees/" to git's info/exclude`, {
|
|
43
|
+
repoPath,
|
|
44
|
+
error: err instanceof Error ? err.message : String(err),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export const gitWorktree = defineResourceStep({
|
|
49
|
+
name: "git.worktree",
|
|
50
|
+
envVars: XDG_ENV_VARS,
|
|
51
|
+
description: "Creates a git worktree so a workflow's steps share one working directory, and removes it when the workflow is done.",
|
|
52
|
+
package: { name: pkg.name, version: pkg.version },
|
|
53
|
+
input: GitWorktreeInput,
|
|
54
|
+
output: GitWorktreeOutput,
|
|
55
|
+
retry: { maxAttempts: 1 },
|
|
56
|
+
async spawn(sctx, input, res) {
|
|
57
|
+
const settings = loadGitWorktreeSettings();
|
|
58
|
+
const repoPath = await realpath(input.repoPath);
|
|
59
|
+
const env = childEnv(sctx.logger);
|
|
60
|
+
if (!(await isGitRepo(repoPath, env, sctx.signal))) {
|
|
61
|
+
throw new Error(`git.worktree: "${repoPath}" is not a git repository`);
|
|
62
|
+
}
|
|
63
|
+
const branchName = input.branchName ?? input.worktreeName;
|
|
64
|
+
const worktreePath = path.join(repoPath, ".worktrees", slugifyBranch(branchName));
|
|
65
|
+
if (await pathExists(worktreePath)) {
|
|
66
|
+
throw new Error(`git.worktree: refusing to spawn -- "${worktreePath}" already exists`);
|
|
67
|
+
}
|
|
68
|
+
const paths = pathsFor(settings.stateDir, sctx.workflowId, res.attemptId);
|
|
69
|
+
await writeMeta(paths, { repoPath, worktreePath, branchName });
|
|
70
|
+
const result = await herdrWorktreeCreate(repoPath, worktreePath, branchName, input.worktreeName, settings.herdrBin, env, sctx.signal);
|
|
71
|
+
await excludeWorktreesDir(repoPath, sctx);
|
|
72
|
+
return {
|
|
73
|
+
handle: result.workspaceId,
|
|
74
|
+
output: {
|
|
75
|
+
repoPath,
|
|
76
|
+
worktreePath: result.worktreePath,
|
|
77
|
+
branchName: result.branchName,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
async find(fctx) {
|
|
82
|
+
const settings = loadGitWorktreeSettings();
|
|
83
|
+
const paths = pathsFor(settings.stateDir, fctx.workflowId, fctx.attemptId);
|
|
84
|
+
const meta = await readMeta(paths);
|
|
85
|
+
if (meta === null) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const env = childEnv(fctx.logger);
|
|
89
|
+
const existing = await herdrWorktreeList(meta.repoPath, settings.herdrBin, env, fctx.signal);
|
|
90
|
+
const entry = existing.find((w) => w.path === meta.worktreePath);
|
|
91
|
+
if (entry?.openWorkspaceId === undefined) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
handle: entry.openWorkspaceId,
|
|
96
|
+
output: {
|
|
97
|
+
repoPath: meta.repoPath,
|
|
98
|
+
worktreePath: entry.path,
|
|
99
|
+
branchName: entry.branch,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
async close(cctx, handle) {
|
|
104
|
+
const settings = loadGitWorktreeSettings();
|
|
105
|
+
const paths = pathsFor(settings.stateDir, cctx.workflowId, cctx.attemptId);
|
|
106
|
+
const env = childEnv(cctx.logger);
|
|
107
|
+
const meta = await readMeta(paths);
|
|
108
|
+
if (meta === null) {
|
|
109
|
+
await herdrWorktreeRemove(handle, settings.herdrBin, env);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const existing = await herdrWorktreeList(meta.repoPath, settings.herdrBin, env);
|
|
113
|
+
const entry = existing.find((w) => w.path === meta.worktreePath);
|
|
114
|
+
if (entry === undefined) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (entry.openWorkspaceId === handle) {
|
|
118
|
+
await herdrWorktreeRemove(handle, settings.herdrBin, env);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
await gitWorktreeRemoveFallback(meta.repoPath, meta.worktreePath, env);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=worktree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,qGAAqG;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAA4C,MAAM,aAAa,CAAC;AAC3F,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxD,OAAO,EACL,QAAQ,EACR,yBAAyB,EACzB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,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AAM,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAChF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC,CAAC;QAEjE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,IAAI,KAAK,CAAC,eAAe,KAAK,MAAM,EAAE,CAAC;YACrC,MAAM,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC1D,OAAO;QACT,CAAC;QAED,MAAM,yBAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ligeti/step-git-worktree",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "Ligeti step package: creates and removes a git worktree so a workflow's many steps/tools share one working directory.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://gitlab.com/nagyv-projects/ligeti.git",
|
|
10
|
+
"directory": "steps/git-worktree"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@ligeti/sdk": "^2.1.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@ligeti/sdk": "2.1.2",
|
|
26
|
+
"@ligeti/testing": "2.0.3"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {}
|
|
6
29
|
}
|