@procedures/git 0.2.3 → 0.4.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 +82 -0
- package/README.md +125 -17
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +314 -4
- package/dist/module.js.map +1 -1
- package/dist/procedures/git/blame.d.ts +17 -0
- package/dist/procedures/git/blame.d.ts.map +1 -0
- package/dist/procedures/git/blame.js +69 -0
- package/dist/procedures/git/blame.js.map +1 -0
- package/dist/procedures/git/branch/add.d.ts +12 -0
- package/dist/procedures/git/branch/add.d.ts.map +1 -0
- package/dist/procedures/git/branch/add.js +21 -0
- package/dist/procedures/git/branch/add.js.map +1 -0
- package/dist/procedures/git/branch/delete.d.ts +13 -0
- package/dist/procedures/git/branch/delete.d.ts.map +1 -0
- package/dist/procedures/git/branch/delete.js +24 -0
- package/dist/procedures/git/branch/delete.js.map +1 -0
- package/dist/procedures/git/branch/list.d.ts +13 -0
- package/dist/procedures/git/branch/list.d.ts.map +1 -0
- package/dist/procedures/git/branch/list.js +37 -0
- package/dist/procedures/git/branch/list.js.map +1 -0
- package/dist/procedures/git/branch.d.ts +8 -2
- package/dist/procedures/git/branch.d.ts.map +1 -1
- package/dist/procedures/git/branch.js +18 -37
- package/dist/procedures/git/branch.js.map +1 -1
- package/dist/procedures/git/commit.d.ts +2 -1
- package/dist/procedures/git/commit.d.ts.map +1 -1
- package/dist/procedures/git/commit.js +21 -12
- package/dist/procedures/git/commit.js.map +1 -1
- package/dist/procedures/git/index.d.ts +19 -0
- package/dist/procedures/git/index.d.ts.map +1 -1
- package/dist/procedures/git/index.js +19 -0
- package/dist/procedures/git/index.js.map +1 -1
- package/dist/procedures/git/init.d.ts +6 -2
- package/dist/procedures/git/init.d.ts.map +1 -1
- package/dist/procedures/git/init.js +8 -4
- package/dist/procedures/git/init.js.map +1 -1
- package/dist/procedures/git/merge/abort.d.ts +14 -0
- package/dist/procedures/git/merge/abort.d.ts.map +1 -0
- package/dist/procedures/git/merge/abort.js +18 -0
- package/dist/procedures/git/merge/abort.js.map +1 -0
- package/dist/procedures/git/merge.d.ts +16 -0
- package/dist/procedures/git/merge.d.ts.map +1 -0
- package/dist/procedures/git/merge.js +41 -0
- package/dist/procedures/git/merge.js.map +1 -0
- package/dist/procedures/git/porcelain.d.ts +27 -0
- package/dist/procedures/git/porcelain.d.ts.map +1 -0
- package/dist/procedures/git/porcelain.js +66 -0
- package/dist/procedures/git/porcelain.js.map +1 -0
- package/dist/procedures/git/push.d.ts.map +1 -1
- package/dist/procedures/git/push.js +4 -2
- package/dist/procedures/git/push.js.map +1 -1
- package/dist/procedures/git/rebase/abort.d.ts +13 -0
- package/dist/procedures/git/rebase/abort.d.ts.map +1 -0
- package/dist/procedures/git/rebase/abort.js +17 -0
- package/dist/procedures/git/rebase/abort.js.map +1 -0
- package/dist/procedures/git/rebase/continue.d.ts +13 -0
- package/dist/procedures/git/rebase/continue.d.ts.map +1 -0
- package/dist/procedures/git/rebase/continue.js +23 -0
- package/dist/procedures/git/rebase/continue.js.map +1 -0
- package/dist/procedures/git/rebase.d.ts +22 -0
- package/dist/procedures/git/rebase.d.ts.map +1 -0
- package/dist/procedures/git/rebase.js +46 -0
- package/dist/procedures/git/rebase.js.map +1 -0
- package/dist/procedures/git/refs.d.ts +31 -0
- package/dist/procedures/git/refs.d.ts.map +1 -0
- package/dist/procedures/git/refs.js +52 -0
- package/dist/procedures/git/refs.js.map +1 -0
- package/dist/procedures/git/reset.d.ts +13 -0
- package/dist/procedures/git/reset.d.ts.map +1 -0
- package/dist/procedures/git/reset.js +31 -0
- package/dist/procedures/git/reset.js.map +1 -0
- package/dist/procedures/git/restore.d.ts +13 -0
- package/dist/procedures/git/restore.d.ts.map +1 -0
- package/dist/procedures/git/restore.js +26 -0
- package/dist/procedures/git/restore.js.map +1 -0
- package/dist/procedures/git/revParse.d.ts +13 -0
- package/dist/procedures/git/revParse.d.ts.map +1 -0
- package/dist/procedures/git/revParse.js +23 -0
- package/dist/procedures/git/revParse.js.map +1 -0
- package/dist/procedures/git/run.d.ts +2 -0
- package/dist/procedures/git/run.d.ts.map +1 -1
- package/dist/procedures/git/run.js +1 -0
- package/dist/procedures/git/run.js.map +1 -1
- package/dist/procedures/git/show.d.ts +15 -0
- package/dist/procedures/git/show.d.ts.map +1 -0
- package/dist/procedures/git/show.js +49 -0
- package/dist/procedures/git/show.js.map +1 -0
- package/dist/procedures/git/status.d.ts +3 -1
- package/dist/procedures/git/status.d.ts.map +1 -1
- package/dist/procedures/git/status.js +11 -24
- package/dist/procedures/git/status.js.map +1 -1
- package/dist/procedures/git/tag/add.d.ts +12 -0
- package/dist/procedures/git/tag/add.d.ts.map +1 -0
- package/dist/procedures/git/tag/add.js +25 -0
- package/dist/procedures/git/tag/add.js.map +1 -0
- package/dist/procedures/git/tag/delete.d.ts +12 -0
- package/dist/procedures/git/tag/delete.d.ts.map +1 -0
- package/dist/procedures/git/tag/delete.js +19 -0
- package/dist/procedures/git/tag/delete.js.map +1 -0
- package/dist/procedures/git/tag/list.d.ts +12 -0
- package/dist/procedures/git/tag/list.d.ts.map +1 -0
- package/dist/procedures/git/tag/list.js +34 -0
- package/dist/procedures/git/tag/list.js.map +1 -0
- package/dist/procedures/git/worktree/add.d.ts +13 -0
- package/dist/procedures/git/worktree/add.d.ts.map +1 -0
- package/dist/procedures/git/worktree/add.js +35 -0
- package/dist/procedures/git/worktree/add.js.map +1 -0
- package/dist/procedures/git/worktree/list.d.ts +17 -0
- package/dist/procedures/git/worktree/list.d.ts.map +1 -0
- package/dist/procedures/git/worktree/list.js +52 -0
- package/dist/procedures/git/worktree/list.js.map +1 -0
- package/dist/procedures/git/worktree/remove.d.ts +13 -0
- package/dist/procedures/git/worktree/remove.d.ts.map +1 -0
- package/dist/procedures/git/worktree/remove.js +20 -0
- package/dist/procedures/git/worktree/remove.js.map +1 -0
- package/dist/types.d.ts +315 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +280 -0
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -1
- package/src/module.ts +413 -4
- package/src/procedures/git/blame.ts +68 -0
- package/src/procedures/git/branch/add.ts +24 -0
- package/src/procedures/git/branch/delete.ts +29 -0
- package/src/procedures/git/branch/list.ts +40 -0
- package/src/procedures/git/branch.ts +19 -40
- package/src/procedures/git/commit.ts +20 -12
- package/src/procedures/git/index.ts +19 -0
- package/src/procedures/git/init.ts +11 -10
- package/src/procedures/git/merge/abort.ts +20 -0
- package/src/procedures/git/merge.ts +42 -0
- package/src/procedures/git/porcelain.ts +63 -0
- package/src/procedures/git/push.ts +4 -2
- package/src/procedures/git/rebase/abort.ts +19 -0
- package/src/procedures/git/rebase/continue.ts +25 -0
- package/src/procedures/git/rebase.ts +48 -0
- package/src/procedures/git/refs.ts +55 -0
- package/src/procedures/git/reset.ts +34 -0
- package/src/procedures/git/restore.ts +27 -0
- package/src/procedures/git/revParse.ts +24 -0
- package/src/procedures/git/run.ts +3 -0
- package/src/procedures/git/show.ts +57 -0
- package/src/procedures/git/status.ts +9 -17
- package/src/procedures/git/tag/add.ts +27 -0
- package/src/procedures/git/tag/delete.ts +22 -0
- package/src/procedures/git/tag/list.ts +36 -0
- package/src/procedures/git/worktree/add.ts +35 -0
- package/src/procedures/git/worktree/list.ts +48 -0
- package/src/procedures/git/worktree/remove.ts +21 -0
- package/src/types.ts +641 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch.delete procedure
|
|
3
|
+
*
|
|
4
|
+
* Delete a branch (roadmap R40). Git refuses a branch that is not merged, unless `force` is true.
|
|
5
|
+
* The result gives the last commit of the branch, so git.branch.add can make it again.
|
|
6
|
+
*/
|
|
7
|
+
import { type GitContext } from "../run.js";
|
|
8
|
+
import type { GitBranchDeleteInput, GitBranchDeleteOutput } from "../../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Delete a branch
|
|
11
|
+
*/
|
|
12
|
+
export declare function gitBranchDelete(input: GitBranchDeleteInput, ctx?: GitContext): Promise<GitBranchDeleteOutput>;
|
|
13
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/procedures/git/branch/delete.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAErF;;GAEG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAcvH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch.delete procedure
|
|
3
|
+
*
|
|
4
|
+
* Delete a branch (roadmap R40). Git refuses a branch that is not merged, unless `force` is true.
|
|
5
|
+
* The result gives the last commit of the branch, so git.branch.add can make it again.
|
|
6
|
+
*/
|
|
7
|
+
import { gitArg } from "../args.js";
|
|
8
|
+
import { git, GitError } from "../run.js";
|
|
9
|
+
/**
|
|
10
|
+
* Delete a branch
|
|
11
|
+
*/
|
|
12
|
+
export async function gitBranchDelete(input, ctx = {}) {
|
|
13
|
+
const name = gitArg("name", input.name);
|
|
14
|
+
const run = { cwd: input.cwd, signal: ctx.signal };
|
|
15
|
+
// With --quiet, a missing branch gives exit 1 and no message. Outside a repository, git gives 128.
|
|
16
|
+
const hash = await git(["rev-parse", "--verify", "--quiet", `refs/heads/${name}^{commit}`], run).then((output) => output.trim(), (error) => {
|
|
17
|
+
if (error instanceof GitError && error.exitCode === 1)
|
|
18
|
+
throw new Error(`branch '${name}' not found`);
|
|
19
|
+
throw error;
|
|
20
|
+
});
|
|
21
|
+
await git(["branch", input.force ? "-D" : "-d", name], run);
|
|
22
|
+
return { name, hash };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/procedures/git/branch/delete.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAmB,MAAM,WAAW,CAAC;AAG3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,KAA2B,EAAE,GAAG,GAAe,EAAE;IACrF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAEnD,mGAAmG;IACnG,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,IAAI,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CACnG,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EACzB,CAAC,KAAc,EAAE,EAAE;QACjB,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,aAAa,CAAC,CAAC;QACrG,MAAM,KAAK,CAAC;IACd,CAAC,CACF,CAAC;IACF,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch.list procedure
|
|
3
|
+
*
|
|
4
|
+
* List the branches (roadmap R40). It works in a repository without commits too: there are no
|
|
5
|
+
* branches yet, and `current` is the branch that HEAD names.
|
|
6
|
+
*/
|
|
7
|
+
import { type GitContext } from "../run.js";
|
|
8
|
+
import type { GitBranchListInput, GitBranchListOutput } from "../../../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* List the branches
|
|
11
|
+
*/
|
|
12
|
+
export declare function gitBranchList(input: GitBranchListInput, ctx?: GitContext): Promise<GitBranchListOutput>;
|
|
13
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/procedures/git/branch/list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAiB,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEhG;;GAEG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAyBjH"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.branch.list procedure
|
|
3
|
+
*
|
|
4
|
+
* List the branches (roadmap R40). It works in a repository without commits too: there are no
|
|
5
|
+
* branches yet, and `current` is the branch that HEAD names.
|
|
6
|
+
*/
|
|
7
|
+
import { git } from "../run.js";
|
|
8
|
+
import { currentBranch } from "../refs.js";
|
|
9
|
+
/**
|
|
10
|
+
* List the branches
|
|
11
|
+
*/
|
|
12
|
+
export async function gitBranchList(input, ctx = {}) {
|
|
13
|
+
const run = { cwd: input.cwd, signal: ctx.signal };
|
|
14
|
+
const current = await currentBranch(run);
|
|
15
|
+
const args = ["branch"];
|
|
16
|
+
if (input.remote)
|
|
17
|
+
args.push("-a");
|
|
18
|
+
// The full ref name tells local from remote branches: a local "feature/x" also contains "/"
|
|
19
|
+
args.push("--format=%(refname)|%(refname:short)|%(HEAD)|%(upstream:short)");
|
|
20
|
+
const output = await git(args, run);
|
|
21
|
+
const branches = output
|
|
22
|
+
.split("\n")
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.map((line) => {
|
|
25
|
+
const [fullName = "", branchName = "", head = "", tracking = ""] = line.split("|");
|
|
26
|
+
const result = {
|
|
27
|
+
name: branchName.replace(/^remotes\//, ""),
|
|
28
|
+
current: head === "*",
|
|
29
|
+
remote: fullName.startsWith("refs/remotes/"),
|
|
30
|
+
};
|
|
31
|
+
if (tracking)
|
|
32
|
+
result.tracking = tracking;
|
|
33
|
+
return result;
|
|
34
|
+
});
|
|
35
|
+
return { branches, current };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/procedures/git/branch/list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAmB,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAyB,EAAE,GAAG,GAAe,EAAE;IACjF,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,IAAI,KAAK,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,4FAA4F;IAC5F,IAAI,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IAE5E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAoB,MAAM;SACrC,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,CAAC,QAAQ,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnF,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,QAAQ;YAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* git.branch procedure
|
|
2
|
+
* git.branch procedure (deprecated)
|
|
3
3
|
*
|
|
4
|
-
* Branch operations
|
|
4
|
+
* Branch operations. Since roadmap R40, git.branch.list, git.branch.add and git.branch.delete do
|
|
5
|
+
* this, one procedure for each operation. This procedure stays for one release, and calls them.
|
|
6
|
+
* Its inputs and outputs do not change. The current branch comes from `git symbolic-ref`, so a
|
|
7
|
+
* repository without commits works now too (before, `git rev-parse --abbrev-ref HEAD` failed).
|
|
5
8
|
*/
|
|
6
9
|
import { type GitContext } from "./run.js";
|
|
7
10
|
import type { GitBranchInput, GitBranchOutput } from "../../types.js";
|
|
8
11
|
/**
|
|
9
12
|
* Branch operations
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Use `gitBranchList`, `gitBranchAdd` or `gitBranchDelete` (git.branch.list,
|
|
15
|
+
* git.branch.add, git.branch.delete).
|
|
10
16
|
*/
|
|
11
17
|
export declare function gitBranch(input: GitBranchInput, ctx?: GitContext): Promise<GitBranchOutput>;
|
|
12
18
|
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/branch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/branch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAK3C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAiBrG"}
|
|
@@ -1,54 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* git.branch procedure
|
|
2
|
+
* git.branch procedure (deprecated)
|
|
3
3
|
*
|
|
4
|
-
* Branch operations
|
|
4
|
+
* Branch operations. Since roadmap R40, git.branch.list, git.branch.add and git.branch.delete do
|
|
5
|
+
* this, one procedure for each operation. This procedure stays for one release, and calls them.
|
|
6
|
+
* Its inputs and outputs do not change. The current branch comes from `git symbolic-ref`, so a
|
|
7
|
+
* repository without commits works now too (before, `git rev-parse --abbrev-ref HEAD` failed).
|
|
5
8
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
9
|
+
import {} from "./run.js";
|
|
10
|
+
import { currentBranch } from "./refs.js";
|
|
11
|
+
import { gitBranchList } from "./branch/list.js";
|
|
12
|
+
import { gitBranchAdd } from "./branch/add.js";
|
|
13
|
+
import { gitBranchDelete } from "./branch/delete.js";
|
|
8
14
|
/**
|
|
9
15
|
* Branch operations
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Use `gitBranchList`, `gitBranchAdd` or `gitBranchDelete` (git.branch.list,
|
|
18
|
+
* git.branch.add, git.branch.delete).
|
|
10
19
|
*/
|
|
11
20
|
export async function gitBranch(input, ctx = {}) {
|
|
12
21
|
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
22
|
// Delete branch
|
|
17
23
|
if (del && name) {
|
|
18
|
-
await
|
|
19
|
-
return { deleted: name, current };
|
|
24
|
+
await gitBranchDelete({ name, cwd }, ctx);
|
|
25
|
+
return { deleted: name, current: await currentBranch({ cwd, signal: ctx.signal }) };
|
|
20
26
|
}
|
|
21
27
|
// Create branch
|
|
22
28
|
if (name && !list) {
|
|
23
|
-
await
|
|
24
|
-
return { created: name, current };
|
|
29
|
+
await gitBranchAdd({ name, cwd }, ctx);
|
|
30
|
+
return { created: name, current: await currentBranch({ cwd, signal: ctx.signal }) };
|
|
25
31
|
}
|
|
26
32
|
// List branches
|
|
27
|
-
|
|
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 };
|
|
33
|
+
return gitBranchList({ remote, cwd }, ctx);
|
|
53
34
|
}
|
|
54
35
|
//# sourceMappingURL=branch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../../src/procedures/git/branch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../../src/procedures/git/branch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmB,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,GAAG,GAAe,EAAE;IACzE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAEvD,gBAAgB;IAChB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;IACtF,CAAC;IAED,gBAAgB;IAChB,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;IACtF,CAAC;IAED,gBAAgB;IAChB,OAAO,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { type GitContext } from "./run.js";
|
|
7
7
|
import type { GitCommitInput, GitCommitOutput } from "../../types.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* This function makes a commit. With `paths`, the commit has only those pathspecs, as they are in
|
|
10
|
+
* the working tree (`git commit -- <paths>`), and the other staged changes stay in the index.
|
|
10
11
|
*/
|
|
11
12
|
export declare function gitCommit(input: GitCommitInput, ctx?: GitContext): Promise<GitCommitOutput>;
|
|
12
13
|
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;GAGG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAuCrG"}
|
|
@@ -4,26 +4,32 @@
|
|
|
4
4
|
* Create commit
|
|
5
5
|
*/
|
|
6
6
|
import { git } from "./run.js";
|
|
7
|
+
import { parsePorcelainV1 } from "./porcelain.js";
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* This function makes a commit. With `paths`, the commit has only those pathspecs, as they are in
|
|
10
|
+
* the working tree (`git commit -- <paths>`), and the other staged changes stay in the index.
|
|
9
11
|
*/
|
|
10
12
|
export async function gitCommit(input, ctx = {}) {
|
|
11
13
|
const { message, all, amend, cwd } = input;
|
|
14
|
+
const paths = input.paths !== undefined && input.paths.length > 0 ? input.paths : undefined;
|
|
12
15
|
const run = { cwd, signal: ctx.signal };
|
|
13
|
-
|
|
16
|
+
if (all && paths) {
|
|
17
|
+
throw new Error("git.commit cannot use all and paths together: git refuses -a with paths");
|
|
18
|
+
}
|
|
19
|
+
// Check if there's anything to commit (unless amending). Each entry has two status letters
|
|
20
|
+
// "XY": X is the index, Y the work tree, "??" an untracked file. Without -a, only a staged
|
|
21
|
+
// change counts. With -a, a change of a tracked file counts too. With paths, git commits each
|
|
22
|
+
// change of a tracked file in those paths, staged or not. An untracked file is never a change
|
|
23
|
+
// to commit. (Before, any line counted, so an untracked file or an unstaged change made git
|
|
24
|
+
// commit fail with "nothing added to commit": roadmap R33.)
|
|
14
25
|
if (!amend) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
const statusArgs = ["status", "--porcelain=v1", "-z", ...(paths ? ["--", ...paths] : [])];
|
|
27
|
+
const entries = parsePorcelainV1(await git(statusArgs, run));
|
|
28
|
+
const tracked = entries.filter((entry) => entry.xy !== "??" && entry.xy !== "!!");
|
|
29
|
+
const staged = tracked.filter((entry) => entry.xy[0] !== " ");
|
|
30
|
+
if ((all || paths ? tracked : staged).length === 0) {
|
|
18
31
|
return { hash: "", message: "", author: "", date: "", skipped: true };
|
|
19
32
|
}
|
|
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
33
|
}
|
|
28
34
|
const args = ["commit"];
|
|
29
35
|
if (all)
|
|
@@ -31,6 +37,9 @@ export async function gitCommit(input, ctx = {}) {
|
|
|
31
37
|
if (amend)
|
|
32
38
|
args.push("--amend");
|
|
33
39
|
args.push("-m", message);
|
|
40
|
+
// After "--", git reads each value as a pathspec, also a value that starts with "-"
|
|
41
|
+
if (paths)
|
|
42
|
+
args.push("--", ...paths);
|
|
34
43
|
await git(args, run);
|
|
35
44
|
// Get commit info
|
|
36
45
|
const format = "--format=%H%n%s%n%an%n%ci";
|
|
@@ -1 +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;
|
|
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;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD;;;GAGG;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,KAAK,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,CAA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,IAAI,EAAE,CAAC;QACxE,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,GAAG;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzB,oFAAoF;IACpF,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;IAErC,MAAM,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAErB,kBAAkB;IAClB,MAAM,MAAM,GAAG,2BAA2B,CAAC;IAC3C,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -12,4 +12,23 @@ export { gitInit } from "./init.js";
|
|
|
12
12
|
export { gitRemote, gitRemoteSet } from "./remote.js";
|
|
13
13
|
export { gitFetch } from "./fetch.js";
|
|
14
14
|
export { gitStashList, gitStashPush, gitStashPop, gitStashApply, gitStashDrop, gitStashExport, gitStashImport, } from "./stash.js";
|
|
15
|
+
export { gitShow } from "./show.js";
|
|
16
|
+
export { gitBlame } from "./blame.js";
|
|
17
|
+
export { gitTagList } from "./tag/list.js";
|
|
18
|
+
export { gitTagAdd } from "./tag/add.js";
|
|
19
|
+
export { gitTagDelete } from "./tag/delete.js";
|
|
20
|
+
export { gitRevParse } from "./revParse.js";
|
|
21
|
+
export { gitReset } from "./reset.js";
|
|
22
|
+
export { gitRestore } from "./restore.js";
|
|
23
|
+
export { gitMerge } from "./merge.js";
|
|
24
|
+
export { gitMergeAbort } from "./merge/abort.js";
|
|
25
|
+
export { gitRebase } from "./rebase.js";
|
|
26
|
+
export { gitRebaseContinue } from "./rebase/continue.js";
|
|
27
|
+
export { gitRebaseAbort } from "./rebase/abort.js";
|
|
28
|
+
export { gitWorktreeList } from "./worktree/list.js";
|
|
29
|
+
export { gitWorktreeAdd } from "./worktree/add.js";
|
|
30
|
+
export { gitWorktreeRemove } from "./worktree/remove.js";
|
|
31
|
+
export { gitBranchList } from "./branch/list.js";
|
|
32
|
+
export { gitBranchAdd } from "./branch/add.js";
|
|
33
|
+
export { gitBranchDelete } from "./branch/delete.js";
|
|
15
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,WAA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AAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -12,4 +12,23 @@ export { gitInit } from "./init.js";
|
|
|
12
12
|
export { gitRemote, gitRemoteSet } from "./remote.js";
|
|
13
13
|
export { gitFetch } from "./fetch.js";
|
|
14
14
|
export { gitStashList, gitStashPush, gitStashPop, gitStashApply, gitStashDrop, gitStashExport, gitStashImport, } from "./stash.js";
|
|
15
|
+
export { gitShow } from "./show.js";
|
|
16
|
+
export { gitBlame } from "./blame.js";
|
|
17
|
+
export { gitTagList } from "./tag/list.js";
|
|
18
|
+
export { gitTagAdd } from "./tag/add.js";
|
|
19
|
+
export { gitTagDelete } from "./tag/delete.js";
|
|
20
|
+
export { gitRevParse } from "./revParse.js";
|
|
21
|
+
export { gitReset } from "./reset.js";
|
|
22
|
+
export { gitRestore } from "./restore.js";
|
|
23
|
+
export { gitMerge } from "./merge.js";
|
|
24
|
+
export { gitMergeAbort } from "./merge/abort.js";
|
|
25
|
+
export { gitRebase } from "./rebase.js";
|
|
26
|
+
export { gitRebaseContinue } from "./rebase/continue.js";
|
|
27
|
+
export { gitRebaseAbort } from "./rebase/abort.js";
|
|
28
|
+
export { gitWorktreeList } from "./worktree/list.js";
|
|
29
|
+
export { gitWorktreeAdd } from "./worktree/add.js";
|
|
30
|
+
export { gitWorktreeRemove } from "./worktree/remove.js";
|
|
31
|
+
export { gitBranchList } from "./branch/list.js";
|
|
32
|
+
export { gitBranchAdd } from "./branch/add.js";
|
|
33
|
+
export { gitBranchDelete } from "./branch/delete.js";
|
|
15
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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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W,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
* git.init procedure
|
|
3
3
|
*
|
|
4
4
|
* Initialize a git repository
|
|
5
|
+
*
|
|
6
|
+
* The procedure looks for `.git` in the folder itself. Before, it called `fs.exists` through
|
|
7
|
+
* `ctx.client`, so a registry of `gitModule` alone (`createRegistry(gitModule)`) did not have the
|
|
8
|
+
* procedure that it called, and `git.init` always failed there (roadmap R33).
|
|
5
9
|
*/
|
|
6
|
-
import type
|
|
10
|
+
import { type GitContext } from "./run.js";
|
|
7
11
|
import type { GitInitInput, GitInitOutput } from "../../types.js";
|
|
8
12
|
/**
|
|
9
13
|
* Initialize a git repository
|
|
10
14
|
*/
|
|
11
|
-
export declare function gitInit(input: GitInitInput, ctx
|
|
15
|
+
export declare function gitInit(input: GitInitInput, ctx?: GitContext): Promise<GitInitOutput>;
|
|
12
16
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/init.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAElE;;GAEG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB/F"}
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
* git.init procedure
|
|
3
3
|
*
|
|
4
4
|
* Initialize a git repository
|
|
5
|
+
*
|
|
6
|
+
* The procedure looks for `.git` in the folder itself. Before, it called `fs.exists` through
|
|
7
|
+
* `ctx.client`, so a registry of `gitModule` alone (`createRegistry(gitModule)`) did not have the
|
|
8
|
+
* procedure that it called, and `git.init` always failed there (roadmap R33).
|
|
5
9
|
*/
|
|
10
|
+
import { access } from "node:fs/promises";
|
|
6
11
|
import { join, resolve } from "node:path";
|
|
7
12
|
import { git } from "./run.js";
|
|
8
13
|
/**
|
|
9
14
|
* Initialize a git repository
|
|
10
15
|
*/
|
|
11
|
-
export async function gitInit(input, ctx) {
|
|
16
|
+
export async function gitInit(input, ctx = {}) {
|
|
12
17
|
const cwd = input.cwd ? resolve(input.cwd) : process.cwd();
|
|
13
|
-
// Check if already a git repo
|
|
18
|
+
// Check if already a git repo (as fs.exists did: an error of the check means "no")
|
|
14
19
|
const gitDir = join(cwd, ".git");
|
|
15
|
-
const
|
|
16
|
-
const alreadyExists = existsResult.exists;
|
|
20
|
+
const alreadyExists = await access(gitDir).then(() => true, () => false);
|
|
17
21
|
if (!alreadyExists) {
|
|
18
22
|
const args = ["init"];
|
|
19
23
|
if (input.bare) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/procedures/git/init.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/procedures/git/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAAmB,EAAE,GAAG,GAAe,EAAE;IACrE,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAE3D,mFAAmF;IACnF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAC7C,GAAG,EAAE,CAAC,IAAI,EACV,GAAG,EAAE,CAAC,KAAK,CACZ,CAAC;IAEF,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,GAAa,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,oBAAoB,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,CAAC,aAAa;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.merge.abort procedure
|
|
3
|
+
*
|
|
4
|
+
* Stop a merge that has conflicts (roadmap R40). Git puts back the branch and the files as they
|
|
5
|
+
* were before the merge. The resolutions of the conflicts are lost. Without a merge, the call
|
|
6
|
+
* fails.
|
|
7
|
+
*/
|
|
8
|
+
import { type GitContext } from "../run.js";
|
|
9
|
+
import type { GitMergeAbortInput, GitMergeAbortOutput } from "../../../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Stop a merge that has conflicts
|
|
12
|
+
*/
|
|
13
|
+
export declare function gitMergeAbort(input: GitMergeAbortInput, ctx?: GitContext): Promise<GitMergeAbortOutput>;
|
|
14
|
+
//# sourceMappingURL=abort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../../../src/procedures/git/merge/abort.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEjF;;GAEG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,GAAE,UAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAIjH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.merge.abort procedure
|
|
3
|
+
*
|
|
4
|
+
* Stop a merge that has conflicts (roadmap R40). Git puts back the branch and the files as they
|
|
5
|
+
* were before the merge. The resolutions of the conflicts are lost. Without a merge, the call
|
|
6
|
+
* fails.
|
|
7
|
+
*/
|
|
8
|
+
import { git } from "../run.js";
|
|
9
|
+
import { headHash } from "../refs.js";
|
|
10
|
+
/**
|
|
11
|
+
* Stop a merge that has conflicts
|
|
12
|
+
*/
|
|
13
|
+
export async function gitMergeAbort(input, ctx = {}) {
|
|
14
|
+
const run = { cwd: input.cwd, signal: ctx.signal };
|
|
15
|
+
await git(["merge", "--abort"], run);
|
|
16
|
+
return { aborted: true, hash: await headHash(run) };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../../src/procedures/git/merge/abort.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAmB,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAyB,EAAE,GAAG,GAAe,EAAE;IACjF,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IACnD,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.merge procedure
|
|
3
|
+
*
|
|
4
|
+
* Merge a branch or a commit into the current branch (roadmap R40).
|
|
5
|
+
*
|
|
6
|
+
* A merge that stops on conflicts is a result, not an error: `conflict` is true, and `conflicts`
|
|
7
|
+
* names the files. Then resolve them and call git.commit, or call git.merge.abort. Git does not
|
|
8
|
+
* start an editor for the message of the merge commit.
|
|
9
|
+
*/
|
|
10
|
+
import { type GitContext } from "./run.js";
|
|
11
|
+
import type { GitMergeInput, GitMergeOutput } from "../../types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Merge a branch or a commit into the current branch
|
|
14
|
+
*/
|
|
15
|
+
export declare function gitMerge(input: GitMergeInput, ctx?: GitContext): Promise<GitMergeOutput>;
|
|
16
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhD,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,CAuBlG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git.merge procedure
|
|
3
|
+
*
|
|
4
|
+
* Merge a branch or a commit into the current branch (roadmap R40).
|
|
5
|
+
*
|
|
6
|
+
* A merge that stops on conflicts is a result, not an error: `conflict` is true, and `conflicts`
|
|
7
|
+
* names the files. Then resolve them and call git.commit, or call git.merge.abort. Git does not
|
|
8
|
+
* start an editor for the message of the merge commit.
|
|
9
|
+
*/
|
|
10
|
+
import { gitArg } from "./args.js";
|
|
11
|
+
import { git } from "./run.js";
|
|
12
|
+
import { commitOf, conflictedFiles, headHash, NO_EDITOR, stoppedOnConflict } from "./refs.js";
|
|
13
|
+
/**
|
|
14
|
+
* Merge a branch or a commit into the current branch
|
|
15
|
+
*/
|
|
16
|
+
export async function gitMerge(input, ctx = {}) {
|
|
17
|
+
const { ref, message, cwd } = input;
|
|
18
|
+
const fastForward = input.fastForward ?? "auto";
|
|
19
|
+
const run = { cwd, signal: ctx.signal };
|
|
20
|
+
const target = await commitOf(ref, run);
|
|
21
|
+
const before = await headHash(run);
|
|
22
|
+
const args = ["merge", "--no-edit"];
|
|
23
|
+
if (fastForward === "only")
|
|
24
|
+
args.push("--ff-only");
|
|
25
|
+
if (fastForward === "never")
|
|
26
|
+
args.push("--no-ff");
|
|
27
|
+
if (message !== undefined)
|
|
28
|
+
args.push("-m", message);
|
|
29
|
+
args.push(gitArg("ref", ref));
|
|
30
|
+
try {
|
|
31
|
+
await git(args, { ...run, env: NO_EDITOR });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (!stoppedOnConflict(error))
|
|
35
|
+
throw error;
|
|
36
|
+
return { ref, hash: before, fastForward: false, upToDate: false, conflict: true, conflicts: await conflictedFiles(run) };
|
|
37
|
+
}
|
|
38
|
+
const after = await headHash(run);
|
|
39
|
+
return { ref, hash: after, fastForward: after !== before && after === target, upToDate: after === before, conflict: false };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/procedures/git/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9F;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAoB,EAAE,GAAG,GAAe,EAAE;IACvE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,MAAM,CAAC;IAChD,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,C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
|
|
1
|
+
/**
|
|
2
|
+
* The status letters of git, and a parser of `git status --porcelain=v1 -z`.
|
|
3
|
+
*
|
|
4
|
+
* With `-z`, git writes each path as it is: no quotes. A rename or a copy gives its new path in
|
|
5
|
+
* the entry, and its old path in the next field.
|
|
6
|
+
*/
|
|
7
|
+
import type { GitStatusFile } from "../../types.js";
|
|
8
|
+
/** One entry of `git status --porcelain=v1 -z`. */
|
|
9
|
+
export interface GitPorcelainEntry extends GitStatusFile {
|
|
10
|
+
/** The two status letters: the index, then the work tree. "??" is untracked and "!!" is ignored. */
|
|
11
|
+
xy: string;
|
|
12
|
+
}
|
|
13
|
+
/** This function gives the status of one entry from its two status letters (index, then work tree). */
|
|
14
|
+
export declare function classifyStatus(xy: string): Pick<GitStatusFile, "status" | "staged">;
|
|
15
|
+
/**
|
|
16
|
+
* This function reads the output of `git status --porcelain=v1 -z`. Each entry has its status
|
|
17
|
+
* letters, its exact path, and for a rename or a copy the old path in `from`. It skips the
|
|
18
|
+
* branch line of `--branch`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const output = await git(["status", "--porcelain=v1", "-z", "--untracked-files=all", "--", "notes"]);
|
|
23
|
+
* const untracked = parsePorcelainV1(output).filter((entry) => entry.status === "untracked");
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function parsePorcelainV1(output: string): GitPorcelainEntry[];
|
|
27
|
+
//# sourceMappingURL=porcelain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"porcelain.d.ts","sourceRoot":"","sources":["../../../src/procedures/git/porcelain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,mDAAmD;AACnD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,oGAAoG;IACpG,EAAE,EAAE,MAAM,CAAC;CACZ;AAKD,uGAAuG;AACvG,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAenF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAcpE"}
|