workspace-tools 0.41.5 → 0.41.7
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/lib/git/branchRefs.d.ts +36 -0
- package/lib/git/branchRefs.js +84 -0
- package/lib/git/branchRefs.js.map +1 -0
- package/lib/git/config.d.ts +16 -0
- package/lib/git/config.js +39 -4
- package/lib/git/config.js.map +1 -1
- package/lib/git/fetchRemote.d.ts +13 -0
- package/lib/git/fetchRemote.js +56 -0
- package/lib/git/fetchRemote.js.map +1 -0
- package/lib/git/getChanges.d.ts +54 -0
- package/lib/git/getChanges.js +138 -0
- package/lib/git/getChanges.js.map +1 -0
- package/lib/git/getCurrentHash.d.ts +8 -0
- package/lib/git/getCurrentHash.js +24 -0
- package/lib/git/getCurrentHash.js.map +1 -0
- package/lib/git/getDefaultRemote.d.ts +14 -3
- package/lib/git/getDefaultRemote.js +92 -53
- package/lib/git/getDefaultRemote.js.map +1 -1
- package/lib/git/getDefaultRemoteBranch.d.ts +29 -2
- package/lib/git/getDefaultRemoteBranch.js +61 -21
- package/lib/git/getDefaultRemoteBranch.js.map +1 -1
- package/lib/git/getFileAddedHash.d.ts +10 -0
- package/lib/git/getFileAddedHash.js +24 -0
- package/lib/git/getFileAddedHash.js.map +1 -0
- package/lib/git/getFileFromRef.d.ts +11 -0
- package/lib/git/getFileFromRef.js +22 -0
- package/lib/git/getFileFromRef.js.map +1 -0
- package/lib/git/getRecentCommitMessages.d.ts +10 -0
- package/lib/git/getRecentCommitMessages.js +27 -0
- package/lib/git/getRecentCommitMessages.js.map +1 -0
- package/lib/git/getRemotes.d.ts +14 -0
- package/lib/git/getRemotes.js +53 -0
- package/lib/git/getRemotes.js.map +1 -0
- package/lib/git/gitUtilities.d.ts +12 -212
- package/lib/git/gitUtilities.js +38 -448
- package/lib/git/gitUtilities.js.map +1 -1
- package/lib/git/index.d.ts +17 -5
- package/lib/git/index.js +123 -17
- package/lib/git/index.js.map +1 -1
- package/lib/git/init.d.ts +11 -0
- package/lib/git/init.js +48 -0
- package/lib/git/init.js.map +1 -0
- package/lib/git/listAllTrackedFiles.d.ts +12 -0
- package/lib/git/listAllTrackedFiles.js +25 -0
- package/lib/git/listAllTrackedFiles.js.map +1 -0
- package/lib/git/parseRemoteBranch.d.ts +26 -0
- package/lib/git/parseRemoteBranch.js +77 -0
- package/lib/git/parseRemoteBranch.js.map +1 -0
- package/lib/git/revertLocalChanges.d.ts +9 -0
- package/lib/git/revertLocalChanges.js +42 -0
- package/lib/git/revertLocalChanges.js.map +1 -0
- package/lib/git/stageAndCommit.d.ts +21 -0
- package/lib/git/stageAndCommit.js +69 -0
- package/lib/git/stageAndCommit.js.map +1 -0
- package/lib/git/types.d.ts +5 -2
- package/lib/git/types.js.map +1 -1
- package/lib/workspaces/getCatalogVersion.d.ts +8 -3
- package/lib/workspaces/getCatalogVersion.js +9 -3
- package/lib/workspaces/getCatalogVersion.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GitBranchOptions, GitCommonOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current branch name.
|
|
4
|
+
* In detached HEAD state, returns "HEAD".
|
|
5
|
+
*
|
|
6
|
+
* @returns The branch name if successful, null otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBranchName(options: GitCommonOptions): string | null;
|
|
9
|
+
/** @deprecated Use object params version */
|
|
10
|
+
export declare function getBranchName(cwd: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the full reference path for a given branch.
|
|
13
|
+
* `branch` here is the short branch name, e.g. `branch-name`.
|
|
14
|
+
* @returns The full branch reference (e.g., `refs/heads/branch-name`) if found, null otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function getFullBranchRef(options: GitBranchOptions): string | null;
|
|
17
|
+
/** @deprecated Use object params version */
|
|
18
|
+
export declare function getFullBranchRef(branch: string, cwd: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the short branch name from a full branch reference.
|
|
21
|
+
* @returns The short branch name if successful, null otherwise
|
|
22
|
+
*/
|
|
23
|
+
export declare function getShortBranchName(options: {
|
|
24
|
+
/** The full branch reference (e.g., `refs/heads/branch-name`) */
|
|
25
|
+
fullBranchRef: string;
|
|
26
|
+
} & GitCommonOptions): string | null;
|
|
27
|
+
/** @deprecated Use object params version */
|
|
28
|
+
export declare function getShortBranchName(fullBranchRef: string, cwd: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the remote tracking branch for the specified branch.
|
|
31
|
+
*
|
|
32
|
+
* @returns The remote branch name (e.g., `origin/main`) if found, null otherwise
|
|
33
|
+
*/
|
|
34
|
+
export declare function getRemoteBranch(options: GitBranchOptions): string | null;
|
|
35
|
+
/** @deprecated Use object params version */
|
|
36
|
+
export declare function getRemoteBranch(branch: string, cwd: string): string | null;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
getBranchName: null,
|
|
7
|
+
getFullBranchRef: null,
|
|
8
|
+
getRemoteBranch: null,
|
|
9
|
+
getShortBranchName: null
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
get getBranchName () {
|
|
19
|
+
return getBranchName;
|
|
20
|
+
},
|
|
21
|
+
get getFullBranchRef () {
|
|
22
|
+
return getFullBranchRef;
|
|
23
|
+
},
|
|
24
|
+
get getRemoteBranch () {
|
|
25
|
+
return getRemoteBranch;
|
|
26
|
+
},
|
|
27
|
+
get getShortBranchName () {
|
|
28
|
+
return getShortBranchName;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _git = require("./git.js");
|
|
32
|
+
function getBranchName(cwdOrOptions) {
|
|
33
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
34
|
+
cwd: cwdOrOptions
|
|
35
|
+
} : cwdOrOptions;
|
|
36
|
+
const results = (0, _git.git)([
|
|
37
|
+
"rev-parse",
|
|
38
|
+
"--abbrev-ref",
|
|
39
|
+
"HEAD"
|
|
40
|
+
], {
|
|
41
|
+
description: "Getting current branch name",
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
return results.success ? results.stdout : null;
|
|
45
|
+
}
|
|
46
|
+
function getFullBranchRef(branchOrOptions, cwd) {
|
|
47
|
+
const { branch, ...options } = typeof branchOrOptions === "string" ? {
|
|
48
|
+
branch: branchOrOptions,
|
|
49
|
+
cwd: cwd
|
|
50
|
+
} : branchOrOptions;
|
|
51
|
+
const showRefResults = (0, _git.git)([
|
|
52
|
+
"show-ref",
|
|
53
|
+
"--heads",
|
|
54
|
+
branch
|
|
55
|
+
], options);
|
|
56
|
+
return showRefResults.success ? showRefResults.stdout.split(" ")[1] : null;
|
|
57
|
+
}
|
|
58
|
+
function getShortBranchName(refOrOptions, cwd) {
|
|
59
|
+
const { fullBranchRef, ...options } = typeof refOrOptions === "string" ? {
|
|
60
|
+
fullBranchRef: refOrOptions,
|
|
61
|
+
cwd: cwd
|
|
62
|
+
} : refOrOptions;
|
|
63
|
+
// The original command `git name-rev --name-only` returned unreliable results if multiple
|
|
64
|
+
// named refs point to the same commit as the branch.
|
|
65
|
+
const showRefResults = (0, _git.git)([
|
|
66
|
+
"rev-parse",
|
|
67
|
+
"--abbrev-ref",
|
|
68
|
+
fullBranchRef
|
|
69
|
+
], options);
|
|
70
|
+
return showRefResults.success ? showRefResults.stdout || null : null;
|
|
71
|
+
}
|
|
72
|
+
function getRemoteBranch(branchOrOptions, cwd) {
|
|
73
|
+
const options = typeof branchOrOptions === "string" ? {
|
|
74
|
+
branch: branchOrOptions,
|
|
75
|
+
cwd: cwd
|
|
76
|
+
} : branchOrOptions;
|
|
77
|
+
const results = (0, _git.git)([
|
|
78
|
+
"rev-parse",
|
|
79
|
+
"--abbrev-ref",
|
|
80
|
+
"--symbolic-full-name",
|
|
81
|
+
`${options.branch}@{u}`
|
|
82
|
+
], options);
|
|
83
|
+
return results.success ? results.stdout.trim() : null;
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/git/branchRefs.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport type { GitBranchOptions, GitCommonOptions } from \"./types.js\";\n\n/**\n * Gets the current branch name.\n * In detached HEAD state, returns \"HEAD\".\n *\n * @returns The branch name if successful, null otherwise\n */\nexport function getBranchName(options: GitCommonOptions): string | null;\n/** @deprecated Use object params version */\nexport function getBranchName(cwd: string): string | null;\nexport function getBranchName(cwdOrOptions: string | GitCommonOptions): string | null {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const results = git([\"rev-parse\", \"--abbrev-ref\", \"HEAD\"], {\n description: \"Getting current branch name\",\n ...options,\n });\n return results.success ? results.stdout : null;\n}\n\n/**\n * Gets the full reference path for a given branch.\n * `branch` here is the short branch name, e.g. `branch-name`.\n * @returns The full branch reference (e.g., `refs/heads/branch-name`) if found, null otherwise\n */\nexport function getFullBranchRef(options: GitBranchOptions): string | null;\n/** @deprecated Use object params version */\nexport function getFullBranchRef(branch: string, cwd: string): string | null;\nexport function getFullBranchRef(branchOrOptions: string | GitBranchOptions, cwd?: string): string | null {\n const { branch, ...options } =\n typeof branchOrOptions === \"string\" ? { branch: branchOrOptions, cwd: cwd! } : branchOrOptions;\n\n const showRefResults = git([\"show-ref\", \"--heads\", branch], options);\n\n return showRefResults.success ? showRefResults.stdout.split(\" \")[1] : null;\n}\n\n/**\n * Gets the short branch name from a full branch reference.\n * @returns The short branch name if successful, null otherwise\n */\nexport function getShortBranchName(\n options: {\n /** The full branch reference (e.g., `refs/heads/branch-name`) */\n fullBranchRef: string;\n } & GitCommonOptions\n): string | null;\n/** @deprecated Use object params version */\nexport function getShortBranchName(fullBranchRef: string, cwd: string): string | null;\nexport function getShortBranchName(\n refOrOptions: string | ({ fullBranchRef: string } & GitCommonOptions),\n cwd?: string\n): string | null {\n const { fullBranchRef, ...options } =\n typeof refOrOptions === \"string\" ? { fullBranchRef: refOrOptions, cwd: cwd! } : refOrOptions;\n\n // The original command `git name-rev --name-only` returned unreliable results if multiple\n // named refs point to the same commit as the branch.\n const showRefResults = git([\"rev-parse\", \"--abbrev-ref\", fullBranchRef], options);\n\n return showRefResults.success ? showRefResults.stdout || null : null;\n}\n\n/**\n * Gets the remote tracking branch for the specified branch.\n *\n * @returns The remote branch name (e.g., `origin/main`) if found, null otherwise\n */\nexport function getRemoteBranch(options: GitBranchOptions): string | null;\n/** @deprecated Use object params version */\nexport function getRemoteBranch(branch: string, cwd: string): string | null;\nexport function getRemoteBranch(branchOrOptions: string | GitBranchOptions, cwd?: string): string | null {\n const options: GitBranchOptions =\n typeof branchOrOptions === \"string\" ? { branch: branchOrOptions, cwd: cwd! } : branchOrOptions;\n\n const results = git([\"rev-parse\", \"--abbrev-ref\", \"--symbolic-full-name\", `${options.branch}@{u}`], options);\n\n return results.success ? results.stdout.trim() : null;\n}\n"],"names":["getBranchName","getFullBranchRef","getRemoteBranch","getShortBranchName","cwdOrOptions","options","cwd","results","git","description","success","stdout","branchOrOptions","branch","showRefResults","split","refOrOptions","fullBranchRef","trim"],"mappings":";;;;;;;;;;;;;;;;;QAYgBA;eAAAA;;QAkBAC;eAAAA;;QA2CAC;eAAAA;;QAtBAC;eAAAA;;;qBAnDI;AAYb,SAASH,cAAcI,YAAuC;IACnE,MAAMC,UAA4B,OAAOD,iBAAiB,WAAW;QAAEE,KAAKF;IAAa,IAAIA;IAE7F,MAAMG,UAAUC,IAAAA,QAAG,EAAC;QAAC;QAAa;QAAgB;KAAO,EAAE;QACzDC,aAAa;QACb,GAAGJ,OAAO;IACZ;IACA,OAAOE,QAAQG,OAAO,GAAGH,QAAQI,MAAM,GAAG;AAC5C;AAUO,SAASV,iBAAiBW,eAA0C,EAAEN,GAAY;IACvF,MAAM,EAAEO,MAAM,EAAE,GAAGR,SAAS,GAC1B,OAAOO,oBAAoB,WAAW;QAAEC,QAAQD;QAAiBN,KAAKA;IAAK,IAAIM;IAEjF,MAAME,iBAAiBN,IAAAA,QAAG,EAAC;QAAC;QAAY;QAAWK;KAAO,EAAER;IAE5D,OAAOS,eAAeJ,OAAO,GAAGI,eAAeH,MAAM,CAACI,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;AACxE;AAcO,SAASZ,mBACda,YAAqE,EACrEV,GAAY;IAEZ,MAAM,EAAEW,aAAa,EAAE,GAAGZ,SAAS,GACjC,OAAOW,iBAAiB,WAAW;QAAEC,eAAeD;QAAcV,KAAKA;IAAK,IAAIU;IAElF,0FAA0F;IAC1F,qDAAqD;IACrD,MAAMF,iBAAiBN,IAAAA,QAAG,EAAC;QAAC;QAAa;QAAgBS;KAAc,EAAEZ;IAEzE,OAAOS,eAAeJ,OAAO,GAAGI,eAAeH,MAAM,IAAI,OAAO;AAClE;AAUO,SAAST,gBAAgBU,eAA0C,EAAEN,GAAY;IACtF,MAAMD,UACJ,OAAOO,oBAAoB,WAAW;QAAEC,QAAQD;QAAiBN,KAAKA;IAAK,IAAIM;IAEjF,MAAML,UAAUC,IAAAA,QAAG,EAAC;QAAC;QAAa;QAAgB;QAAwB,GAAGH,QAAQQ,MAAM,CAAC,IAAI,CAAC;KAAC,EAAER;IAEpG,OAAOE,QAAQG,OAAO,GAAGH,QAAQI,MAAM,CAACO,IAAI,KAAK;AACnD"}
|
package/lib/git/config.d.ts
CHANGED
|
@@ -6,3 +6,19 @@ import { type GitCommonOptions } from "./types.js";
|
|
|
6
6
|
export declare function getConfigValue(options: {
|
|
7
7
|
key: string;
|
|
8
8
|
} & GitCommonOptions): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the user email from the git config.
|
|
11
|
+
* (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)
|
|
12
|
+
*
|
|
13
|
+
* @returns The email string if found, null otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function getUserEmail(options: GitCommonOptions): string | null;
|
|
16
|
+
/** @deprecated Use object params version */
|
|
17
|
+
export declare function getUserEmail(cwd: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the default branch based on `git config init.defaultBranch`, falling back to `master`.
|
|
20
|
+
* (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDefaultBranch(options: GitCommonOptions): string;
|
|
23
|
+
/** @deprecated Use object params version */
|
|
24
|
+
export declare function getDefaultBranch(cwd: string): string;
|
package/lib/git/config.js
CHANGED
|
@@ -2,10 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
getConfigValue: null,
|
|
7
|
+
getDefaultBranch: null,
|
|
8
|
+
getUserEmail: null
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
get getConfigValue () {
|
|
8
18
|
return getConfigValue;
|
|
19
|
+
},
|
|
20
|
+
get getDefaultBranch () {
|
|
21
|
+
return getDefaultBranch;
|
|
22
|
+
},
|
|
23
|
+
get getUserEmail () {
|
|
24
|
+
return getUserEmail;
|
|
9
25
|
}
|
|
10
26
|
});
|
|
11
27
|
const _git = require("./git.js");
|
|
@@ -17,4 +33,23 @@ function getConfigValue(options) {
|
|
|
17
33
|
], gitOptions);
|
|
18
34
|
// command failure here just means it's not set
|
|
19
35
|
return results.success ? results.stdout.trim() : null;
|
|
20
|
-
}
|
|
36
|
+
}
|
|
37
|
+
function getUserEmail(cwdOrOptions) {
|
|
38
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
39
|
+
cwd: cwdOrOptions
|
|
40
|
+
} : cwdOrOptions;
|
|
41
|
+
return getConfigValue({
|
|
42
|
+
key: "user.email",
|
|
43
|
+
...options
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function getDefaultBranch(cwdOrOptions) {
|
|
47
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
48
|
+
cwd: cwdOrOptions
|
|
49
|
+
} : cwdOrOptions;
|
|
50
|
+
// Default to the legacy 'master' for backwards compat and old git clients
|
|
51
|
+
return getConfigValue({
|
|
52
|
+
key: "init.defaultBranch",
|
|
53
|
+
...options
|
|
54
|
+
}) || "master";
|
|
55
|
+
}
|
package/lib/git/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/git/config.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport { type GitCommonOptions } from \"./types.js\";\n\n/**\n * Get the value of a git config key. Returns null if it's not set.\n * (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)\n */\nexport function getConfigValue(options: { key: string } & GitCommonOptions): string | null {\n const { key, ...gitOptions } = options;\n const results = git([\"config\", key], gitOptions);\n // command failure here just means it's not set\n return results.success ? results.stdout.trim() : null;\n}\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/git/config.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport { type GitCommonOptions } from \"./types.js\";\n\n/**\n * Get the value of a git config key. Returns null if it's not set.\n * (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)\n */\nexport function getConfigValue(options: { key: string } & GitCommonOptions): string | null {\n const { key, ...gitOptions } = options;\n const results = git([\"config\", key], gitOptions);\n // command failure here just means it's not set\n return results.success ? results.stdout.trim() : null;\n}\n\n/**\n * Gets the user email from the git config.\n * (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)\n *\n * @returns The email string if found, null otherwise\n */\nexport function getUserEmail(options: GitCommonOptions): string | null;\n/** @deprecated Use object params version */\nexport function getUserEmail(cwd: string): string | null;\nexport function getUserEmail(cwdOrOptions: string | GitCommonOptions): string | null {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n return getConfigValue({ key: \"user.email\", ...options });\n}\n\n/**\n * Gets the default branch based on `git config init.defaultBranch`, falling back to `master`.\n * (Note: setting `throwOnError: true` will cause it to fail if the key is unset.)\n */\nexport function getDefaultBranch(options: GitCommonOptions): string;\n/** @deprecated Use object params version */\nexport function getDefaultBranch(cwd: string): string;\nexport function getDefaultBranch(cwdOrOptions: string | GitCommonOptions): string {\n const options = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n // Default to the legacy 'master' for backwards compat and old git clients\n return getConfigValue({ key: \"init.defaultBranch\", ...options }) || \"master\";\n}\n"],"names":["getConfigValue","getDefaultBranch","getUserEmail","options","key","gitOptions","results","git","success","stdout","trim","cwdOrOptions","cwd"],"mappings":";;;;;;;;;;;;;;;;QAOgBA;eAAAA;;QA4BAC;eAAAA;;QAZAC;eAAAA;;;qBAvBI;AAOb,SAASF,eAAeG,OAA2C;IACxE,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;IAC/B,MAAMG,UAAUC,IAAAA,QAAG,EAAC;QAAC;QAAUH;KAAI,EAAEC;IACrC,+CAA+C;IAC/C,OAAOC,QAAQE,OAAO,GAAGF,QAAQG,MAAM,CAACC,IAAI,KAAK;AACnD;AAWO,SAASR,aAAaS,YAAuC;IAClE,MAAMR,UAA4B,OAAOQ,iBAAiB,WAAW;QAAEC,KAAKD;IAAa,IAAIA;IAC7F,OAAOX,eAAe;QAAEI,KAAK;QAAc,GAAGD,OAAO;IAAC;AACxD;AASO,SAASF,iBAAiBU,YAAuC;IACtE,MAAMR,UAAU,OAAOQ,iBAAiB,WAAW;QAAEC,KAAKD;IAAa,IAAIA;IAE3E,0EAA0E;IAC1E,OAAOX,eAAe;QAAEI,KAAK;QAAsB,GAAGD,OAAO;IAAC,MAAM;AACtE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GitFetchOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fetch from the given remote (and optionally branch) or all remotes.
|
|
4
|
+
* Throws an error on failure by default.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchRemote(options: GitFetchOptions): void;
|
|
7
|
+
/** @deprecated Use object params version */
|
|
8
|
+
export declare function fetchRemote(remote: string, cwd: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Fetch from the given remote and branch. Throws an error on failure.
|
|
11
|
+
* @deprecated Use `fetchRemote({ remote, remoteBranch, cwd })`
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchRemoteBranch(remote: string, remoteBranch: string, cwd: string): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
fetchRemote: null,
|
|
7
|
+
fetchRemoteBranch: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get fetchRemote () {
|
|
17
|
+
return fetchRemote;
|
|
18
|
+
},
|
|
19
|
+
get fetchRemoteBranch () {
|
|
20
|
+
return fetchRemoteBranch;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _git = require("./git.js");
|
|
24
|
+
function fetchRemote(remoteOrOptions, cwd) {
|
|
25
|
+
const { remote, remoteBranch, options, ...gitOptions } = typeof remoteOrOptions === "string" ? {
|
|
26
|
+
remote: remoteOrOptions,
|
|
27
|
+
cwd: cwd
|
|
28
|
+
} : remoteOrOptions;
|
|
29
|
+
if (remoteBranch && !remote) {
|
|
30
|
+
throw new Error('Must provide "remote" when using "remoteBranch" option');
|
|
31
|
+
}
|
|
32
|
+
const fetchArgs = [
|
|
33
|
+
"fetch",
|
|
34
|
+
"--",
|
|
35
|
+
...remote ? [
|
|
36
|
+
remote
|
|
37
|
+
] : [],
|
|
38
|
+
...remoteBranch ? [
|
|
39
|
+
remoteBranch
|
|
40
|
+
] : [],
|
|
41
|
+
...options || []
|
|
42
|
+
];
|
|
43
|
+
(0, _git.git)(fetchArgs, {
|
|
44
|
+
description: remote ? `Fetching ${remoteBranch ? `branch "${remoteBranch}" from ` : ""}remote "${remote}"` : "Fetching all remotes",
|
|
45
|
+
throwOnError: true,
|
|
46
|
+
...gitOptions
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function fetchRemoteBranch(remote, remoteBranch, cwd) {
|
|
50
|
+
fetchRemote({
|
|
51
|
+
remote,
|
|
52
|
+
remoteBranch,
|
|
53
|
+
cwd,
|
|
54
|
+
throwOnError: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/git/fetchRemote.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport type { GitFetchOptions } from \"./types.js\";\n\n/**\n * Fetch from the given remote (and optionally branch) or all remotes.\n * Throws an error on failure by default.\n */\nexport function fetchRemote(options: GitFetchOptions): void;\n/** @deprecated Use object params version */\nexport function fetchRemote(remote: string, cwd: string): void;\nexport function fetchRemote(remoteOrOptions: string | GitFetchOptions, cwd?: string): void {\n const { remote, remoteBranch, options, ...gitOptions } =\n typeof remoteOrOptions === \"string\"\n ? ({ remote: remoteOrOptions, cwd: cwd! } satisfies GitFetchOptions)\n : remoteOrOptions;\n\n if (remoteBranch && !remote) {\n throw new Error('Must provide \"remote\" when using \"remoteBranch\" option');\n }\n\n const fetchArgs = [\n \"fetch\",\n \"--\",\n ...(remote ? [remote] : []),\n ...(remoteBranch ? [remoteBranch] : []),\n ...(options || []),\n ];\n\n git(fetchArgs, {\n description: remote\n ? `Fetching ${remoteBranch ? `branch \"${remoteBranch}\" from ` : \"\"}remote \"${remote}\"`\n : \"Fetching all remotes\",\n throwOnError: true,\n ...gitOptions,\n });\n}\n\n/**\n * Fetch from the given remote and branch. Throws an error on failure.\n * @deprecated Use `fetchRemote({ remote, remoteBranch, cwd })`\n */\nexport function fetchRemoteBranch(remote: string, remoteBranch: string, cwd: string): void {\n fetchRemote({ remote, remoteBranch, cwd, throwOnError: true });\n}\n"],"names":["fetchRemote","fetchRemoteBranch","remoteOrOptions","cwd","remote","remoteBranch","options","gitOptions","Error","fetchArgs","git","description","throwOnError"],"mappings":";;;;;;;;;;;;;;;QAUgBA;eAAAA;;QA+BAC;eAAAA;;;qBAzCI;AAUb,SAASD,YAAYE,eAAyC,EAAEC,GAAY;IACjF,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAEC,OAAO,EAAE,GAAGC,YAAY,GACpD,OAAOL,oBAAoB,WACtB;QAAEE,QAAQF;QAAiBC,KAAKA;IAAK,IACtCD;IAEN,IAAIG,gBAAgB,CAACD,QAAQ;QAC3B,MAAM,IAAII,MAAM;IAClB;IAEA,MAAMC,YAAY;QAChB;QACA;WACIL,SAAS;YAACA;SAAO,GAAG,EAAE;WACtBC,eAAe;YAACA;SAAa,GAAG,EAAE;WAClCC,WAAW,EAAE;KAClB;IAEDI,IAAAA,QAAG,EAACD,WAAW;QACbE,aAAaP,SACT,CAAC,SAAS,EAAEC,eAAe,CAAC,QAAQ,EAAEA,aAAa,OAAO,CAAC,GAAG,GAAG,QAAQ,EAAED,OAAO,CAAC,CAAC,GACpF;QACJQ,cAAc;QACd,GAAGL,UAAU;IACf;AACF;AAMO,SAASN,kBAAkBG,MAAc,EAAEC,YAAoB,EAAEF,GAAW;IACjFH,YAAY;QAAEI;QAAQC;QAAcF;QAAKS,cAAc;IAAK;AAC9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GetChangesBetweenRefsOptions, GitBranchOptions, GitCommonOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets file paths with changes between two git references (commits, branches, tags).
|
|
4
|
+
* Throws an error on failure by default.
|
|
5
|
+
*
|
|
6
|
+
* @returns An array of file paths that have changed
|
|
7
|
+
*/
|
|
8
|
+
export declare function getChangesBetweenRefs(options: GetChangesBetweenRefsOptions): string[];
|
|
9
|
+
/** @deprecated Use object param version */
|
|
10
|
+
export declare function getChangesBetweenRefs(fromRef: string, toRef: string, options: string[], pattern: string, cwd: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Gets file paths with changes between the current branch and the given branch.
|
|
13
|
+
* Throws an error on failure.
|
|
14
|
+
*
|
|
15
|
+
* @returns An array of relative file paths that have changed
|
|
16
|
+
* @deprecated Use `getBranchChanges({ branch, cwd })`
|
|
17
|
+
*/
|
|
18
|
+
export declare function getChanges(branch: string, cwd: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Gets file paths with changes between the branch and the merge-base.
|
|
21
|
+
* Throws an error on failure by default.
|
|
22
|
+
*
|
|
23
|
+
* @returns An array of relative file paths that have changed
|
|
24
|
+
*/
|
|
25
|
+
export declare function getBranchChanges(options: GitBranchOptions): string[];
|
|
26
|
+
/** @deprecated Use object params version */
|
|
27
|
+
export declare function getBranchChanges(branch: string, cwd: string): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Get a list of files with untracked changes.
|
|
30
|
+
* Throws an error on failure by default.
|
|
31
|
+
*
|
|
32
|
+
* @returns An array of file paths with untracked changes
|
|
33
|
+
*/
|
|
34
|
+
export declare function getUntrackedChanges(options: GitCommonOptions): string[];
|
|
35
|
+
/** @deprecated Use object params version */
|
|
36
|
+
export declare function getUntrackedChanges(cwd: string): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Gets file paths with changes that have not been staged yet.
|
|
39
|
+
* Throws an error on failure by default.
|
|
40
|
+
*
|
|
41
|
+
* @returns An array of relative file paths with unstaged changes
|
|
42
|
+
*/
|
|
43
|
+
export declare function getUnstagedChanges(options: GitCommonOptions): string[];
|
|
44
|
+
/** @deprecated Use object params version */
|
|
45
|
+
export declare function getUnstagedChanges(cwd: string): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Gets all files with staged changes (files added to the index).
|
|
48
|
+
* Throws an error on failure by default.
|
|
49
|
+
*
|
|
50
|
+
* @returns An array of relative file paths that have been staged
|
|
51
|
+
*/
|
|
52
|
+
export declare function getStagedChanges(options: GitCommonOptions): string[];
|
|
53
|
+
/** @deprecated Use object params version */
|
|
54
|
+
export declare function getStagedChanges(cwd: string): string[];
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
getBranchChanges: null,
|
|
7
|
+
getChanges: null,
|
|
8
|
+
getChangesBetweenRefs: null,
|
|
9
|
+
getStagedChanges: null,
|
|
10
|
+
getUnstagedChanges: null,
|
|
11
|
+
getUntrackedChanges: null
|
|
12
|
+
});
|
|
13
|
+
function _export(target, all) {
|
|
14
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
_export(exports, {
|
|
20
|
+
get getBranchChanges () {
|
|
21
|
+
return getBranchChanges;
|
|
22
|
+
},
|
|
23
|
+
get getChanges () {
|
|
24
|
+
return getChanges;
|
|
25
|
+
},
|
|
26
|
+
get getChangesBetweenRefs () {
|
|
27
|
+
return getChangesBetweenRefs;
|
|
28
|
+
},
|
|
29
|
+
get getStagedChanges () {
|
|
30
|
+
return getStagedChanges;
|
|
31
|
+
},
|
|
32
|
+
get getUnstagedChanges () {
|
|
33
|
+
return getUnstagedChanges;
|
|
34
|
+
},
|
|
35
|
+
get getUntrackedChanges () {
|
|
36
|
+
return getUntrackedChanges;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const _git = require("./git.js");
|
|
40
|
+
const diffArgs = [
|
|
41
|
+
"--no-pager",
|
|
42
|
+
"diff",
|
|
43
|
+
"--name-only",
|
|
44
|
+
"--relative"
|
|
45
|
+
];
|
|
46
|
+
function getChangesBetweenRefs(fromRef, toRef, options, pattern, cwd) {
|
|
47
|
+
let gitOptions;
|
|
48
|
+
if (typeof fromRef === "string") {
|
|
49
|
+
gitOptions = {
|
|
50
|
+
cwd: cwd
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
({ fromRef, toRef, options, pattern, ...gitOptions } = fromRef);
|
|
54
|
+
}
|
|
55
|
+
const range = `${fromRef}...${toRef || ""}`;
|
|
56
|
+
const results = (0, _git.git)([
|
|
57
|
+
...diffArgs,
|
|
58
|
+
...options || [],
|
|
59
|
+
range,
|
|
60
|
+
...pattern ? [
|
|
61
|
+
"--",
|
|
62
|
+
pattern
|
|
63
|
+
] : []
|
|
64
|
+
], {
|
|
65
|
+
description: `Gathering information about changes between refs (${range})`,
|
|
66
|
+
throwOnError: true,
|
|
67
|
+
...gitOptions
|
|
68
|
+
});
|
|
69
|
+
return (0, _git.processGitOutput)(results, {
|
|
70
|
+
excludeNodeModules: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function getChanges(branch, cwd) {
|
|
74
|
+
return getChangesBetweenRefs({
|
|
75
|
+
fromRef: branch,
|
|
76
|
+
cwd,
|
|
77
|
+
throwOnError: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function getBranchChanges(branchOrOptions, cwd) {
|
|
81
|
+
const { branch, ...options } = typeof branchOrOptions === "string" ? {
|
|
82
|
+
branch: branchOrOptions,
|
|
83
|
+
cwd: cwd
|
|
84
|
+
} : branchOrOptions;
|
|
85
|
+
return getChangesBetweenRefs({
|
|
86
|
+
fromRef: branch,
|
|
87
|
+
throwOnError: true,
|
|
88
|
+
...options
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function getUntrackedChanges(cwdOrOptions) {
|
|
92
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
93
|
+
cwd: cwdOrOptions
|
|
94
|
+
} : cwdOrOptions;
|
|
95
|
+
const results = (0, _git.git)([
|
|
96
|
+
"ls-files",
|
|
97
|
+
"--others",
|
|
98
|
+
"--exclude-standard"
|
|
99
|
+
], {
|
|
100
|
+
description: "Gathering information about untracked changes",
|
|
101
|
+
throwOnError: true,
|
|
102
|
+
...options
|
|
103
|
+
});
|
|
104
|
+
return (0, _git.processGitOutput)(results, {
|
|
105
|
+
excludeNodeModules: true
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function getUnstagedChanges(cwdOrOptions) {
|
|
109
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
110
|
+
cwd: cwdOrOptions
|
|
111
|
+
} : cwdOrOptions;
|
|
112
|
+
const results = (0, _git.git)([
|
|
113
|
+
...diffArgs
|
|
114
|
+
], {
|
|
115
|
+
description: "Gathering information about unstaged changes",
|
|
116
|
+
throwOnError: true,
|
|
117
|
+
...options
|
|
118
|
+
});
|
|
119
|
+
return (0, _git.processGitOutput)(results, {
|
|
120
|
+
excludeNodeModules: true
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function getStagedChanges(cwdOrOptions) {
|
|
124
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
125
|
+
cwd: cwdOrOptions
|
|
126
|
+
} : cwdOrOptions;
|
|
127
|
+
const results = (0, _git.git)([
|
|
128
|
+
...diffArgs,
|
|
129
|
+
"--staged"
|
|
130
|
+
], {
|
|
131
|
+
description: "Gathering information about staged changes",
|
|
132
|
+
throwOnError: true,
|
|
133
|
+
...options
|
|
134
|
+
});
|
|
135
|
+
return (0, _git.processGitOutput)(results, {
|
|
136
|
+
excludeNodeModules: true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/git/getChanges.ts"],"sourcesContent":["import { git, processGitOutput } from \"./git.js\";\nimport type { GetChangesBetweenRefsOptions, GitBranchOptions, GitCommonOptions } from \"./types.js\";\n\nconst diffArgs = [\"--no-pager\", \"diff\", \"--name-only\", \"--relative\"] as const;\n\n/**\n * Gets file paths with changes between two git references (commits, branches, tags).\n * Throws an error on failure by default.\n *\n * @returns An array of file paths that have changed\n */\nexport function getChangesBetweenRefs(options: GetChangesBetweenRefsOptions): string[];\n/** @deprecated Use object param version */\nexport function getChangesBetweenRefs(\n fromRef: string,\n toRef: string,\n options: string[],\n pattern: string,\n cwd: string\n): string[];\nexport function getChangesBetweenRefs(\n fromRef: string | GetChangesBetweenRefsOptions,\n toRef?: string,\n options?: string[],\n pattern?: string,\n cwd?: string\n): string[] {\n let gitOptions: GitCommonOptions;\n if (typeof fromRef === \"string\") {\n gitOptions = { cwd: cwd! };\n } else {\n ({ fromRef, toRef, options, pattern, ...gitOptions } = fromRef);\n }\n\n const range = `${fromRef}...${toRef || \"\"}`;\n const results = git([...diffArgs, ...(options || []), range, ...(pattern ? [\"--\", pattern] : [])], {\n description: `Gathering information about changes between refs (${range})`,\n throwOnError: true,\n ...gitOptions,\n });\n return processGitOutput(results, { excludeNodeModules: true });\n}\n\n/**\n * Gets file paths with changes between the current branch and the given branch.\n * Throws an error on failure.\n *\n * @returns An array of relative file paths that have changed\n * @deprecated Use `getBranchChanges({ branch, cwd })`\n */\nexport function getChanges(branch: string, cwd: string): string[] {\n return getChangesBetweenRefs({ fromRef: branch, cwd, throwOnError: true });\n}\n\n/**\n * Gets file paths with changes between the branch and the merge-base.\n * Throws an error on failure by default.\n *\n * @returns An array of relative file paths that have changed\n */\nexport function getBranchChanges(options: GitBranchOptions): string[];\n/** @deprecated Use object params version */\nexport function getBranchChanges(branch: string, cwd: string): string[];\nexport function getBranchChanges(branchOrOptions: string | GitBranchOptions, cwd?: string): string[] {\n const { branch, ...options } =\n typeof branchOrOptions === \"string\" ? { branch: branchOrOptions, cwd: cwd! } : branchOrOptions;\n\n return getChangesBetweenRefs({ fromRef: branch, throwOnError: true, ...options });\n}\n\n/**\n * Get a list of files with untracked changes.\n * Throws an error on failure by default.\n *\n * @returns An array of file paths with untracked changes\n */\nexport function getUntrackedChanges(options: GitCommonOptions): string[];\n/** @deprecated Use object params version */\nexport function getUntrackedChanges(cwd: string): string[];\nexport function getUntrackedChanges(cwdOrOptions: string | GitCommonOptions): string[] {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const results = git([\"ls-files\", \"--others\", \"--exclude-standard\"], {\n description: \"Gathering information about untracked changes\",\n throwOnError: true,\n ...options,\n });\n return processGitOutput(results, { excludeNodeModules: true });\n}\n\n/**\n * Gets file paths with changes that have not been staged yet.\n * Throws an error on failure by default.\n *\n * @returns An array of relative file paths with unstaged changes\n */\nexport function getUnstagedChanges(options: GitCommonOptions): string[];\n/** @deprecated Use object params version */\nexport function getUnstagedChanges(cwd: string): string[];\nexport function getUnstagedChanges(cwdOrOptions: string | GitCommonOptions): string[] {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const results = git([...diffArgs], {\n description: \"Gathering information about unstaged changes\",\n throwOnError: true,\n ...options,\n });\n return processGitOutput(results, { excludeNodeModules: true });\n}\n\n/**\n * Gets all files with staged changes (files added to the index).\n * Throws an error on failure by default.\n *\n * @returns An array of relative file paths that have been staged\n */\nexport function getStagedChanges(options: GitCommonOptions): string[];\n/** @deprecated Use object params version */\nexport function getStagedChanges(cwd: string): string[];\nexport function getStagedChanges(cwdOrOptions: string | GitCommonOptions): string[] {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const results = git([...diffArgs, \"--staged\"], {\n description: \"Gathering information about staged changes\",\n throwOnError: true,\n ...options,\n });\n return processGitOutput(results, { excludeNodeModules: true });\n}\n"],"names":["getBranchChanges","getChanges","getChangesBetweenRefs","getStagedChanges","getUnstagedChanges","getUntrackedChanges","diffArgs","fromRef","toRef","options","pattern","cwd","gitOptions","range","results","git","description","throwOnError","processGitOutput","excludeNodeModules","branch","branchOrOptions","cwdOrOptions"],"mappings":";;;;;;;;;;;;;;;;;;;QA+DgBA;eAAAA;;QAbAC;eAAAA;;QA9BAC;eAAAA;;QAmGAC;eAAAA;;QApBAC;eAAAA;;QApBAC;eAAAA;;;qBA/EsB;AAGtC,MAAMC,WAAW;IAAC;IAAc;IAAQ;IAAe;CAAa;AAiB7D,SAASJ,sBACdK,OAA8C,EAC9CC,KAAc,EACdC,OAAkB,EAClBC,OAAgB,EAChBC,GAAY;IAEZ,IAAIC;IACJ,IAAI,OAAOL,YAAY,UAAU;QAC/BK,aAAa;YAAED,KAAKA;QAAK;IAC3B,OAAO;QACJ,CAAA,EAAEJ,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGE,YAAY,GAAGL,OAAM;IAC/D;IAEA,MAAMM,QAAQ,GAAGN,QAAQ,GAAG,EAAEC,SAAS,IAAI;IAC3C,MAAMM,UAAUC,IAAAA,QAAG,EAAC;WAAIT;WAAcG,WAAW,EAAE;QAAGI;WAAWH,UAAU;YAAC;YAAMA;SAAQ,GAAG,EAAE;KAAE,EAAE;QACjGM,aAAa,CAAC,kDAAkD,EAAEH,MAAM,CAAC,CAAC;QAC1EI,cAAc;QACd,GAAGL,UAAU;IACf;IACA,OAAOM,IAAAA,qBAAgB,EAACJ,SAAS;QAAEK,oBAAoB;IAAK;AAC9D;AASO,SAASlB,WAAWmB,MAAc,EAAET,GAAW;IACpD,OAAOT,sBAAsB;QAAEK,SAASa;QAAQT;QAAKM,cAAc;IAAK;AAC1E;AAWO,SAASjB,iBAAiBqB,eAA0C,EAAEV,GAAY;IACvF,MAAM,EAAES,MAAM,EAAE,GAAGX,SAAS,GAC1B,OAAOY,oBAAoB,WAAW;QAAED,QAAQC;QAAiBV,KAAKA;IAAK,IAAIU;IAEjF,OAAOnB,sBAAsB;QAAEK,SAASa;QAAQH,cAAc;QAAM,GAAGR,OAAO;IAAC;AACjF;AAWO,SAASJ,oBAAoBiB,YAAuC;IACzE,MAAMb,UAA4B,OAAOa,iBAAiB,WAAW;QAAEX,KAAKW;IAAa,IAAIA;IAE7F,MAAMR,UAAUC,IAAAA,QAAG,EAAC;QAAC;QAAY;QAAY;KAAqB,EAAE;QAClEC,aAAa;QACbC,cAAc;QACd,GAAGR,OAAO;IACZ;IACA,OAAOS,IAAAA,qBAAgB,EAACJ,SAAS;QAAEK,oBAAoB;IAAK;AAC9D;AAWO,SAASf,mBAAmBkB,YAAuC;IACxE,MAAMb,UAA4B,OAAOa,iBAAiB,WAAW;QAAEX,KAAKW;IAAa,IAAIA;IAE7F,MAAMR,UAAUC,IAAAA,QAAG,EAAC;WAAIT;KAAS,EAAE;QACjCU,aAAa;QACbC,cAAc;QACd,GAAGR,OAAO;IACZ;IACA,OAAOS,IAAAA,qBAAgB,EAACJ,SAAS;QAAEK,oBAAoB;IAAK;AAC9D;AAWO,SAAShB,iBAAiBmB,YAAuC;IACtE,MAAMb,UAA4B,OAAOa,iBAAiB,WAAW;QAAEX,KAAKW;IAAa,IAAIA;IAE7F,MAAMR,UAAUC,IAAAA,QAAG,EAAC;WAAIT;QAAU;KAAW,EAAE;QAC7CU,aAAa;QACbC,cAAc;QACd,GAAGR,OAAO;IACZ;IACA,OAAOS,IAAAA,qBAAgB,EAACJ,SAAS;QAAEK,oBAAoB;IAAK;AAC9D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GitCommonOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current commit hash (SHA).
|
|
4
|
+
* @returns The hash if successful, null otherwise
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCurrentHash(options: GitCommonOptions): string | null;
|
|
7
|
+
/** @deprecated Use object params version */
|
|
8
|
+
export declare function getCurrentHash(cwd: string): string | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getCurrentHash", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getCurrentHash;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _git = require("./git.js");
|
|
12
|
+
function getCurrentHash(cwdOrOptions) {
|
|
13
|
+
const options = typeof cwdOrOptions === "string" ? {
|
|
14
|
+
cwd: cwdOrOptions
|
|
15
|
+
} : cwdOrOptions;
|
|
16
|
+
const results = (0, _git.git)([
|
|
17
|
+
"rev-parse",
|
|
18
|
+
"HEAD"
|
|
19
|
+
], {
|
|
20
|
+
description: "Getting current git hash",
|
|
21
|
+
...options
|
|
22
|
+
});
|
|
23
|
+
return results.success ? results.stdout : null;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/git/getCurrentHash.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport type { GitCommonOptions } from \"./types.js\";\n\n/**\n * Gets the current commit hash (SHA).\n * @returns The hash if successful, null otherwise\n */\nexport function getCurrentHash(options: GitCommonOptions): string | null;\n/** @deprecated Use object params version */\nexport function getCurrentHash(cwd: string): string | null;\nexport function getCurrentHash(cwdOrOptions: string | GitCommonOptions): string | null {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const results = git([\"rev-parse\", \"HEAD\"], {\n description: \"Getting current git hash\",\n ...options,\n });\n\n return results.success ? results.stdout : null;\n}\n"],"names":["getCurrentHash","cwdOrOptions","options","cwd","results","git","description","success","stdout"],"mappings":";;;;+BAUgBA;;;eAAAA;;;qBAVI;AAUb,SAASA,eAAeC,YAAuC;IACpE,MAAMC,UAA4B,OAAOD,iBAAiB,WAAW;QAAEE,KAAKF;IAAa,IAAIA;IAE7F,MAAMG,UAAUC,IAAAA,QAAG,EAAC;QAAC;QAAa;KAAO,EAAE;QACzCC,aAAa;QACb,GAAGJ,OAAO;IACZ;IAEA,OAAOE,QAAQG,OAAO,GAAGH,QAAQI,MAAM,GAAG;AAC5C"}
|
|
@@ -2,16 +2,21 @@ export type GetDefaultRemoteOptions = {
|
|
|
2
2
|
/** Get repository info relative to this directory. */
|
|
3
3
|
cwd: string;
|
|
4
4
|
/**
|
|
5
|
-
* If true, throw an error if remote info can't be found,
|
|
6
|
-
* in package.json
|
|
5
|
+
* If true, throw an error if remote info can't be found, if no `package.json` is found, or if
|
|
6
|
+
* a `repository` is specified in package.json but no matching remote exists.
|
|
7
7
|
*/
|
|
8
8
|
strict?: boolean;
|
|
9
9
|
/** If true, log debug messages about how the remote was chosen */
|
|
10
10
|
verbose?: boolean;
|
|
11
|
+
/** Optional pre-fetched mapping from remote name to remote URL */
|
|
12
|
+
remotes?: Record<string, string>;
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* Get the name of the default remote: the one matching the `repository` field in package.json.
|
|
14
|
-
* Throws if `options.cwd` is not in a git repo
|
|
16
|
+
* Throws if `options.cwd` is not in a git repo.
|
|
17
|
+
*
|
|
18
|
+
* It's recommended to set `strict: true` to also throw if no remotes are defined, no package.json
|
|
19
|
+
* is found, or package.json has a `repository` field but no matching remote exists.
|
|
15
20
|
*
|
|
16
21
|
* The order of preference for returned remotes is:
|
|
17
22
|
* 1. If `repository` is defined in package.json, the remote with a matching URL (if `options.strict`
|
|
@@ -26,3 +31,9 @@ export type GetDefaultRemoteOptions = {
|
|
|
26
31
|
export declare function getDefaultRemote(options: GetDefaultRemoteOptions): string;
|
|
27
32
|
/** @deprecated Use the object param version */
|
|
28
33
|
export declare function getDefaultRemote(cwd: string): string;
|
|
34
|
+
/** Match repository URL from package.json to a git remote. Exported for testing. */
|
|
35
|
+
export declare function _matchRepositoryUrlToRemote(
|
|
36
|
+
/** repository.url from package.json */
|
|
37
|
+
repositoryUrl: string,
|
|
38
|
+
/** Mapping from remote name to remote URL */
|
|
39
|
+
remotes: Record<string, string>, logOrThrow?: (message: string) => void): string | undefined;
|