@procedures/git 0.0.0-stage → 0.2.0
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/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +1130 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +514 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/git/add.d.ts +12 -0
- package/dist/procedures/git/add.d.ts.map +1 -0
- package/dist/procedures/git/add.js +26 -0
- package/dist/procedures/git/add.js.map +1 -0
- package/dist/procedures/git/args.d.ts +15 -0
- package/dist/procedures/git/args.d.ts.map +1 -0
- package/dist/procedures/git/args.js +20 -0
- package/dist/procedures/git/args.js.map +1 -0
- package/dist/procedures/git/branch.d.ts +12 -0
- package/dist/procedures/git/branch.d.ts.map +1 -0
- package/dist/procedures/git/branch.js +54 -0
- package/dist/procedures/git/branch.js.map +1 -0
- package/dist/procedures/git/checkout.d.ts +12 -0
- package/dist/procedures/git/checkout.d.ts.map +1 -0
- package/dist/procedures/git/checkout.js +23 -0
- package/dist/procedures/git/checkout.js.map +1 -0
- package/dist/procedures/git/clone.d.ts +12 -0
- package/dist/procedures/git/clone.d.ts.map +1 -0
- package/dist/procedures/git/clone.js +28 -0
- package/dist/procedures/git/clone.js.map +1 -0
- package/dist/procedures/git/commit.d.ts +12 -0
- package/dist/procedures/git/commit.d.ts.map +1 -0
- package/dist/procedures/git/commit.js +41 -0
- package/dist/procedures/git/commit.js.map +1 -0
- package/dist/procedures/git/diff.d.ts +18 -0
- package/dist/procedures/git/diff.d.ts.map +1 -0
- package/dist/procedures/git/diff.js +58 -0
- package/dist/procedures/git/diff.js.map +1 -0
- package/dist/procedures/git/fetch.d.ts +12 -0
- package/dist/procedures/git/fetch.d.ts.map +1 -0
- package/dist/procedures/git/fetch.js +29 -0
- package/dist/procedures/git/fetch.js.map +1 -0
- package/dist/procedures/git/index.d.ts +15 -0
- package/dist/procedures/git/index.d.ts.map +1 -0
- package/dist/procedures/git/index.js +15 -0
- package/dist/procedures/git/index.js.map +1 -0
- package/dist/procedures/git/init.d.ts +12 -0
- package/dist/procedures/git/init.d.ts.map +1 -0
- package/dist/procedures/git/init.js +32 -0
- package/dist/procedures/git/init.js.map +1 -0
- package/dist/procedures/git/log.d.ts +12 -0
- package/dist/procedures/git/log.d.ts.map +1 -0
- package/dist/procedures/git/log.js +35 -0
- package/dist/procedures/git/log.js.map +1 -0
- package/dist/procedures/git/predicates.d.ts +40 -0
- package/dist/procedures/git/predicates.d.ts.map +1 -0
- package/dist/procedures/git/predicates.js +76 -0
- package/dist/procedures/git/predicates.js.map +1 -0
- package/dist/procedures/git/pull.d.ts +12 -0
- package/dist/procedures/git/pull.d.ts.map +1 -0
- package/dist/procedures/git/pull.js +36 -0
- package/dist/procedures/git/pull.js.map +1 -0
- package/dist/procedures/git/push.d.ts +12 -0
- package/dist/procedures/git/push.d.ts.map +1 -0
- package/dist/procedures/git/push.js +39 -0
- package/dist/procedures/git/push.js.map +1 -0
- package/dist/procedures/git/remote.d.ts +13 -0
- package/dist/procedures/git/remote.d.ts.map +1 -0
- package/dist/procedures/git/remote.js +30 -0
- package/dist/procedures/git/remote.js.map +1 -0
- package/dist/procedures/git/run.d.ts +32 -0
- package/dist/procedures/git/run.d.ts.map +1 -0
- package/dist/procedures/git/run.js +60 -0
- package/dist/procedures/git/run.js.map +1 -0
- package/dist/procedures/git/stash.d.ts +38 -0
- package/dist/procedures/git/stash.d.ts.map +1 -0
- package/dist/procedures/git/stash.js +211 -0
- package/dist/procedures/git/stash.js.map +1 -0
- package/dist/procedures/git/status.d.ts +17 -0
- package/dist/procedures/git/status.d.ts.map +1 -0
- package/dist/procedures/git/status.js +107 -0
- package/dist/procedures/git/status.js.map +1 -0
- package/dist/procedures/git.d.ts +5 -0
- package/dist/procedures/git.d.ts.map +1 -0
- package/dist/procedures/git.js +5 -0
- package/dist/procedures/git.js.map +1 -0
- package/dist/register.d.ts +7 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/types.d.ts +350 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +397 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -3
- package/src/index.ts +20 -0
- package/src/module.ts +656 -0
- package/src/procedures/git/add.ts +29 -0
- package/src/procedures/git/args.ts +21 -0
- package/src/procedures/git/branch.ts +61 -0
- package/src/procedures/git/checkout.ts +27 -0
- package/src/procedures/git/clone.ts +33 -0
- package/src/procedures/git/commit.ts +46 -0
- package/src/procedures/git/diff.ts +62 -0
- package/src/procedures/git/fetch.ts +32 -0
- package/src/procedures/git/index.ts +22 -0
- package/src/procedures/git/init.ts +43 -0
- package/src/procedures/git/log.ts +40 -0
- package/src/procedures/git/predicates.ts +90 -0
- package/src/procedures/git/pull.ts +45 -0
- package/src/procedures/git/push.ts +42 -0
- package/src/procedures/git/remote.ts +31 -0
- package/src/procedures/git/run.ts +70 -0
- package/src/procedures/git/stash.ts +255 -0
- package/src/procedures/git/status.ts +98 -0
- package/src/procedures/git.ts +5 -0
- package/src/register.ts +11 -0
- package/src/types.ts +815 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch procedure
|
|
3
|
+
*
|
|
4
|
+
* Branch operations
|
|
5
|
+
*/
|
|
6
|
+
import { gitArg } from "./args.js";
|
|
7
|
+
import { git } from "./run.js";
|
|
8
|
+
/**
|
|
9
|
+
* Branch operations
|
|
10
|
+
*/
|
|
11
|
+
export async function gitBranch(input, ctx = {}) {
|
|
12
|
+
const { name, delete: del, list, remote, cwd } = input;
|
|
13
|
+
const run = { cwd, signal: ctx.signal };
|
|
14
|
+
// Get current branch
|
|
15
|
+
const current = (await git(["rev-parse", "--abbrev-ref", "HEAD"], run)).trim();
|
|
16
|
+
// Delete branch
|
|
17
|
+
if (del && name) {
|
|
18
|
+
await git(["branch", "-d", gitArg("name", name)], run);
|
|
19
|
+
return { deleted: name, current };
|
|
20
|
+
}
|
|
21
|
+
// Create branch
|
|
22
|
+
if (name && !list) {
|
|
23
|
+
await git(["branch", gitArg("name", name)], run);
|
|
24
|
+
return { created: name, current };
|
|
25
|
+
}
|
|
26
|
+
// List branches
|
|
27
|
+
const args = ["branch"];
|
|
28
|
+
if (remote)
|
|
29
|
+
args.push("-a");
|
|
30
|
+
// The full ref name tells local from remote branches: a local "feature/x" also contains "/"
|
|
31
|
+
args.push("--format=%(refname)|%(refname:short)|%(HEAD)|%(upstream:short)");
|
|
32
|
+
const output = await git(args, run);
|
|
33
|
+
const branches = output
|
|
34
|
+
.split("\n")
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.map(line => {
|
|
37
|
+
const parts = line.split("|");
|
|
38
|
+
const fullName = parts[0] ?? "";
|
|
39
|
+
const branchName = parts[1] ?? "";
|
|
40
|
+
const head = parts[2] ?? "";
|
|
41
|
+
const trackingVal = parts[3];
|
|
42
|
+
const result = {
|
|
43
|
+
name: branchName.replace(/^remotes\//, ""),
|
|
44
|
+
current: head === "*",
|
|
45
|
+
remote: fullName.startsWith("refs/remotes/"),
|
|
46
|
+
};
|
|
47
|
+
if (trackingVal) {
|
|
48
|
+
result.tracking = trackingVal;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
});
|
|
52
|
+
return { branches, current };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../../src/procedures/git/branch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG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,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;YAC1C,OAAO,EAAE,IAAI,KAAK,GAAG;YACrB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC;SAC7C,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.checkout procedure
|
|
3
|
+
*
|
|
4
|
+
* Checkout branch or files
|
|
5
|
+
*/
|
|
6
|
+
import { type GitContext } from "./run.js";
|
|
7
|
+
import type { GitCheckoutInput, GitCheckoutOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checkout branch or files
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitCheckout(input: GitCheckoutInput, ctx?: GitContext): Promise<GitCheckoutOutput>;
|
|
12
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/checkout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;GAEG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAa3G"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.checkout procedure
|
|
3
|
+
*
|
|
4
|
+
* Checkout branch or files
|
|
5
|
+
*/
|
|
6
|
+
import { gitArg } from "./args.js";
|
|
7
|
+
import { git } from "./run.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checkout branch or files
|
|
10
|
+
*/
|
|
11
|
+
export async function gitCheckout(input, ctx = {}) {
|
|
12
|
+
const { ref, create, paths, cwd } = input;
|
|
13
|
+
const args = ["checkout"];
|
|
14
|
+
if (create)
|
|
15
|
+
args.push("-b");
|
|
16
|
+
args.push(gitArg("ref", ref));
|
|
17
|
+
if (paths && paths.length > 0) {
|
|
18
|
+
args.push("--", ...paths);
|
|
19
|
+
}
|
|
20
|
+
await git(args, { cwd, signal: ctx.signal });
|
|
21
|
+
return { ref, created: create };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/procedures/git/checkout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAuB,EAAE,GAAG,GAAe,EAAE;IAC7E,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAE1C,MAAM,IAAI,GAAa,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.clone procedure
|
|
3
|
+
*
|
|
4
|
+
* Clone repository
|
|
5
|
+
*/
|
|
6
|
+
import { type GitContext } from "./run.js";
|
|
7
|
+
import type { GitCloneInput, GitCloneOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Clone repository
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitClone(input: GitCloneInput, ctx?: GitContext): Promise<GitCloneOutput>;
|
|
12
|
+
//# sourceMappingURL=clone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBlG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.clone procedure
|
|
3
|
+
*
|
|
4
|
+
* Clone repository
|
|
5
|
+
*/
|
|
6
|
+
import { join, basename } from "node:path";
|
|
7
|
+
import { gitArg } from "./args.js";
|
|
8
|
+
import { git } from "./run.js";
|
|
9
|
+
/**
|
|
10
|
+
* Clone repository
|
|
11
|
+
*/
|
|
12
|
+
export async function gitClone(input, ctx = {}) {
|
|
13
|
+
const { url, dest, branch, depth, cwd } = input;
|
|
14
|
+
// Determine destination directory
|
|
15
|
+
const destDir = dest || basename(url, ".git").replace(/\.git$/, "");
|
|
16
|
+
const fullPath = cwd ? join(cwd, destDir) : destDir;
|
|
17
|
+
const args = ["clone"];
|
|
18
|
+
if (branch)
|
|
19
|
+
args.push("-b", branch);
|
|
20
|
+
if (depth)
|
|
21
|
+
args.push("--depth", String(depth));
|
|
22
|
+
args.push("--", gitArg("url", url), gitArg("dest", destDir));
|
|
23
|
+
await git(args, { cwd, signal: ctx.signal });
|
|
24
|
+
// Get the branch that was checked out
|
|
25
|
+
const clonedBranch = (await git(["rev-parse", "--abbrev-ref", "HEAD"], { cwd: fullPath, signal: ctx.signal })).trim();
|
|
26
|
+
return { path: fullPath, branch: clonedBranch };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/procedures/git/clone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,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
|
+
* Create commit
|
|
5
|
+
*/
|
|
6
|
+
import { type GitContext } from "./run.js";
|
|
7
|
+
import type { GitCommitInput, GitCommitOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Create commit
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitCommit(input: GitCommitInput, ctx?: GitContext): Promise<GitCommitOutput>;
|
|
12
|
+
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/commit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;GAEG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAiCrG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.commit procedure
|
|
3
|
+
*
|
|
4
|
+
* Create commit
|
|
5
|
+
*/
|
|
6
|
+
import { git } from "./run.js";
|
|
7
|
+
/**
|
|
8
|
+
* Create commit
|
|
9
|
+
*/
|
|
10
|
+
export async function gitCommit(input, ctx = {}) {
|
|
11
|
+
const { message, all, amend, cwd } = input;
|
|
12
|
+
const run = { cwd, signal: ctx.signal };
|
|
13
|
+
// Check if there's anything to commit (unless amending)
|
|
14
|
+
if (!amend) {
|
|
15
|
+
const status = (await git(["status", "--porcelain"], run)).trim();
|
|
16
|
+
if (!status && !all) {
|
|
17
|
+
// Nothing staged and not using -a, skip commit
|
|
18
|
+
return { hash: "", message: "", author: "", date: "", skipped: true };
|
|
19
|
+
}
|
|
20
|
+
// If using -a, check if there are any modified files
|
|
21
|
+
if (all) {
|
|
22
|
+
const hasChanges = status.length > 0;
|
|
23
|
+
if (!hasChanges) {
|
|
24
|
+
return { hash: "", message: "", author: "", date: "", skipped: true };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const args = ["commit"];
|
|
29
|
+
if (all)
|
|
30
|
+
args.push("-a");
|
|
31
|
+
if (amend)
|
|
32
|
+
args.push("--amend");
|
|
33
|
+
args.push("-m", message);
|
|
34
|
+
await git(args, run);
|
|
35
|
+
// Get commit info
|
|
36
|
+
const format = "--format=%H%n%s%n%an%n%ci";
|
|
37
|
+
const info = (await git(["log", "-1", format], run)).trim();
|
|
38
|
+
const [hash = "", msg = "", author = "", date = ""] = info.split("\n");
|
|
39
|
+
return { hash, message: msg, author, date };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../src/procedures/git/commit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,GAAG,GAAe,EAAE;IACzE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAExC,wDAAwD;IACxD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClE,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,+CAA+C;YAC/C,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE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
+
* Show changes
|
|
5
|
+
*
|
|
6
|
+
* The counts come from `git diff --numstat -z`. With `-z`, each path is exact, and a rename gives
|
|
7
|
+
* the old and the new path in separate fields (deep dive WRP-7). Before, the procedure split each
|
|
8
|
+
* line at whitespace: a path with a space lost its end, and a rename gave its old path only.
|
|
9
|
+
*/
|
|
10
|
+
import { type GitContext } from "./run.js";
|
|
11
|
+
import type { GitDiffInput, GitDiffOutput, GitDiffFile } from "../../types.js";
|
|
12
|
+
/** This function reads the output of `git diff --numstat -z`. */
|
|
13
|
+
export declare function parseNumstat(output: string): GitDiffFile[];
|
|
14
|
+
/**
|
|
15
|
+
* Show changes
|
|
16
|
+
*/
|
|
17
|
+
export declare function gitDiff(input: GitDiffInput, ctx?: GitContext): Promise<GitDiffOutput>;
|
|
18
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/E,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAmB1D;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAsB/F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.diff procedure
|
|
3
|
+
*
|
|
4
|
+
* Show changes
|
|
5
|
+
*
|
|
6
|
+
* The counts come from `git diff --numstat -z`. With `-z`, each path is exact, and a rename gives
|
|
7
|
+
* the old and the new path in separate fields (deep dive WRP-7). Before, the procedure split each
|
|
8
|
+
* line at whitespace: a path with a space lost its end, and a rename gave its old path only.
|
|
9
|
+
*/
|
|
10
|
+
import { gitArg } from "./args.js";
|
|
11
|
+
import { git, zFields } from "./run.js";
|
|
12
|
+
/** This function reads the output of `git diff --numstat -z`. */
|
|
13
|
+
export function parseNumstat(output) {
|
|
14
|
+
const files = [];
|
|
15
|
+
const fields = zFields(output);
|
|
16
|
+
for (let i = 0; i < fields.length; i++) {
|
|
17
|
+
const [add = "0", del = "0", ...rest] = fields[i].split("\t");
|
|
18
|
+
// A binary file has "-" for both counts
|
|
19
|
+
const additions = add === "-" ? 0 : parseInt(add, 10);
|
|
20
|
+
const deletions = del === "-" ? 0 : parseInt(del, 10);
|
|
21
|
+
const path = rest.join("\t");
|
|
22
|
+
if (path === "") {
|
|
23
|
+
// A rename or a copy: the old path, then the new path, in the next two fields
|
|
24
|
+
const from = fields[++i] ?? "";
|
|
25
|
+
const to = fields[++i] ?? "";
|
|
26
|
+
files.push({ path: to, from, additions, deletions });
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
files.push({ path, additions, deletions });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return files;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Show changes
|
|
36
|
+
*/
|
|
37
|
+
export async function gitDiff(input, ctx = {}) {
|
|
38
|
+
const { staged, ref, paths, stat, cwd } = input;
|
|
39
|
+
const run = { cwd, signal: ctx.signal };
|
|
40
|
+
const selection = [];
|
|
41
|
+
if (staged)
|
|
42
|
+
selection.push("--cached");
|
|
43
|
+
if (ref)
|
|
44
|
+
selection.push(gitArg("ref", ref));
|
|
45
|
+
const pathspec = paths && paths.length > 0 ? ["--", ...paths] : [];
|
|
46
|
+
const files = parseNumstat(await git(["diff", ...selection, "--numstat", "-z", ...pathspec], run));
|
|
47
|
+
const result = {
|
|
48
|
+
files,
|
|
49
|
+
additions: files.reduce((sum, file) => sum + file.additions, 0),
|
|
50
|
+
deletions: files.reduce((sum, file) => sum + file.deletions, 0),
|
|
51
|
+
};
|
|
52
|
+
// Include full diff if not stat-only
|
|
53
|
+
if (!stat) {
|
|
54
|
+
result.diff = await git(["diff", ...selection, ...pathspec], run);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/procedures/git/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAGzD,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/D,wCAAwC;QACxC,MAAM,SAAS,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAChB,8EAA8E;YAC9E,MAAM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L,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC/D,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;KAChE,CAAC;IAEF,qCAAqC;IACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.fetch procedure
|
|
3
|
+
*
|
|
4
|
+
* Fetch from remote without merging
|
|
5
|
+
*/
|
|
6
|
+
import { type GitContext } from "./run.js";
|
|
7
|
+
import type { GitFetchInput, GitFetchOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Fetch from remote
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitFetch(input: GitFetchInput, ctx?: GitContext): Promise<GitFetchOutput>;
|
|
12
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBlG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.fetch procedure
|
|
3
|
+
*
|
|
4
|
+
* Fetch from remote without merging
|
|
5
|
+
*/
|
|
6
|
+
import { gitArg } from "./args.js";
|
|
7
|
+
import { git } from "./run.js";
|
|
8
|
+
/**
|
|
9
|
+
* Fetch from remote
|
|
10
|
+
*/
|
|
11
|
+
export async function gitFetch(input, ctx = {}) {
|
|
12
|
+
const { branch, all, prune, cwd } = input;
|
|
13
|
+
const remoteName = input.remote ?? "origin";
|
|
14
|
+
const args = ["fetch"];
|
|
15
|
+
if (all) {
|
|
16
|
+
args.push("--all");
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
args.push(gitArg("remote", remoteName));
|
|
20
|
+
if (branch) {
|
|
21
|
+
args.push(gitArg("branch", branch));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (prune)
|
|
25
|
+
args.push("--prune");
|
|
26
|
+
await git(args, { cwd, signal: ctx.signal });
|
|
27
|
+
return { remote: remoteName, fetched: true };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/procedures/git/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAoB,EAAE,GAAG,GAAe,EAAE;IACvE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC;IAE5C,MAAM,IAAI,GAAa,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;QACxC,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEhC,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { gitStatus } from "./status.js";
|
|
2
|
+
export { gitAdd } from "./add.js";
|
|
3
|
+
export { gitCommit } from "./commit.js";
|
|
4
|
+
export { gitPush } from "./push.js";
|
|
5
|
+
export { gitPull } from "./pull.js";
|
|
6
|
+
export { gitClone } from "./clone.js";
|
|
7
|
+
export { gitCheckout } from "./checkout.js";
|
|
8
|
+
export { gitBranch } from "./branch.js";
|
|
9
|
+
export { gitLog } from "./log.js";
|
|
10
|
+
export { gitDiff } from "./diff.js";
|
|
11
|
+
export { gitInit } from "./init.js";
|
|
12
|
+
export { gitRemote, gitRemoteSet } from "./remote.js";
|
|
13
|
+
export { gitFetch } from "./fetch.js";
|
|
14
|
+
export { gitStashList, gitStashPush, gitStashPop, gitStashApply, gitStashDrop, gitStashExport, gitStashImport, } from "./stash.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { gitStatus } from "./status.js";
|
|
2
|
+
export { gitAdd } from "./add.js";
|
|
3
|
+
export { gitCommit } from "./commit.js";
|
|
4
|
+
export { gitPush } from "./push.js";
|
|
5
|
+
export { gitPull } from "./pull.js";
|
|
6
|
+
export { gitClone } from "./clone.js";
|
|
7
|
+
export { gitCheckout } from "./checkout.js";
|
|
8
|
+
export { gitBranch } from "./branch.js";
|
|
9
|
+
export { gitLog } from "./log.js";
|
|
10
|
+
export { gitDiff } from "./diff.js";
|
|
11
|
+
export { gitInit } from "./init.js";
|
|
12
|
+
export { gitRemote, gitRemoteSet } from "./remote.js";
|
|
13
|
+
export { gitFetch } from "./fetch.js";
|
|
14
|
+
export { gitStashList, gitStashPush, gitStashPop, gitStashApply, gitStashDrop, gitStashExport, gitStashImport, } from "./stash.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/git/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.init procedure
|
|
3
|
+
*
|
|
4
|
+
* Initialize a git repository
|
|
5
|
+
*/
|
|
6
|
+
import type { ProcedureContext } from "@procedures/client";
|
|
7
|
+
import type { GitInitInput, GitInitOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Initialize a git repository
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitInit(input: GitInitInput, ctx: ProcedureContext): Promise<GitInitOutput>;
|
|
12
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIlE;;GAEG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CA0BhG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.init procedure
|
|
3
|
+
*
|
|
4
|
+
* Initialize a git repository
|
|
5
|
+
*/
|
|
6
|
+
import { join, resolve } from "node:path";
|
|
7
|
+
import { git } from "./run.js";
|
|
8
|
+
/**
|
|
9
|
+
* Initialize a git repository
|
|
10
|
+
*/
|
|
11
|
+
export async function gitInit(input, ctx) {
|
|
12
|
+
const cwd = input.cwd ? resolve(input.cwd) : process.cwd();
|
|
13
|
+
// Check if already a git repo
|
|
14
|
+
const gitDir = join(cwd, ".git");
|
|
15
|
+
const existsResult = await ctx.client.call(["fs", "exists"], { path: gitDir });
|
|
16
|
+
const alreadyExists = existsResult.exists;
|
|
17
|
+
if (!alreadyExists) {
|
|
18
|
+
const args = ["init"];
|
|
19
|
+
if (input.bare) {
|
|
20
|
+
args.push("--bare");
|
|
21
|
+
}
|
|
22
|
+
if (input.initialBranch) {
|
|
23
|
+
args.push(`--initial-branch=${input.initialBranch}`);
|
|
24
|
+
}
|
|
25
|
+
await git(args, { cwd, signal: ctx.signal });
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
path: cwd,
|
|
29
|
+
created: !alreadyExists,
|
|
30
|
+
};
|
|
31
|
+
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EAAE,CAAC,aAAa;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.log procedure
|
|
3
|
+
*
|
|
4
|
+
* Show commit log
|
|
5
|
+
*/
|
|
6
|
+
import { type GitContext } from "./run.js";
|
|
7
|
+
import type { GitLogInput, GitLogOutput } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Show commit log
|
|
10
|
+
*/
|
|
11
|
+
export declare function gitLog(input: GitLogInput, ctx?: GitContext): Promise<GitLogOutput>;
|
|
12
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/log.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAM9E;;GAEG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAsB5F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.log procedure
|
|
3
|
+
*
|
|
4
|
+
* Show commit log
|
|
5
|
+
*/
|
|
6
|
+
import { gitArg } from "./args.js";
|
|
7
|
+
import { git } from "./run.js";
|
|
8
|
+
// Control characters that do not occur in a name, an email, a date or a subject
|
|
9
|
+
const FIELD = "\x1f";
|
|
10
|
+
const RECORD = "\x1e";
|
|
11
|
+
/**
|
|
12
|
+
* Show commit log
|
|
13
|
+
*/
|
|
14
|
+
export async function gitLog(input, ctx = {}) {
|
|
15
|
+
const { count, ref, cwd } = input;
|
|
16
|
+
const format = `--format=${["%H", "%h", "%an", "%ae", "%ci", "%s"].join("%x1f")}%x1e`;
|
|
17
|
+
const args = ["log", `-n${count}`, format];
|
|
18
|
+
if (ref)
|
|
19
|
+
args.push(gitArg("ref", ref));
|
|
20
|
+
const output = await git(args, { cwd, signal: ctx.signal });
|
|
21
|
+
const commits = output
|
|
22
|
+
.split(RECORD)
|
|
23
|
+
.map((record) => record.replace(/^\n/, ""))
|
|
24
|
+
.filter((record) => record.length > 0)
|
|
25
|
+
.map((record) => {
|
|
26
|
+
const [hash = "", shortHash = "", author = "", email = "", date = "", message = ""] = record.split(FIELD);
|
|
27
|
+
return { hash, shortHash, author, email, date, message };
|
|
28
|
+
});
|
|
29
|
+
const result = { commits };
|
|
30
|
+
if (input.oneline) {
|
|
31
|
+
result.lines = commits.map((commit) => `${commit.shortHash} ${commit.message}`);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/procedures/git/log.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD,gFAAgF;AAChF,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAkB,EAAE,GAAG,GAAe,EAAE;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAElC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IACtF,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3C,IAAI,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.
|
|
5
|
+
* These return true/false based on git repository state.
|
|
6
|
+
*/
|
|
7
|
+
import { type GitContext } from "./run.js";
|
|
8
|
+
export interface GitPredicateInput {
|
|
9
|
+
/** Working directory (default: process.cwd()) */
|
|
10
|
+
cwd?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface GitPredicateOutput {
|
|
13
|
+
/** The predicate result */
|
|
14
|
+
value: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if there are any changes (unstaged, staged, or untracked)
|
|
18
|
+
*/
|
|
19
|
+
export declare function gitHasChanges(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if there are any staged changes ready to commit
|
|
22
|
+
*/
|
|
23
|
+
export declare function gitHasStagedChanges(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if there are any unstaged changes (modified or deleted files)
|
|
26
|
+
*/
|
|
27
|
+
export declare function gitHasUnstagedChanges(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if there are any untracked files
|
|
30
|
+
*/
|
|
31
|
+
export declare function gitHasUntrackedFiles(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if there are local commits that haven't been pushed
|
|
34
|
+
*/
|
|
35
|
+
export declare function gitHasLocalCommits(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the working directory is clean (no changes at all)
|
|
38
|
+
*/
|
|
39
|
+
export declare function gitIsClean(input: GitPredicateInput, ctx?: GitContext): Promise<GitPredicateOutput>;
|
|
40
|
+
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/predicates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAeD;;GAEG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG/G;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIrH;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAIvH;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAItH;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAWpH;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG5G"}
|