workspace-tools 0.41.8 → 0.41.9

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.
@@ -1,8 +1,9 @@
1
1
  import { type GetDefaultRemoteOptions } from "./getDefaultRemote.js";
2
+ import type { RemoteBranch } from "./types.js";
2
3
  export type GetDefaultRemoteBranchOptions = GetDefaultRemoteOptions & {
3
4
  /**
4
5
  * Name of branch to use, **without** a remote prefix. If you want to resolve a branch
5
- * that may already include a remote prefix, use {@link resolveRemoteBranch}.
6
+ * that may already include a remote prefix, use {@link resolveRemoteAndBranch}.
6
7
  *
7
8
  * If undefined, uses the default branch name (falling back to `master`).
8
9
  */
@@ -14,7 +15,7 @@ export type GetDefaultRemoteBranchOptions = GetDefaultRemoteOptions & {
14
15
  * Throws if `options.cwd` is not in a git repo.
15
16
  *
16
17
  * If you want to resolve a branch that may already include a remote prefix, use
17
- * {@link resolveRemoteBranch} instead.
18
+ * {@link resolveRemoteAndBranch} instead.
18
19
  *
19
20
  * If `options.strict` is true, throws in the same cases as {@link getDefaultRemote}, {@link getRemotes},
20
21
  * or if querying the default branch from the remote fails.
@@ -28,6 +29,15 @@ export declare function getDefaultRemoteBranch(options: GetDefaultRemoteBranchOp
28
29
  * @deprecated Use the object param version
29
30
  */
30
31
  export declare function getDefaultRemoteBranch(...args: string[]): string;
32
+ /**
33
+ * Resolve a user-provided branch (possibly with a remote) to a fully-qualified remote branch.
34
+ * @returns A fully-qualified target remote branch reference (e.g. `origin/main`)
35
+ * @deprecated Use {@link resolveRemoteAndBranch} instead
36
+ */
37
+ export declare function resolveRemoteBranch(options: Omit<GetDefaultRemoteBranchOptions, "branch" | "remotes"> & {
38
+ /** Branch which might include a remote prefix */
39
+ branch: string | undefined;
40
+ }): string;
31
41
  /**
32
42
  * Resolve a user-provided branch (possibly with a remote) to a fully-qualified remote branch.
33
43
  * First tries the less-expensive {@link parseRemoteBranchPlusRemotes} (compares with remote names
@@ -37,9 +47,9 @@ export declare function getDefaultRemoteBranch(...args: string[]): string;
37
47
  * If `options.strict` is true, throws in the same cases as {@link parseRemoteBranch},
38
48
  * {@link getDefaultRemoteBranch}, {@link getDefaultRemote}, or {@link getRemotes}.
39
49
  *
40
- * @returns A fully-qualified target remote branch reference (e.g. `origin/main`)
50
+ * @returns A fully-qualified target remote branch reference (e.g. `{ remote: "origin", branch: "main" }`)
41
51
  */
42
- export declare function resolveRemoteBranch(options: Omit<GetDefaultRemoteBranchOptions, "branch" | "remotes"> & {
52
+ export declare function resolveRemoteAndBranch(options: Omit<GetDefaultRemoteBranchOptions, "branch" | "remotes"> & {
43
53
  /** Branch which might include a remote prefix */
44
54
  branch: string | undefined;
45
- }): string;
55
+ }): RemoteBranch;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  0 && (module.exports = {
6
6
  getDefaultRemoteBranch: null,
7
+ resolveRemoteAndBranch: null,
7
8
  resolveRemoteBranch: null
8
9
  });
9
10
  function _export(target, all) {
@@ -16,6 +17,9 @@ _export(exports, {
16
17
  get getDefaultRemoteBranch () {
17
18
  return getDefaultRemoteBranch;
18
19
  },
20
+ get resolveRemoteAndBranch () {
21
+ return resolveRemoteAndBranch;
22
+ },
19
23
  get resolveRemoteBranch () {
20
24
  return resolveRemoteBranch;
21
25
  }
@@ -30,10 +34,21 @@ function getDefaultRemoteBranch(...args) {
30
34
  branch: branchOrOptions,
31
35
  cwd: argsCwd
32
36
  } : branchOrOptions;
37
+ const result = getDefaultRemoteAndBranch(options);
38
+ return `${result.remote}/${result.branch}`;
39
+ }
40
+ /**
41
+ * Like {@link getDefaultRemoteBranch} but it returns an object.
42
+ *
43
+ * @returns A branch reference like `{ remote: "upstream", branch: "master" }` or `{ remote: "origin", branch: "main" }`.
44
+ */ function getDefaultRemoteAndBranch(options) {
33
45
  const { cwd, branch } = options;
34
46
  const defaultRemote = (0, _getDefaultRemote.getDefaultRemote)(options);
35
47
  if (branch) {
36
- return `${defaultRemote}/${branch}`;
48
+ return {
49
+ remote: defaultRemote,
50
+ branch
51
+ };
37
52
  }
38
53
  let remoteDefaultBranch;
39
54
  // Get the default branch name from the default remote.
@@ -63,9 +78,16 @@ function getDefaultRemoteBranch(...args) {
63
78
  remoteDefaultBranch || (remoteDefaultBranch = (0, _gitUtilities.getDefaultBranch)({
64
79
  cwd
65
80
  }));
66
- return `${defaultRemote}/${remoteDefaultBranch}`;
81
+ return {
82
+ remote: defaultRemote,
83
+ branch: remoteDefaultBranch
84
+ };
67
85
  }
68
86
  function resolveRemoteBranch(options) {
87
+ const result = resolveRemoteAndBranch(options);
88
+ return `${result.remote}/${result.branch}`;
89
+ }
90
+ function resolveRemoteAndBranch(options) {
69
91
  const { branch } = options;
70
92
  let parsed;
71
93
  if (branch) {
@@ -76,12 +98,15 @@ function resolveRemoteBranch(options) {
76
98
  branch
77
99
  });
78
100
  if (parsed.remote) {
79
- return `${parsed.remote}/${parsed.remoteBranch}`;
101
+ return {
102
+ remote: parsed.remote,
103
+ branch: parsed.remoteBranch
104
+ };
80
105
  }
81
106
  }
82
107
  // No branch provided, or the provided branch didn't include a remote.
83
108
  // Get the default remote and possibly default branch.
84
- return getDefaultRemoteBranch({
109
+ return getDefaultRemoteAndBranch({
85
110
  ...options,
86
111
  remotes: parsed?.remotes
87
112
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/git/getDefaultRemoteBranch.ts"],"sourcesContent":["import { getDefaultRemote, type GetDefaultRemoteOptions } from \"./getDefaultRemote.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- referenced by docs\nimport type { getRemotes } from \"./getRemotes.js\";\nimport { git } from \"./git.js\";\nimport { getDefaultBranch } from \"./gitUtilities.js\";\nimport {\n parseRemoteBranchPlusRemotes,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type parseRemoteBranch,\n} from \"./parseRemoteBranch.js\";\n\nexport type GetDefaultRemoteBranchOptions = GetDefaultRemoteOptions & {\n /**\n * Name of branch to use, **without** a remote prefix. If you want to resolve a branch\n * that may already include a remote prefix, use {@link resolveRemoteBranch}.\n *\n * If undefined, uses the default branch name (falling back to `master`).\n */\n branch?: string;\n};\n\n/**\n * Gets a reference to `options.branch` or the default branch relative to the default remote.\n * (See {@link getDefaultRemote} for how the default remote is determined.)\n * Throws if `options.cwd` is not in a git repo.\n *\n * If you want to resolve a branch that may already include a remote prefix, use\n * {@link resolveRemoteBranch} instead.\n *\n * If `options.strict` is true, throws in the same cases as {@link getDefaultRemote}, {@link getRemotes},\n * or if querying the default branch from the remote fails.\n *\n * @returns A branch reference like `upstream/master` or `origin/master`.\n */\nexport function getDefaultRemoteBranch(options: GetDefaultRemoteBranchOptions): string;\n/**\n * First param: `branch`. Second param: `cwd`. See {@link GetDefaultRemoteBranchOptions} for more info.\n * (This had to be changed to `...args` to avoid a conflict with the object param version.)\n * @deprecated Use the object param version\n */\nexport function getDefaultRemoteBranch(...args: string[]): string;\nexport function getDefaultRemoteBranch(...args: (string | GetDefaultRemoteBranchOptions)[]): string {\n const [branchOrOptions, argsCwd] = args;\n const options =\n typeof branchOrOptions === \"string\"\n ? ({ branch: branchOrOptions, cwd: argsCwd } as GetDefaultRemoteBranchOptions)\n : branchOrOptions;\n const { cwd, branch } = options;\n\n const defaultRemote = getDefaultRemote(options);\n\n if (branch) {\n return `${defaultRemote}/${branch}`;\n }\n\n let remoteDefaultBranch: string | undefined;\n\n // Get the default branch name from the default remote.\n // ls-remote is a plumbing command with stable, locale-independent output.\n // Output format: \"ref: refs/heads/main\\tHEAD\\n<hash>\\tHEAD\"\n const lsRemoteCmd = [\"ls-remote\", \"--symref\", defaultRemote, \"HEAD\"];\n const lsRemote = git(lsRemoteCmd, {\n cwd,\n throwOnError: options.strict,\n description: `Fetching default branch info from remote \"${defaultRemote}\"`,\n });\n if (lsRemote.success) {\n const refRegex = /^ref: refs\\/heads\\/(.*?)\\t/;\n const symRefLine = lsRemote.stdout.split(\"\\n\").find((line) => refRegex.test(line));\n remoteDefaultBranch = symRefLine && symRefLine.match(refRegex)?.[1];\n\n if (!remoteDefaultBranch && options.strict) {\n throw new Error(\n `Could not parse default branch from \\`git ${lsRemoteCmd.join(\" \")}\\` output:\\n${lsRemote.stdout}`\n );\n }\n }\n\n // If no default branch found from the remote, fall back to the local git config or \"master\"\n // (this can't use throwOnError in case the key isn't set)\n remoteDefaultBranch ||= getDefaultBranch({ cwd });\n\n return `${defaultRemote}/${remoteDefaultBranch}`;\n}\n\n/**\n * Resolve a user-provided branch (possibly with a remote) to a fully-qualified remote branch.\n * First tries the less-expensive {@link parseRemoteBranchPlusRemotes} (compares with remote names\n * read from `git config`) to see if there's an explicit remote in the branch name, then tries\n * {@link getDefaultRemoteBranch}.\n *\n * If `options.strict` is true, throws in the same cases as {@link parseRemoteBranch},\n * {@link getDefaultRemoteBranch}, {@link getDefaultRemote}, or {@link getRemotes}.\n *\n * @returns A fully-qualified target remote branch reference (e.g. `origin/main`)\n */\nexport function resolveRemoteBranch(\n options: Omit<GetDefaultRemoteBranchOptions, \"branch\" | \"remotes\"> & {\n /** Branch which might include a remote prefix */\n branch: string | undefined;\n }\n): string {\n const { branch } = options;\n\n let parsed: ReturnType<typeof parseRemoteBranchPlusRemotes> | undefined;\n if (branch) {\n // A branch is provided, so see if it includes a remote name.\n // The result is saved so the fetched list of remotes can be reused.\n parsed = parseRemoteBranchPlusRemotes({ ...options, branch });\n if (parsed.remote) {\n return `${parsed.remote}/${parsed.remoteBranch}`;\n }\n }\n\n // No branch provided, or the provided branch didn't include a remote.\n // Get the default remote and possibly default branch.\n return getDefaultRemoteBranch({ ...options, remotes: parsed?.remotes });\n}\n"],"names":["getDefaultRemoteBranch","resolveRemoteBranch","args","branchOrOptions","argsCwd","options","branch","cwd","defaultRemote","getDefaultRemote","remoteDefaultBranch","lsRemoteCmd","lsRemote","git","throwOnError","strict","description","success","refRegex","symRefLine","stdout","split","find","line","test","match","Error","join","getDefaultBranch","parsed","parseRemoteBranchPlusRemotes","remote","remoteBranch","remotes"],"mappings":";;;;;;;;;;;;;;;QAyCgBA;eAAAA;;QAuDAC;eAAAA;;;kCAhG+C;qBAG3C;8BACa;mCAK1B;AAgCA,SAASD,uBAAuB,GAAGE,IAAgD;IACxF,MAAM,CAACC,iBAAiBC,QAAQ,GAAGF;IACnC,MAAMG,UACJ,OAAOF,oBAAoB,WACtB;QAAEG,QAAQH;QAAiBI,KAAKH;IAAQ,IACzCD;IACN,MAAM,EAAEI,GAAG,EAAED,MAAM,EAAE,GAAGD;IAExB,MAAMG,gBAAgBC,IAAAA,kCAAgB,EAACJ;IAEvC,IAAIC,QAAQ;QACV,OAAO,GAAGE,cAAc,CAAC,EAAEF,QAAQ;IACrC;IAEA,IAAII;IAEJ,uDAAuD;IACvD,0EAA0E;IAC1E,4DAA4D;IAC5D,MAAMC,cAAc;QAAC;QAAa;QAAYH;QAAe;KAAO;IACpE,MAAMI,WAAWC,IAAAA,QAAG,EAACF,aAAa;QAChCJ;QACAO,cAAcT,QAAQU,MAAM;QAC5BC,aAAa,CAAC,0CAA0C,EAAER,cAAc,CAAC,CAAC;IAC5E;IACA,IAAII,SAASK,OAAO,EAAE;QACpB,MAAMC,WAAW;QACjB,MAAMC,aAAaP,SAASQ,MAAM,CAACC,KAAK,CAAC,MAAMC,IAAI,CAAC,CAACC,OAASL,SAASM,IAAI,CAACD;QAC5Eb,sBAAsBS,cAAcA,WAAWM,KAAK,CAACP,WAAW,CAAC,EAAE;QAEnE,IAAI,CAACR,uBAAuBL,QAAQU,MAAM,EAAE;YAC1C,MAAM,IAAIW,MACR,CAAC,0CAA0C,EAAEf,YAAYgB,IAAI,CAAC,KAAK,YAAY,EAAEf,SAASQ,MAAM,EAAE;QAEtG;IACF;IAEA,4FAA4F;IAC5F,0DAA0D;IAC1DV,wBAAAA,sBAAwBkB,IAAAA,8BAAgB,EAAC;QAAErB;IAAI;IAE/C,OAAO,GAAGC,cAAc,CAAC,EAAEE,qBAAqB;AAClD;AAaO,SAAST,oBACdI,OAGC;IAED,MAAM,EAAEC,MAAM,EAAE,GAAGD;IAEnB,IAAIwB;IACJ,IAAIvB,QAAQ;QACV,6DAA6D;QAC7D,oEAAoE;QACpEuB,SAASC,IAAAA,+CAA4B,EAAC;YAAE,GAAGzB,OAAO;YAAEC;QAAO;QAC3D,IAAIuB,OAAOE,MAAM,EAAE;YACjB,OAAO,GAAGF,OAAOE,MAAM,CAAC,CAAC,EAAEF,OAAOG,YAAY,EAAE;QAClD;IACF;IAEA,sEAAsE;IACtE,sDAAsD;IACtD,OAAOhC,uBAAuB;QAAE,GAAGK,OAAO;QAAE4B,SAASJ,QAAQI;IAAQ;AACvE"}
1
+ {"version":3,"sources":["../../src/git/getDefaultRemoteBranch.ts"],"sourcesContent":["import { getDefaultRemote, type GetDefaultRemoteOptions } from \"./getDefaultRemote.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- referenced by docs\nimport type { getRemotes } from \"./getRemotes.js\";\nimport { git } from \"./git.js\";\nimport { getDefaultBranch } from \"./gitUtilities.js\";\nimport {\n parseRemoteBranchPlusRemotes,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type parseRemoteBranch,\n} from \"./parseRemoteBranch.js\";\nimport type { RemoteBranch } from \"./types.js\";\n\nexport type GetDefaultRemoteBranchOptions = GetDefaultRemoteOptions & {\n /**\n * Name of branch to use, **without** a remote prefix. If you want to resolve a branch\n * that may already include a remote prefix, use {@link resolveRemoteAndBranch}.\n *\n * If undefined, uses the default branch name (falling back to `master`).\n */\n branch?: string;\n};\n\n/**\n * Gets a reference to `options.branch` or the default branch relative to the default remote.\n * (See {@link getDefaultRemote} for how the default remote is determined.)\n * Throws if `options.cwd` is not in a git repo.\n *\n * If you want to resolve a branch that may already include a remote prefix, use\n * {@link resolveRemoteAndBranch} instead.\n *\n * If `options.strict` is true, throws in the same cases as {@link getDefaultRemote}, {@link getRemotes},\n * or if querying the default branch from the remote fails.\n *\n * @returns A branch reference like `upstream/master` or `origin/master`.\n */\nexport function getDefaultRemoteBranch(options: GetDefaultRemoteBranchOptions): string;\n/**\n * First param: `branch`. Second param: `cwd`. See {@link GetDefaultRemoteBranchOptions} for more info.\n * (This had to be changed to `...args` to avoid a conflict with the object param version.)\n * @deprecated Use the object param version\n */\nexport function getDefaultRemoteBranch(...args: string[]): string;\nexport function getDefaultRemoteBranch(...args: (string | GetDefaultRemoteBranchOptions)[]): string {\n const [branchOrOptions, argsCwd] = args;\n const options =\n typeof branchOrOptions === \"string\"\n ? ({ branch: branchOrOptions, cwd: argsCwd } as GetDefaultRemoteBranchOptions)\n : branchOrOptions;\n\n const result = getDefaultRemoteAndBranch(options);\n return `${result.remote}/${result.branch}`;\n}\n\n/**\n * Like {@link getDefaultRemoteBranch} but it returns an object.\n *\n * @returns A branch reference like `{ remote: \"upstream\", branch: \"master\" }` or `{ remote: \"origin\", branch: \"main\" }`.\n */\nfunction getDefaultRemoteAndBranch(options: GetDefaultRemoteBranchOptions): RemoteBranch {\n const { cwd, branch } = options;\n\n const defaultRemote = getDefaultRemote(options);\n\n if (branch) {\n return { remote: defaultRemote, branch };\n }\n\n let remoteDefaultBranch: string | undefined;\n\n // Get the default branch name from the default remote.\n // ls-remote is a plumbing command with stable, locale-independent output.\n // Output format: \"ref: refs/heads/main\\tHEAD\\n<hash>\\tHEAD\"\n const lsRemoteCmd = [\"ls-remote\", \"--symref\", defaultRemote, \"HEAD\"];\n const lsRemote = git(lsRemoteCmd, {\n cwd,\n throwOnError: options.strict,\n description: `Fetching default branch info from remote \"${defaultRemote}\"`,\n });\n if (lsRemote.success) {\n const refRegex = /^ref: refs\\/heads\\/(.*?)\\t/;\n const symRefLine = lsRemote.stdout.split(\"\\n\").find((line) => refRegex.test(line));\n remoteDefaultBranch = symRefLine && symRefLine.match(refRegex)?.[1];\n\n if (!remoteDefaultBranch && options.strict) {\n throw new Error(\n `Could not parse default branch from \\`git ${lsRemoteCmd.join(\" \")}\\` output:\\n${lsRemote.stdout}`\n );\n }\n }\n\n // If no default branch found from the remote, fall back to the local git config or \"master\"\n // (this can't use throwOnError in case the key isn't set)\n remoteDefaultBranch ||= getDefaultBranch({ cwd });\n\n return { remote: defaultRemote, branch: remoteDefaultBranch };\n}\n\n/**\n * Resolve a user-provided branch (possibly with a remote) to a fully-qualified remote branch.\n * @returns A fully-qualified target remote branch reference (e.g. `origin/main`)\n * @deprecated Use {@link resolveRemoteAndBranch} instead\n */\nexport function resolveRemoteBranch(\n options: Omit<GetDefaultRemoteBranchOptions, \"branch\" | \"remotes\"> & {\n /** Branch which might include a remote prefix */\n branch: string | undefined;\n }\n): string {\n const result = resolveRemoteAndBranch(options);\n return `${result.remote}/${result.branch}`;\n}\n\n/**\n * Resolve a user-provided branch (possibly with a remote) to a fully-qualified remote branch.\n * First tries the less-expensive {@link parseRemoteBranchPlusRemotes} (compares with remote names\n * read from `git config`) to see if there's an explicit remote in the branch name, then tries\n * {@link getDefaultRemoteBranch}.\n *\n * If `options.strict` is true, throws in the same cases as {@link parseRemoteBranch},\n * {@link getDefaultRemoteBranch}, {@link getDefaultRemote}, or {@link getRemotes}.\n *\n * @returns A fully-qualified target remote branch reference (e.g. `{ remote: \"origin\", branch: \"main\" }`)\n */\nexport function resolveRemoteAndBranch(\n options: Omit<GetDefaultRemoteBranchOptions, \"branch\" | \"remotes\"> & {\n /** Branch which might include a remote prefix */\n branch: string | undefined;\n }\n): RemoteBranch {\n const { branch } = options;\n\n let parsed: ReturnType<typeof parseRemoteBranchPlusRemotes> | undefined;\n if (branch) {\n // A branch is provided, so see if it includes a remote name.\n // The result is saved so the fetched list of remotes can be reused.\n parsed = parseRemoteBranchPlusRemotes({ ...options, branch });\n if (parsed.remote) {\n return { remote: parsed.remote, branch: parsed.remoteBranch };\n }\n }\n\n // No branch provided, or the provided branch didn't include a remote.\n // Get the default remote and possibly default branch.\n return getDefaultRemoteAndBranch({ ...options, remotes: parsed?.remotes });\n}\n"],"names":["getDefaultRemoteBranch","resolveRemoteAndBranch","resolveRemoteBranch","args","branchOrOptions","argsCwd","options","branch","cwd","result","getDefaultRemoteAndBranch","remote","defaultRemote","getDefaultRemote","remoteDefaultBranch","lsRemoteCmd","lsRemote","git","throwOnError","strict","description","success","refRegex","symRefLine","stdout","split","find","line","test","match","Error","join","getDefaultBranch","parsed","parseRemoteBranchPlusRemotes","remoteBranch","remotes"],"mappings":";;;;;;;;;;;;;;;;QA0CgBA;eAAAA;;QAiFAC;eAAAA;;QArBAC;eAAAA;;;kCAtG+C;qBAG3C;8BACa;mCAK1B;AAiCA,SAASF,uBAAuB,GAAGG,IAAgD;IACxF,MAAM,CAACC,iBAAiBC,QAAQ,GAAGF;IACnC,MAAMG,UACJ,OAAOF,oBAAoB,WACtB;QAAEG,QAAQH;QAAiBI,KAAKH;IAAQ,IACzCD;IAEN,MAAMK,SAASC,0BAA0BJ;IACzC,OAAO,GAAGG,OAAOE,MAAM,CAAC,CAAC,EAAEF,OAAOF,MAAM,EAAE;AAC5C;AAEA;;;;CAIC,GACD,SAASG,0BAA0BJ,OAAsC;IACvE,MAAM,EAAEE,GAAG,EAAED,MAAM,EAAE,GAAGD;IAExB,MAAMM,gBAAgBC,IAAAA,kCAAgB,EAACP;IAEvC,IAAIC,QAAQ;QACV,OAAO;YAAEI,QAAQC;YAAeL;QAAO;IACzC;IAEA,IAAIO;IAEJ,uDAAuD;IACvD,0EAA0E;IAC1E,4DAA4D;IAC5D,MAAMC,cAAc;QAAC;QAAa;QAAYH;QAAe;KAAO;IACpE,MAAMI,WAAWC,IAAAA,QAAG,EAACF,aAAa;QAChCP;QACAU,cAAcZ,QAAQa,MAAM;QAC5BC,aAAa,CAAC,0CAA0C,EAAER,cAAc,CAAC,CAAC;IAC5E;IACA,IAAII,SAASK,OAAO,EAAE;QACpB,MAAMC,WAAW;QACjB,MAAMC,aAAaP,SAASQ,MAAM,CAACC,KAAK,CAAC,MAAMC,IAAI,CAAC,CAACC,OAASL,SAASM,IAAI,CAACD;QAC5Eb,sBAAsBS,cAAcA,WAAWM,KAAK,CAACP,WAAW,CAAC,EAAE;QAEnE,IAAI,CAACR,uBAAuBR,QAAQa,MAAM,EAAE;YAC1C,MAAM,IAAIW,MACR,CAAC,0CAA0C,EAAEf,YAAYgB,IAAI,CAAC,KAAK,YAAY,EAAEf,SAASQ,MAAM,EAAE;QAEtG;IACF;IAEA,4FAA4F;IAC5F,0DAA0D;IAC1DV,wBAAAA,sBAAwBkB,IAAAA,8BAAgB,EAAC;QAAExB;IAAI;IAE/C,OAAO;QAAEG,QAAQC;QAAeL,QAAQO;IAAoB;AAC9D;AAOO,SAASZ,oBACdI,OAGC;IAED,MAAMG,SAASR,uBAAuBK;IACtC,OAAO,GAAGG,OAAOE,MAAM,CAAC,CAAC,EAAEF,OAAOF,MAAM,EAAE;AAC5C;AAaO,SAASN,uBACdK,OAGC;IAED,MAAM,EAAEC,MAAM,EAAE,GAAGD;IAEnB,IAAI2B;IACJ,IAAI1B,QAAQ;QACV,6DAA6D;QAC7D,oEAAoE;QACpE0B,SAASC,IAAAA,+CAA4B,EAAC;YAAE,GAAG5B,OAAO;YAAEC;QAAO;QAC3D,IAAI0B,OAAOtB,MAAM,EAAE;YACjB,OAAO;gBAAEA,QAAQsB,OAAOtB,MAAM;gBAAEJ,QAAQ0B,OAAOE,YAAY;YAAC;QAC9D;IACF;IAEA,sEAAsE;IACtE,sDAAsD;IACtD,OAAOzB,0BAA0B;QAAE,GAAGJ,OAAO;QAAE8B,SAASH,QAAQG;IAAQ;AAC1E"}
@@ -4,10 +4,11 @@ export { fetchRemote, fetchRemoteBranch } from "./fetchRemote.js";
4
4
  export { getBranchChanges, getChanges, getChangesBetweenRefs, getStagedChanges, getUnstagedChanges, getUntrackedChanges, } from "./getChanges.js";
5
5
  export { getCurrentHash } from "./getCurrentHash.js";
6
6
  export { getDefaultRemote, type GetDefaultRemoteOptions } from "./getDefaultRemote.js";
7
- export { getDefaultRemoteBranch, type GetDefaultRemoteBranchOptions, resolveRemoteBranch, } from "./getDefaultRemoteBranch.js";
7
+ export { getDefaultRemoteBranch, type GetDefaultRemoteBranchOptions, resolveRemoteBranch, resolveRemoteAndBranch, } from "./getDefaultRemoteBranch.js";
8
8
  export { getFileAddedHash } from "./getFileAddedHash.js";
9
9
  export { getFileFromRef } from "./getFileFromRef.js";
10
10
  export { getRecentCommitMessages } from "./getRecentCommitMessages.js";
11
+ export { getRemotes } from "./getRemotes.js";
11
12
  export { addGitObserver, clearGitObservers, git, gitFailFast, type GitError, type GitObserver, type GitOptions, type GitProcessOutput, } from "./git.js";
12
13
  export { getParentBranch } from "./gitUtilities.js";
13
14
  export { init } from "./init.js";
package/lib/git/index.js CHANGED
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", {
23
23
  getParentBranch: null,
24
24
  getRecentCommitMessages: null,
25
25
  getRemoteBranch: null,
26
+ getRemotes: null,
26
27
  getShortBranchName: null,
27
28
  getStagedChanges: null,
28
29
  getUnstagedChanges: null,
@@ -33,6 +34,7 @@ Object.defineProperty(exports, "__esModule", {
33
34
  init: null,
34
35
  listAllTrackedFiles: null,
35
36
  parseRemoteBranch: null,
37
+ resolveRemoteAndBranch: null,
36
38
  resolveRemoteBranch: null,
37
39
  revertLocalChanges: null,
38
40
  stage: null,
@@ -105,6 +107,9 @@ _export(exports, {
105
107
  get getRemoteBranch () {
106
108
  return _branchRefs.getRemoteBranch;
107
109
  },
110
+ get getRemotes () {
111
+ return _getRemotes.getRemotes;
112
+ },
108
113
  get getShortBranchName () {
109
114
  return _branchRefs.getShortBranchName;
110
115
  },
@@ -135,6 +140,9 @@ _export(exports, {
135
140
  get parseRemoteBranch () {
136
141
  return _parseRemoteBranch.parseRemoteBranch;
137
142
  },
143
+ get resolveRemoteAndBranch () {
144
+ return _getDefaultRemoteBranch.resolveRemoteAndBranch;
145
+ },
138
146
  get resolveRemoteBranch () {
139
147
  return _getDefaultRemoteBranch.resolveRemoteBranch;
140
148
  },
@@ -158,6 +166,7 @@ const _getDefaultRemoteBranch = require("./getDefaultRemoteBranch.js");
158
166
  const _getFileAddedHash = require("./getFileAddedHash.js");
159
167
  const _getFileFromRef = require("./getFileFromRef.js");
160
168
  const _getRecentCommitMessages = require("./getRecentCommitMessages.js");
169
+ const _getRemotes = require("./getRemotes.js");
161
170
  const _git = require("./git.js");
162
171
  const _gitUtilities = require("./gitUtilities.js");
163
172
  const _init = require("./init.js");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/git/index.ts"],"sourcesContent":["export { getBranchName, getFullBranchRef, getRemoteBranch, getShortBranchName } from \"./branchRefs.js\";\nexport { getConfigValue, getDefaultBranch, getUserEmail } from \"./config.js\";\nexport { fetchRemote, fetchRemoteBranch } from \"./fetchRemote.js\";\nexport {\n getBranchChanges,\n getChanges,\n getChangesBetweenRefs,\n getStagedChanges,\n getUnstagedChanges,\n getUntrackedChanges,\n} from \"./getChanges.js\";\nexport { getCurrentHash } from \"./getCurrentHash.js\";\nexport { getDefaultRemote, type GetDefaultRemoteOptions } from \"./getDefaultRemote.js\";\nexport {\n getDefaultRemoteBranch,\n type GetDefaultRemoteBranchOptions,\n resolveRemoteBranch,\n} from \"./getDefaultRemoteBranch.js\";\nexport { getFileAddedHash } from \"./getFileAddedHash.js\";\nexport { getFileFromRef } from \"./getFileFromRef.js\";\nexport { getRecentCommitMessages } from \"./getRecentCommitMessages.js\";\nexport {\n addGitObserver,\n clearGitObservers,\n git,\n gitFailFast,\n type GitError,\n type GitObserver,\n type GitOptions,\n type GitProcessOutput,\n} from \"./git.js\";\nexport { getParentBranch } from \"./gitUtilities.js\";\nexport { init } from \"./init.js\";\nexport { listAllTrackedFiles } from \"./listAllTrackedFiles.js\";\nexport { parseRemoteBranch } from \"./parseRemoteBranch.js\";\nexport { revertLocalChanges } from \"./revertLocalChanges.js\";\nexport { commit, stage, stageAndCommit } from \"./stageAndCommit.js\";\n\n// getRepositoryName is not currently exported; could be changed if it would be useful externally\n"],"names":["addGitObserver","clearGitObservers","commit","fetchRemote","fetchRemoteBranch","getBranchChanges","getBranchName","getChanges","getChangesBetweenRefs","getConfigValue","getCurrentHash","getDefaultBranch","getDefaultRemote","getDefaultRemoteBranch","getFileAddedHash","getFileFromRef","getFullBranchRef","getParentBranch","getRecentCommitMessages","getRemoteBranch","getShortBranchName","getStagedChanges","getUnstagedChanges","getUntrackedChanges","getUserEmail","git","gitFailFast","init","listAllTrackedFiles","parseRemoteBranch","resolveRemoteBranch","revertLocalChanges","stage","stageAndCommit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsBEA;eAAAA,mBAAc;;QACdC;eAAAA,sBAAiB;;QAaVC;eAAAA,sBAAM;;QAlCNC;eAAAA,wBAAW;;QAAEC;eAAAA,8BAAiB;;QAErCC;eAAAA,4BAAgB;;QAJTC;eAAAA,yBAAa;;QAKpBC;eAAAA,sBAAU;;QACVC;eAAAA,iCAAqB;;QALdC;eAAAA,sBAAc;;QAUdC;eAAAA,8BAAc;;QAVEC;eAAAA,wBAAgB;;QAWhCC;eAAAA,kCAAgB;;QAEvBC;eAAAA,8CAAsB;;QAIfC;eAAAA,kCAAgB;;QAChBC;eAAAA,8BAAc;;QAnBCC;eAAAA,4BAAgB;;QA+B/BC;eAAAA,6BAAe;;QAXfC;eAAAA,gDAAuB;;QApBUC;eAAAA,2BAAe;;QAAEC;eAAAA,8BAAkB;;QAO3EC;eAAAA,4BAAgB;;QAChBC;eAAAA,8BAAkB;;QAClBC;eAAAA,+BAAmB;;QARsBC;eAAAA,oBAAY;;QAuBrDC;eAAAA,QAAG;;QACHC;eAAAA,gBAAW;;QAOJC;eAAAA,UAAI;;QACJC;eAAAA,wCAAmB;;QACnBC;eAAAA,oCAAiB;;QAlBxBC;eAAAA,2CAAmB;;QAmBZC;eAAAA,sCAAkB;;QACVC;eAAAA,qBAAK;;QAAEC;eAAAA,8BAAc;;;4BApC+C;wBACtB;6BAChB;4BAQxC;gCACwB;kCACgC;wCAKxD;kCAC0B;gCACF;yCACS;qBAUjC;8BACyB;sBACX;qCACe;mCACF;oCACC;gCACW;CAE9C,iGAAiG"}
1
+ {"version":3,"sources":["../../src/git/index.ts"],"sourcesContent":["export { getBranchName, getFullBranchRef, getRemoteBranch, getShortBranchName } from \"./branchRefs.js\";\nexport { getConfigValue, getDefaultBranch, getUserEmail } from \"./config.js\";\nexport { fetchRemote, fetchRemoteBranch } from \"./fetchRemote.js\";\nexport {\n getBranchChanges,\n getChanges,\n getChangesBetweenRefs,\n getStagedChanges,\n getUnstagedChanges,\n getUntrackedChanges,\n} from \"./getChanges.js\";\nexport { getCurrentHash } from \"./getCurrentHash.js\";\nexport { getDefaultRemote, type GetDefaultRemoteOptions } from \"./getDefaultRemote.js\";\nexport {\n getDefaultRemoteBranch,\n type GetDefaultRemoteBranchOptions,\n resolveRemoteBranch,\n resolveRemoteAndBranch,\n} from \"./getDefaultRemoteBranch.js\";\nexport { getFileAddedHash } from \"./getFileAddedHash.js\";\nexport { getFileFromRef } from \"./getFileFromRef.js\";\nexport { getRecentCommitMessages } from \"./getRecentCommitMessages.js\";\nexport { getRemotes } from \"./getRemotes.js\";\nexport {\n addGitObserver,\n clearGitObservers,\n git,\n gitFailFast,\n type GitError,\n type GitObserver,\n type GitOptions,\n type GitProcessOutput,\n} from \"./git.js\";\nexport { getParentBranch } from \"./gitUtilities.js\";\nexport { init } from \"./init.js\";\nexport { listAllTrackedFiles } from \"./listAllTrackedFiles.js\";\nexport { parseRemoteBranch } from \"./parseRemoteBranch.js\";\nexport { revertLocalChanges } from \"./revertLocalChanges.js\";\nexport { commit, stage, stageAndCommit } from \"./stageAndCommit.js\";\n\n// getRepositoryName is not currently exported; could be changed if it would be useful externally\n"],"names":["addGitObserver","clearGitObservers","commit","fetchRemote","fetchRemoteBranch","getBranchChanges","getBranchName","getChanges","getChangesBetweenRefs","getConfigValue","getCurrentHash","getDefaultBranch","getDefaultRemote","getDefaultRemoteBranch","getFileAddedHash","getFileFromRef","getFullBranchRef","getParentBranch","getRecentCommitMessages","getRemoteBranch","getRemotes","getShortBranchName","getStagedChanges","getUnstagedChanges","getUntrackedChanges","getUserEmail","git","gitFailFast","init","listAllTrackedFiles","parseRemoteBranch","resolveRemoteAndBranch","resolveRemoteBranch","revertLocalChanges","stage","stageAndCommit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwBEA;eAAAA,mBAAc;;QACdC;eAAAA,sBAAiB;;QAaVC;eAAAA,sBAAM;;QApCNC;eAAAA,wBAAW;;QAAEC;eAAAA,8BAAiB;;QAErCC;eAAAA,4BAAgB;;QAJTC;eAAAA,yBAAa;;QAKpBC;eAAAA,sBAAU;;QACVC;eAAAA,iCAAqB;;QALdC;eAAAA,sBAAc;;QAUdC;eAAAA,8BAAc;;QAVEC;eAAAA,wBAAgB;;QAWhCC;eAAAA,kCAAgB;;QAEvBC;eAAAA,8CAAsB;;QAKfC;eAAAA,kCAAgB;;QAChBC;eAAAA,8BAAc;;QApBCC;eAAAA,4BAAgB;;QAiC/BC;eAAAA,6BAAe;;QAZfC;eAAAA,gDAAuB;;QArBUC;eAAAA,2BAAe;;QAsBhDC;eAAAA,sBAAU;;QAtBwCC;eAAAA,8BAAkB;;QAO3EC;eAAAA,4BAAgB;;QAChBC;eAAAA,8BAAkB;;QAClBC;eAAAA,+BAAmB;;QARsBC;eAAAA,oBAAY;;QAyBrDC;eAAAA,QAAG;;QACHC;eAAAA,gBAAW;;QAOJC;eAAAA,UAAI;;QACJC;eAAAA,wCAAmB;;QACnBC;eAAAA,oCAAiB;;QAnBxBC;eAAAA,8CAAsB;;QADtBC;eAAAA,2CAAmB;;QAqBZC;eAAAA,sCAAkB;;QACVC;eAAAA,qBAAK;;QAAEC;eAAAA,8BAAc;;;4BAtC+C;wBACtB;6BAChB;4BAQxC;gCACwB;kCACgC;wCAMxD;kCAC0B;gCACF;yCACS;4BACb;qBAUpB;8BACyB;sBACX;qCACe;mCACF;oCACC;gCACW;CAE9C,iGAAiG"}
@@ -51,6 +51,12 @@ export type ParsedRemoteBranch = {
51
51
  /** Branch name without remote, e.g. `main`. This is always set. */
52
52
  remoteBranch: string;
53
53
  };
54
+ export type RemoteBranch = {
55
+ /** Remote name, e.g. `origin`. */
56
+ remote: string;
57
+ /** Branch name without remote, e.g. `main`. */
58
+ branch: string;
59
+ };
54
60
  export type GitStageOptions = {
55
61
  /** File patterns to stage */
56
62
  patterns: string[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/git/types.ts"],"sourcesContent":["/** Options used for all git operations and wrappers */\nexport type GitCommonOptions = {\n cwd: string;\n /** If true, throw if the command fails */\n throwOnError?: boolean;\n};\n\n/** Options for git operations related to a branch */\nexport type GitBranchOptions = { branch: string } & GitCommonOptions;\n\nexport type GitFetchOptions = GitCommonOptions & {\n /** Remote name to fetch, e.g. \"origin\" (if not provided, fetches all remotes) */\n remote?: string;\n /** Branch name to fetch, e.g. \"main\". To use this, `remote` must also be set. */\n remoteBranch?: string;\n /** Extra command line options */\n options?: string[];\n};\n\nexport type GetChangesBetweenRefsOptions = GitCommonOptions & {\n /** The starting reference */\n fromRef: string;\n /** The ending reference */\n toRef?: string;\n /** Extra command line options */\n options?: string[];\n /** Optional file pattern to filter results */\n pattern?: string;\n};\n\nexport type GitInitOptions = Omit<GitCommonOptions, \"throwOnError\"> & {\n /** Email to set in the git config, if not already set */\n email?: string;\n /** Username to set in the git config, if not already set */\n username?: string;\n};\n\nexport type ParseRemoteBranchOptions = GitCommonOptions & {\n /** Branch name with possible remote prefix */\n branch: string;\n /**\n * Well-known remote names. If these appear at the beginning of a branch name, they'll always\n * be returned as `ParsedRemoteBranch.remote` regardless of whether they exist locally.\n * @default [\"origin\", \"upstream\"]\n */\n knownRemotes?: string[];\n};\n\nexport type ParsedRemoteBranch = {\n /**\n * Remote name, e.g. `origin`.\n * May be an empty string if the original branch reference didn't include a remote.\n */\n remote: string;\n /** Branch name without remote, e.g. `main`. This is always set. */\n remoteBranch: string;\n};\n\nexport type GitStageOptions = {\n /** File patterns to stage */\n patterns: string[];\n} & GitCommonOptions;\n\nexport type GitCommitOptions = GitCommonOptions & {\n /** Commit message */\n message: string;\n /** Additional git commit options */\n options?: string[];\n};\n"],"names":[],"mappings":"AAAA,qDAAqD"}
1
+ {"version":3,"sources":["../../src/git/types.ts"],"sourcesContent":["/** Options used for all git operations and wrappers */\nexport type GitCommonOptions = {\n cwd: string;\n /** If true, throw if the command fails */\n throwOnError?: boolean;\n};\n\n/** Options for git operations related to a branch */\nexport type GitBranchOptions = { branch: string } & GitCommonOptions;\n\nexport type GitFetchOptions = GitCommonOptions & {\n /** Remote name to fetch, e.g. \"origin\" (if not provided, fetches all remotes) */\n remote?: string;\n /** Branch name to fetch, e.g. \"main\". To use this, `remote` must also be set. */\n remoteBranch?: string;\n /** Extra command line options */\n options?: string[];\n};\n\nexport type GetChangesBetweenRefsOptions = GitCommonOptions & {\n /** The starting reference */\n fromRef: string;\n /** The ending reference */\n toRef?: string;\n /** Extra command line options */\n options?: string[];\n /** Optional file pattern to filter results */\n pattern?: string;\n};\n\nexport type GitInitOptions = Omit<GitCommonOptions, \"throwOnError\"> & {\n /** Email to set in the git config, if not already set */\n email?: string;\n /** Username to set in the git config, if not already set */\n username?: string;\n};\n\nexport type ParseRemoteBranchOptions = GitCommonOptions & {\n /** Branch name with possible remote prefix */\n branch: string;\n /**\n * Well-known remote names. If these appear at the beginning of a branch name, they'll always\n * be returned as `ParsedRemoteBranch.remote` regardless of whether they exist locally.\n * @default [\"origin\", \"upstream\"]\n */\n knownRemotes?: string[];\n};\n\nexport type ParsedRemoteBranch = {\n /**\n * Remote name, e.g. `origin`.\n * May be an empty string if the original branch reference didn't include a remote.\n */\n remote: string;\n /** Branch name without remote, e.g. `main`. This is always set. */\n remoteBranch: string;\n};\n\nexport type RemoteBranch = {\n /** Remote name, e.g. `origin`. */\n remote: string;\n /** Branch name without remote, e.g. `main`. */\n branch: string;\n};\n\nexport type GitStageOptions = {\n /** File patterns to stage */\n patterns: string[];\n} & GitCommonOptions;\n\nexport type GitCommitOptions = GitCommonOptions & {\n /** Commit message */\n message: string;\n /** Additional git commit options */\n options?: string[];\n};\n"],"names":[],"mappings":"AAAA,qDAAqD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspace-tools",
3
- "version": "0.41.8",
3
+ "version": "0.41.9",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",