simple-git
Version:
Simple GIT interface for node.js
2,896 lines • 69.9 kB
JavaScript
import { isPathSpec as D, pathspec as rt, toPaths as yt } from "@simple-git/args-pathspec";
import { pathspec as ko } from "@simple-git/args-pathspec";
import { exists as ke, FOLDER as _e } from "@kwsites/file-exists";
import { spawn as ve } from "node:child_process";
import it from "debug";
import { createDeferred as Ee, deferred as P } from "@kwsites/promise-deferred";
import { normalize as Se } from "node:path";
import { isGitEnvKey as Re, vulnerabilityCheck as Oe } from "@simple-git/argv-parser";
import { EventEmitter as Ce } from "node:events";
class O extends Error {
constructor(e, n) {
super(n), this.task = e, Object.setPrototypeOf(this, new.target.prototype);
}
}
class Ae extends O {
constructor(e, n) {
super(void 0, n), this.config = e;
}
}
class A extends O {
constructor(e, n, r) {
super(e, r), this.task = e, this.plugin = n, Object.setPrototypeOf(this, new.target.prototype);
}
}
class at extends O {
constructor(e, n) {
super(void 0, n || String(e)), this.git = e;
}
}
class xe extends O {
constructor(e) {
super(void 0, e);
}
}
const I = "\0", W = () => {
};
function Ne(t) {
return typeof t != "function" ? W : t;
}
function $e(t) {
return typeof t == "function" && t !== W;
}
function Pe(t, e) {
const n = t.indexOf(e);
return n <= 0 ? [t, ""] : [t.substr(0, n), t.substr(n + 1)];
}
function Me(t, e = 0) {
return Dt(t) && t.length > e ? t[e] : void 0;
}
function N(t, e = 0) {
if (Dt(t) && t.length > e)
return t[t.length - 1 - e];
}
function Dt(t) {
return Bt(t);
}
function H(t = "", e = !0, n = `
`) {
return t.split(n).reduce((r, s) => {
const o = e ? s.trim() : s;
return o && r.push(o), r;
}, []);
}
function ut(t, e) {
return H(t, !0).map((n) => e(n));
}
function Lt(t) {
return ke(t, _e);
}
function S(t, e) {
return Array.isArray(t) ? t.includes(e) || t.push(e) : t.add(e), e;
}
function De(t, e) {
return Array.isArray(t) && !t.includes(e) && t.push(e), t;
}
function ct(t, e) {
if (Array.isArray(t)) {
const n = t.indexOf(e);
n >= 0 && t.splice(n, 1);
} else
t.delete(e);
return e;
}
const ft = Object.prototype.toString.call.bind(Object.prototype.toString);
function v(t) {
return Array.isArray(t) ? t : [t];
}
function jt(t) {
return t.replace(/[\s-]+(.)/g, (e, n) => n.toUpperCase());
}
function L(t) {
return v(t).map((e) => e instanceof String ? e : String(e));
}
function p(t, e = 0) {
if (t == null)
return e;
const n = parseInt(t, 10);
return Number.isNaN(n) ? e : n;
}
function U(t, e) {
const n = [];
for (let r = 0, s = t.length; r < s; r++)
n.push(e, t[r]);
return n;
}
function F(t) {
return (Array.isArray(t) ? Buffer.concat(t) : t).toString("utf-8");
}
function Le(t) {
return t ? Buffer.isBuffer(t) ? t.length : Buffer.byteLength(t) : 0;
}
function je(t, e) {
const n = {};
return e.forEach((r) => {
t[r] !== void 0 && (n[r] = t[r]);
}), n;
}
function wt(t = 0) {
return new Promise((e) => setTimeout(e, t));
}
function bt(t) {
if (t !== !1)
return t;
}
function d(t, e, n) {
return e(t) ? t : arguments.length > 2 ? n : void 0;
}
const K = (t) => Array.isArray(t);
function st(t, e) {
const n = D(t) ? "string" : typeof t;
return /number|string|boolean/.test(n) && (!e || !e.includes(n));
}
const m = (t) => typeof t == "string" || D(t), Be = (t) => m(t) || Buffer.isBuffer(t), G = (t) => m(t) || Array.isArray(t) && t.every(m);
function lt(t) {
return !!t && ft(t) === "[object Object]";
}
function Ie(t) {
return typeof t == "function";
}
const Bt = (t) => t == null || "number|boolean|function".includes(typeof t) ? !1 : typeof t.length == "number";
var V = /* @__PURE__ */ ((t) => (t[t.SUCCESS = 0] = "SUCCESS", t[t.ERROR = 1] = "ERROR", t[t.NOT_FOUND = -2] = "NOT_FOUND", t[t.UNCLEAN = 128] = "UNCLEAN", t))(V || {});
class z {
constructor(e, n) {
this.stdOut = e, this.stdErr = n;
}
asStrings() {
return new z(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
}
}
function Ue() {
throw new Error("LineParser:useMatches not implemented");
}
class l {
constructor(e, n) {
this.matches = [], this.useMatches = Ue, this.parse = (r, s) => (this.resetMatches(), this._regExp.every((o, i) => this.addMatch(o, i, r(i))) ? this.useMatches(s, this.prepareMatches()) !== !1 : !1), this._regExp = Array.isArray(e) ? e : [e], n && (this.useMatches = n);
}
resetMatches() {
this.matches.length = 0;
}
prepareMatches() {
return this.matches;
}
addMatch(e, n, r) {
const s = r && e.exec(r);
return s && this.pushMatch(n, s), !!s;
}
pushMatch(e, n) {
this.matches.push(...n.slice(1));
}
}
class x extends l {
addMatch(e, n, r) {
return /^remote:\s/.test(String(r)) && super.addMatch(e, n, r);
}
pushMatch(e, n) {
(e > 0 || n.length > 1) && super.pushMatch(e, n);
}
}
const Fe = {
binary: "git",
maxConcurrentProcesses: 5,
config: [],
trimmed: !1
};
function Ge(...t) {
const e = process.cwd(), n = Object.assign(
{ baseDir: e, ...Fe },
...t.filter((r) => typeof r == "object" && r)
);
return n.baseDir = n.baseDir || e, n.trimmed = n.trimmed === !0, n;
}
function It(t, e = []) {
return lt(t) ? Object.keys(t).reduce((n, r) => {
const s = t[r];
if (D(s))
n.push(s);
else if (st(s, ["boolean"]))
n.push(r + "=" + s);
else if (Array.isArray(s))
for (const o of s)
st(o, ["string", "number"]) || n.push(r + "=" + o);
else
n.push(r);
return n;
}, e) : e;
}
function h(t, e = 0, n = !1) {
const r = [];
for (let s = 0, o = e < 0 ? t.length : e; s < o; s++)
"string|number".includes(typeof t[s]) && r.push(String(t[s]));
return It(ht(t), r), n || r.push(...ze(t)), r;
}
function ze(t) {
const e = typeof N(t) == "function";
return L(d(N(t, e ? 1 : 0), K, []));
}
function ht(t) {
const e = Ie(N(t));
return d(N(t, e ? 1 : 0), lt);
}
function u(t, e = !0) {
const n = Ne(N(t));
return e || $e(n) ? n : void 0;
}
function Tt(t, e) {
return t(e.stdOut, e.stdErr);
}
function E(t, e, n, r = !0) {
return v(n).forEach((s) => {
for (let o = H(s, r), i = 0, a = o.length; i < a; i++) {
const c = (y = 0) => {
if (!(i + y >= a))
return o[i + y];
};
e.some(({ parse: y }) => y(c, t));
}
}), t;
}
var qe = /* @__PURE__ */ ((t) => (t.BARE = "bare", t.IN_TREE = "tree", t.IS_REPO_ROOT = "root", t))(qe || {});
const mt = ({ exitCode: t }, e, n, r) => {
if (t === V.UNCLEAN && Ve(e))
return n(Buffer.from("false"));
r(e);
}, Ut = (t) => t.trim() === "true";
function We(t) {
switch (t) {
case "bare":
return Ke();
case "root":
return He();
}
return {
commands: ["rev-parse", "--is-inside-work-tree"],
format: "utf-8",
onError: mt,
parser: Ut
};
}
function He() {
return {
commands: ["rev-parse", "--git-dir"],
format: "utf-8",
onError: mt,
parser(e) {
return /^\.(git)?$/.test(e.trim());
}
};
}
function Ke() {
return {
commands: ["rev-parse", "--is-bare-repository"],
format: "utf-8",
onError: mt,
parser: Ut
};
}
function Ve(t) {
return /(Not a git repository|Kein Git-Repository)/i.test(String(t));
}
class Xe {
constructor(e) {
this.paths = [], this.files = [], this.folders = [], this.dryRun = e;
}
}
const Ye = /^[a-z]+\s*/i, Qe = /^[a-z]+\s+[a-z]+\s*/i, Je = /\/$/;
function Ze(t, e) {
const n = new Xe(t), r = t ? Qe : Ye;
return H(e).forEach((s) => {
const o = s.replace(r, "");
n.paths.push(o), (Je.test(o) ? n.folders : n.files).push(o);
}), n;
}
const Ft = [];
function tn(t) {
return {
commands: Ft,
format: "empty",
parser: t
};
}
function b(t) {
return {
commands: Ft,
format: "empty",
parser() {
throw typeof t == "string" ? new xe(t) : t;
}
};
}
function g(t, e = !1) {
return {
commands: t,
format: "utf-8",
parser(n) {
return e ? String(n).trim() : n;
}
};
}
function Gt(t) {
return {
commands: t,
format: "buffer",
parser(e) {
return e;
}
};
}
function en(t) {
return t.format === "buffer";
}
function kt(t) {
return t.format === "empty" || !t.commands.length;
}
const nn = "Git clean interactive mode is not supported", rn = 'Git clean mode parameter ("n" or "f") is required', sn = "Git clean unknown option found in: ";
var zt = /* @__PURE__ */ ((t) => (t.DRY_RUN = "n", t.FORCE = "f", t.IGNORED_INCLUDED = "x", t.IGNORED_ONLY = "X", t.EXCLUDING = "e", t.QUIET = "q", t.RECURSIVE = "d", t))(zt || {});
const qt = /* @__PURE__ */ new Set([
"i",
...L(Object.values(zt))
]);
function on(t, e) {
const { cleanMode: n, options: r, valid: s } = cn(t);
return n ? s.options ? (r.push(...e), r.some(hn) ? b(nn) : an(n, r)) : b(sn + JSON.stringify(t)) : b(rn);
}
function an(t, e) {
return {
commands: ["clean", `-${t}`, ...e],
format: "utf-8",
parser(r) {
return Ze(t === "n", r);
}
};
}
function un(t) {
return Array.isArray(t) && t.every((e) => qt.has(e));
}
function cn(t) {
let e, n = [], r = { cleanMode: !1, options: !0 };
return t.replace(/[^a-z]i/g, "").split("").forEach((s) => {
fn(s) ? (e = s, r.cleanMode = !0) : r.options = r.options && ln(n[n.length] = `-${s}`);
}), {
cleanMode: e,
options: n,
valid: r
};
}
function fn(t) {
return t === "f" || t === "n";
}
function ln(t) {
return /^-[a-z]$/i.test(t) && qt.has(t.charAt(1));
}
function hn(t) {
return /^-[^\-]/.test(t) ? t.indexOf("i") > 0 : t === "--interactive";
}
class mn {
constructor() {
this.files = [], this.values = /* @__PURE__ */ Object.create(null);
}
get all() {
return this._all || (this._all = this.files.reduce((e, n) => Object.assign(e, this.values[n]), {})), this._all;
}
addFile(e) {
if (!(e in this.values)) {
const n = N(this.files);
this.values[e] = n ? Object.create(this.values[n]) : {}, this.files.push(e);
}
return this.values[e];
}
addValue(e, n, r) {
const s = this.addFile(e);
Object.hasOwn(s, n) ? Array.isArray(s[n]) ? s[n].push(r) : s[n] = [s[n], r] : s[n] = r, this._all = void 0;
}
}
function pn(t) {
const e = new mn();
for (const n of Wt(t))
e.addValue(n.file, String(n.key), n.value);
return e;
}
function dn(t, e) {
let n = null;
const r = [], s = /* @__PURE__ */ new Map();
for (const o of Wt(t, e))
o.key === e && (r.push(n = o.value), s.has(o.file) || s.set(o.file, []), s.get(o.file).push(n));
return {
key: e,
paths: Array.from(s.keys()),
scopes: s,
value: n,
values: r
};
}
function gn(t) {
return t.replace(/^(file):/, "");
}
function* Wt(t, e = null) {
const n = t.split("\0");
for (let r = 0, s = n.length - 1; r < s; ) {
const o = gn(n[r++]);
let i = n[r++], a = e;
if (i.includes(`
`)) {
const c = Pe(i, `
`);
a = c[0], i = c[1];
}
yield { file: o, key: a, value: i };
}
}
var Ht = /* @__PURE__ */ ((t) => (t.system = "system", t.global = "global", t.local = "local", t.worktree = "worktree", t))(Ht || {});
function Y(t, e) {
return typeof t == "string" && Object.hasOwn(Ht, t) ? t : e;
}
function yn(t, e, n, r) {
const s = ["config", `--${r}`];
return n && s.push("--add"), s.push(t, e), {
commands: s,
format: "utf-8",
parser(o) {
return o;
}
};
}
function wn(t, e) {
const n = ["config", "--null", "--show-origin", "--get-all", t];
return e && n.splice(1, 0, `--${e}`), {
commands: n,
format: "utf-8",
parser(r) {
return dn(r, t);
}
};
}
function bn(t) {
const e = ["config", "--list", "--show-origin", "--null"];
return t && e.push(`--${t}`), {
commands: e,
format: "utf-8",
parser(n) {
return pn(n);
}
};
}
function Tn() {
return {
addConfig(t, e, ...n) {
return this._runTask(
yn(
t,
e,
n[0] === !0,
Y(
n[1],
"local"
/* local */
)
),
u(arguments)
);
},
getConfig(t, e) {
return this._runTask(
wn(t, Y(e, void 0)),
u(arguments)
);
},
listConfig(...t) {
return this._runTask(
bn(Y(t[0], void 0)),
u(arguments)
);
}
};
}
var Kt = /* @__PURE__ */ ((t) => (t.ADDED = "A", t.COPIED = "C", t.DELETED = "D", t.MODIFIED = "M", t.RENAMED = "R", t.CHANGED = "T", t.UNMERGED = "U", t.UNKNOWN = "X", t.BROKEN = "B", t))(Kt || {});
const kn = new Set(Object.values(Kt));
function _n(t) {
return kn.has(t);
}
var _t;
const vn = ["-h"], j = /* @__PURE__ */ Symbol("grepQuery");
class En {
constructor() {
this[_t] = [];
}
*[(_t = j, Symbol.iterator)]() {
for (const e of this[j])
yield e;
}
and(...e) {
return e.length && this[j].push("--and", "(", ...U(e, "-e"), ")"), this;
}
param(...e) {
return this[j].push(...U(e, "-e")), this;
}
}
function Sn(...t) {
return new En().param(...t);
}
function Rn(t) {
const e = /* @__PURE__ */ new Set(), n = {};
return ut(t, (r) => {
const [s, o, i] = r.split(I);
e.add(s), (n[s] = n[s] || []).push({
line: p(o),
path: s,
preview: i
});
}), {
paths: e,
results: n
};
}
function On() {
return {
grep(t) {
const e = u(arguments), n = h(arguments);
for (const s of vn)
if (n.includes(s))
return this._runTask(
b(`git.grep: use of "${s}" is not supported.`),
e
);
typeof t == "string" && (t = Sn().param(t));
const r = ["grep", "--null", "-n", "--full-name", ...n, ...t];
return this._runTask(
{
commands: r,
format: "utf-8",
parser(s) {
return Rn(s);
}
},
e
);
}
};
}
var Vt = /* @__PURE__ */ ((t) => (t.MIXED = "mixed", t.SOFT = "soft", t.HARD = "hard", t.MERGE = "merge", t.KEEP = "keep", t))(Vt || {});
const Cn = L(Object.values(Vt));
function An(t, e) {
const n = ["reset"];
return Xt(t) && n.push(`--${t}`), n.push(...e), g(n);
}
function xn(t) {
if (Xt(t))
return t;
switch (typeof t) {
case "string":
case "undefined":
return "soft";
}
}
function Xt(t) {
return typeof t == "string" && Cn.includes(t);
}
it.formatters.L = (t) => String(Bt(t) ? t.length : "-");
it.formatters.B = (t) => Buffer.isBuffer(t) ? t.toString("utf8") : ft(t);
function Nn() {
return it("simple-git");
}
function vt(t, e, n) {
return !e || !String(e).replace(/\s*/, "") ? n ? (r, ...s) => {
t(r, ...s), n(r, ...s);
} : t : (r, ...s) => {
t(`%s ${r}`, e, ...s), n && n(r, ...s);
};
}
function $n(t, e, { namespace: n }) {
if (typeof t == "string")
return t;
const r = e && e.namespace || "";
return r.startsWith(n) ? r.substr(n.length + 1) : r || n;
}
function $(t, e, n, r = Nn()) {
const s = t && `[${t}]` || "", o = [], i = typeof e == "string" ? r.extend(e) : e, a = $n(d(e, m), i, r);
return y(n);
function c(w, T) {
return S(
o,
$(t, a.replace(/^[^:]+/, w), T, r)
);
}
function y(w) {
const T = w && `[${w}]` || "", k = i && vt(i, T) || W, C = vt(r, `${s} ${T}`, k);
return Object.assign(i ? k : C, {
label: t,
sibling: c,
info: C,
step: y
});
}
}
const M = class M {
constructor(e = "GitExecutor") {
this.logLabel = e, this._queue = /* @__PURE__ */ new Map();
}
withProgress(e) {
return this._queue.get(e);
}
createProgress(e) {
const n = M.getName(e.commands[0]), r = $(this.logLabel, n);
return {
task: e,
logger: r,
name: n
};
}
push(e) {
const n = this.createProgress(e);
return n.logger("Adding task to the queue, commands = %o", e.commands), this._queue.set(e, n), n;
}
fatal(e) {
for (const [n, { logger: r }] of Array.from(this._queue.entries()))
n === e.task ? (r.info("Failed %o", e), r(
"Fatal exception, any as-yet un-started tasks run through this executor will not be attempted"
)) : r.info(
"A fatal exception occurred in a previous task, the queue has been purged: %o",
e.message
), this.complete(n);
if (this._queue.size !== 0)
throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`);
}
complete(e) {
this.withProgress(e) && this._queue.delete(e);
}
attempt(e) {
const n = this.withProgress(e);
if (!n)
throw new O(void 0, "TasksPendingQueue: attempt called for an unknown task");
return n.logger("Starting task"), n;
}
static getName(e = "empty") {
return `task:${e}:${++M.counter}`;
}
};
M.counter = 0;
let ot = M;
class Pn {
constructor(e, n, r) {
this._executor = e, this._scheduler = n, this._plugins = r, this._chain = Promise.resolve(), this._queue = new ot();
}
get cwd() {
return this._cwd || this._executor.cwd;
}
set cwd(e) {
this._cwd = e;
}
get env() {
return this._executor.env;
}
get outputHandler() {
return this._executor.outputHandler;
}
chain() {
return this;
}
push(e) {
return this._queue.push(e), this._chain = this._chain.then(() => this.attemptTask(e));
}
async attemptTask(e) {
const n = await this._scheduler.next(), r = () => this._queue.complete(e);
try {
const { logger: s } = this._queue.attempt(e);
return await (kt(e) ? this.attemptEmptyTask(e, s) : this.attemptRemoteTask(e, s));
} catch (s) {
throw this.onFatalException(e, s);
} finally {
r(), n();
}
}
onFatalException(e, n) {
const r = n instanceof O ? Object.assign(n, { task: e }) : new O(e, n && String(n));
return this._chain = Promise.resolve(), this._queue.fatal(r), r;
}
async attemptRemoteTask(e, n) {
const r = this._plugins.exec("spawn.binary", "", this.taskContext(e, e.commands)), s = this._plugins.exec(
"spawn.args",
[...e.commands],
this.taskContext(e, e.commands)
), o = await this.gitResponse(
e,
r,
s,
this.outputHandler,
n.step("SPAWN")
), i = await this.handleTaskData(e, s, o, n.step("HANDLE"));
return n("passing response to task's parser as a %s", e.format), en(e) ? Tt(e.parser, i) : Tt(e.parser, i.asStrings());
}
async attemptEmptyTask(e, n) {
return n("empty task bypassing child process to call to task's parser"), e.parser(this);
}
handleTaskData(e, n, r, s) {
const { exitCode: o, rejection: i, stdOut: a, stdErr: c } = r;
return new Promise((y, w) => {
s("Preparing to handle process response exitCode=%d stdOut=", o);
const { error: T } = this._plugins.exec(
"task.error",
{ error: i },
{
...this.taskContext(e, n),
...r
}
);
if (T && e.onError)
return s.info("exitCode=%s handling with custom error handler"), e.onError(
r,
T,
(k) => {
s.info("custom error handler treated as success"), s("custom error returned a %s", ft(k)), y(
new z(
Array.isArray(k) ? Buffer.concat(k) : k,
Buffer.concat(c)
)
);
},
w
);
if (T)
return s.info(
"handling as error: exitCode=%s stdErr=%s rejection=%o",
o,
c.length,
i
), w(T);
s.info("retrieving task output complete"), y(new z(Buffer.concat(a), Buffer.concat(c)));
});
}
async gitResponse(e, n, r, s, o) {
const i = o.sibling("output"), a = this._plugins.exec(
"spawn.options",
{
cwd: this.cwd,
env: this.env,
windowsHide: !0
},
this.taskContext(e, e.commands)
);
return new Promise((c) => {
const y = [], w = [];
o.info("%s %o", n, r), o("%O", a);
let T = this._beforeSpawn(e, r);
if (T)
return c({
stdOut: y,
stdErr: w,
exitCode: 9901,
rejection: T
});
this._plugins.exec("spawn.before", void 0, {
...this.taskContext(e, r),
kill(C) {
T = C || T;
}
});
const k = ve(n, r, a);
k.stdout.on(
"data",
Et(y, "stdOut", o, i.step("stdOut"))
), k.stderr.on(
"data",
Et(w, "stdErr", o, i.step("stdErr"))
), k.on("error", Mn(w, o)), s && (o("Passing child process stdOut/stdErr to custom outputHandler"), s(n, k.stdout, k.stderr, [...r])), this._plugins.exec("spawn.after", void 0, {
...this.taskContext(e, r),
spawned: k,
close(C, Te) {
c({
stdOut: y,
stdErr: w,
exitCode: C,
rejection: T || Te
});
},
kill(C) {
k.killed || (T = C, k.kill("SIGINT"));
}
});
});
}
_beforeSpawn(e, n) {
let r;
return this._plugins.exec("spawn.before", void 0, {
...this.taskContext(e, n),
kill(s) {
r = s || r;
}
}), r;
}
taskContext(e, n) {
return {
method: String(Me(e.commands) || ""),
commands: n,
env: { ...this.env },
input: kt(e) ? void 0 : e.input
};
}
}
function Mn(t, e) {
return (n) => {
e("[ERROR] child process exception %o", n), t.push(Buffer.from(String(n.stack), "ascii"));
};
}
function Et(t, e, n, r) {
return (s) => {
n("%s received %L bytes", e, s), r("%B", s), t.push(s);
};
}
class Dn {
constructor(e, n, r) {
this.cwd = e, this._scheduler = n, this._plugins = r, this._chain = this.chain();
}
chain() {
return new Pn(this, this._scheduler, this._plugins);
}
push(e) {
return this._chain.push(e);
}
}
function Ln(t, e, n = W) {
const r = (o) => {
n(null, o);
}, s = (o) => {
o?.task === t && n(o, void 0);
};
e.then(r, s);
}
function St(t, e) {
return tn((n) => {
if (!Lt(t))
throw new Error(`Git.cwd: cannot change to non-directory "${t}"`);
return (e || n).cwd = t;
});
}
function Q(t) {
const e = ["checkout", ...t];
return e[1] === "-b" && e.includes("-B") && (e[1] = ct(e, "-B")), g(e);
}
function jn() {
return {
checkout() {
return this._runTask(
Q(h(arguments, 1)),
u(arguments)
);
},
checkoutBranch(t, e) {
return this._runTask(
Q(["-b", t, e, ...h(arguments)]),
u(arguments)
);
},
checkoutLocalBranch(t) {
return this._runTask(
Q(["-b", t, ...h(arguments)]),
u(arguments)
);
}
};
}
const Yt = (t, e, n) => {
const r = ["clone", ...n];
return m(t) && r.push(rt(t)), m(e) && r.push(rt(e)), g(r);
}, Bn = (t, e, n) => (S(n, "--mirror"), Yt(t, e, n));
function Rt(t, e, n, ...r) {
return m(n) ? e(n, d(r[0], m), h(arguments)) : b(`git.${t}() requires a string 'repoPath'`);
}
function In() {
return {
clone(t, ...e) {
return this._runTask(
Rt("clone", Yt, d(t, m), ...e),
u(arguments)
);
},
mirror(t, ...e) {
return this._runTask(
Rt("mirror", Bn, d(t, m), ...e),
u(arguments)
);
}
};
}
const Un = [
new l(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/, (t, [e, n, r]) => {
t.branch = e, t.commit = r, t.root = !!n;
}),
new l(/\s*Author:\s(.+)/i, (t, [e]) => {
const n = e.split("<"), r = n.pop();
!r || !r.includes("@") || (t.author = {
email: r.substr(0, r.length - 1),
name: n.join("<").trim()
});
}),
new l(
/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,
(t, [e, n, r]) => {
t.summary.changes = parseInt(e, 10) || 0, t.summary.insertions = parseInt(n, 10) || 0, t.summary.deletions = parseInt(r, 10) || 0;
}
),
new l(
/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,
(t, [e, n, r]) => {
t.summary.changes = parseInt(e, 10) || 0;
const s = parseInt(n, 10) || 0;
r === "-" ? t.summary.deletions = s : r === "+" && (t.summary.insertions = s);
}
)
];
function Fn(t) {
return E({
author: null,
branch: "",
commit: "",
root: !1,
summary: {
changes: 0,
insertions: 0,
deletions: 0
}
}, Un, t);
}
function Gn(t, e, n) {
return {
commands: [
"-c",
"core.abbrev=40",
"commit",
...U(t, "-m"),
...e,
...n
],
format: "utf-8",
parser: Fn
};
}
function zn() {
return {
commit(e, ...n) {
const r = u(arguments), s = t(e) || Gn(
v(e),
v(d(n[0], G, [])),
[
...L(d(n[1], K, [])),
...h(arguments, 0, !0)
]
);
return this._runTask(s, r);
}
};
function t(e) {
return !G(e) && b(
"git.commit: requires the commit message to be supplied as a string/string[]"
);
}
}
function qn() {
return {
count: 0,
garbage: 0,
inPack: 0,
packs: 0,
prunePackable: 0,
size: 0,
sizeGarbage: 0,
sizePack: 0
};
}
const Wn = new l(
/([a-z-]+): (\d+)$/,
(t, [e, n]) => {
const r = jt(e);
Object.hasOwn(t, r) && (t[r] = p(n));
}
);
function Hn() {
return {
countObjects() {
return this._runTask({
commands: ["count-objects", "--verbose"],
format: "utf-8",
parser(t) {
return E(qn(), [Wn], t);
}
});
}
};
}
function Kn() {
return {
firstCommit() {
return this._runTask(
g(["rev-list", "--max-parents=0", "HEAD"], !0),
u(arguments)
);
}
};
}
function Vn(t, e) {
const n = ["hash-object", t];
return e && n.push("-w"), g(n, !0);
}
class J {
constructor(e, n, r, s) {
this.bare = e, this.path = n, this.existing = r, this.gitDir = s;
}
}
const Xn = /^Init.+ repository in (.+)$/, Yn = /^Rein.+ in (.+)$/;
function Qn(t, e, n) {
const r = String(n).trim();
let s;
if (s = Xn.exec(r))
return new J(t, e, !1, s[1]);
if (s = Yn.exec(r))
return new J(t, e, !0, s[1]);
let o = "";
const i = r.split(" ");
for (; i.length; )
if (i.shift() === "in") {
o = i.join(" ");
break;
}
return new J(t, e, /^re/i.test(r), o);
}
const Qt = "--bare";
function Jn(t) {
return t.includes(Qt);
}
function Zn(t = !1, e, n) {
const r = ["init", ...n];
return t && !Jn(r) && r.splice(1, 0, Qt), {
commands: r,
format: "utf-8",
parser(s) {
return Qn(r.includes("--bare"), e, s);
}
};
}
function tr(t) {
return t === void 0 ? b("interpretTrailers called without input content") : {
format: "utf-8",
parser(e) {
return Object.fromEntries(
ut(e, (n) => {
const r = n.indexOf(":");
return [
jt(n.substring(0, r).toLowerCase()),
n.substring(r + 2).trim()
];
})
);
},
commands: ["interpret-trailers", "--parse"],
input: t
};
}
function er() {
return {
interpretTrailers(t) {
return this._runTask(
tr(d(t, Be)),
u(arguments)
);
}
};
}
var R = /* @__PURE__ */ ((t) => (t.NONE = "", t.STAT = "--stat", t.NUM_STAT = "--numstat", t.NAME_ONLY = "--name-only", t.NAME_STATUS = "--name-status", t))(R || {});
const Jt = /^--(stat|numstat|name-only|name-status)(=|$)/;
function pt(t) {
for (let e = 0; e < t.length; e++) {
const n = Jt.exec(t[e]);
if (n)
return `--${n[1]}`;
}
return "";
}
function nr(t) {
return Jt.test(t);
}
class rr {
constructor() {
this.changed = 0, this.deletions = 0, this.insertions = 0, this.files = [];
}
}
const Ot = [
new l(
/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,
(t, [e, n, r = ""]) => {
t.files.push({
file: e.trim(),
changes: p(n),
insertions: r.replace(/[^+]/g, "").length,
deletions: r.replace(/[^-]/g, "").length,
binary: !1
});
}
),
new l(
/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,
(t, [e, n, r]) => {
t.files.push({
file: e.trim(),
before: p(n),
after: p(r),
binary: !0
});
}
),
new l(/^(.+)\s+\|\s+Bin\s*$/, (t, [e]) => {
t.files.push({
file: e.trim(),
before: 0,
after: 0,
binary: !0
});
}),
new l(
/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,
(t, [e, n]) => {
const r = /(\d+) i/.exec(n), s = /(\d+) d/.exec(n);
t.changed = p(e), t.insertions = p(r?.[1]), t.deletions = p(s?.[1]);
}
)
], sr = [
new l(
/(\d+)\t(\d+)\t(.+)$/,
(t, [e, n, r]) => {
const s = p(e), o = p(n);
t.changed++, t.insertions += s, t.deletions += o, t.files.push({
file: r,
changes: s + o,
insertions: s,
deletions: o,
binary: !1
});
}
),
new l(/-\t-\t(.+)$/, (t, [e]) => {
t.changed++, t.files.push({
file: e,
after: 0,
before: 0,
binary: !0
});
})
], or = [
new l(/(.+)$/, (t, [e]) => {
t.changed++, t.files.push({
file: e,
changes: 0,
insertions: 0,
deletions: 0,
binary: !1
});
})
], ir = [
new l(
/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,
(t, [e, n, r, s, o]) => {
t.changed++, t.files.push({
file: o ?? r,
changes: 0,
insertions: 0,
deletions: 0,
binary: !1,
status: bt(_n(e) && e),
from: bt(!!o && r !== o && r),
similarity: p(n)
});
}
)
], ar = {
[R.NONE]: Ot,
[R.STAT]: Ot,
[R.NUM_STAT]: sr,
[R.NAME_STATUS]: ir,
[R.NAME_ONLY]: or
};
function Zt(t = R.NONE) {
const e = ar[t];
return (n) => E(new rr(), e, n, !1);
}
const te = "òòòòòò ", ee = " òò", ne = " ò ", ur = ["hash", "date", "message", "refs", "author_name", "author_email"];
function cr(t, e) {
return e.reduce(
(n, r, s) => (n[r] = t[s] || "", n),
/* @__PURE__ */ Object.create({ diff: null })
);
}
function re(t = ne, e = ur, n = R.NONE) {
const r = Zt(n);
return function(s) {
const o = H(
s.trim(),
!1,
te
).map(function(i) {
const a = i.split(ee), c = cr(a[0].split(t), e);
return a.length > 1 && a[1].trim() && (c.diff = r(a[1])), c;
});
return {
all: o,
latest: o.length && o[0] || null,
total: o.length
};
};
}
function fr(t) {
let e = pt(t);
const n = ["diff"];
return e === R.NONE && (e = R.STAT, n.push("--stat=4096")), n.push(...t), dt(n) || {
commands: n,
format: "utf-8",
parser: Zt(e)
};
}
function dt(t) {
const e = t.filter(nr);
if (e.length > 1)
return b(
`Summary flags are mutually exclusive - pick one of ${e.join(",")}`
);
if (e.length && t.includes("-z"))
return b(
`Summary flag ${e} parsing is not compatible with null termination option '-z'`
);
}
var se = /* @__PURE__ */ ((t) => (t[t["--pretty"] = 0] = "--pretty", t[t["max-count"] = 1] = "max-count", t[t.maxCount = 2] = "maxCount", t[t.n = 3] = "n", t[t.file = 4] = "file", t[t.format = 5] = "format", t[t.from = 6] = "from", t[t.to = 7] = "to", t[t.splitter = 8] = "splitter", t[t.symmetric = 9] = "symmetric", t[t.mailMap = 10] = "mailMap", t[t.multiLine = 11] = "multiLine", t[t.strictDate = 12] = "strictDate", t))(se || {});
function lr(t, e) {
const n = [], r = [];
return Object.keys(t).forEach((s) => {
n.push(s), r.push(String(t[s]));
}), [n, r.join(e)];
}
function hr(t) {
return Object.keys(t).reduce((e, n) => (n in se || (e[n] = t[n]), e), {});
}
function oe(t = {}, e = []) {
const n = d(t.splitter, m, ne), r = lt(t.format) ? t.format : {
hash: "%H",
date: t.strictDate === !1 ? "%ai" : "%aI",
message: "%s",
refs: "%D",
body: t.multiLine ? "%B" : "%b",
author_name: t.mailMap !== !1 ? "%aN" : "%an",
author_email: t.mailMap !== !1 ? "%aE" : "%ae"
}, [s, o] = lr(r, n), i = [], a = [
`--pretty=format:${te}${o}${ee}`,
...e
], c = t.n || t["max-count"] || t.maxCount;
if (c && a.push(`--max-count=${c}`), t.from || t.to) {
const y = t.symmetric !== !1 ? "..." : "..";
i.push(`${t.from || ""}${y}${t.to || ""}`);
}
return m(t.file) && a.push("--follow", rt(t.file)), It(hr(t), a), {
fields: s,
splitter: n,
commands: [...a, ...i]
};
}
function mr(t, e, n) {
const r = re(t, e, pt(n));
return {
commands: ["log", ...n],
format: "utf-8",
parser: r
};
}
function pr() {
return {
log(...n) {
const r = u(arguments), s = oe(
ht(arguments),
L(d(arguments[0], K, []))
), o = e(...n) || dt(s.commands) || t(s);
return this._runTask(o, r);
}
};
function t(n) {
return mr(n.splitter, n.fields, n.commands);
}
function e(n, r) {
return m(n) && m(r) && b(
"git.log(string, string) should be replaced with git.log({ from: string, to: string })"
);
}
}
class Z {
constructor(e, n = null, r) {
this.reason = e, this.file = n, this.meta = r;
}
toString() {
return `${this.file}:${this.reason}`;
}
}
class dr {
constructor() {
this.conflicts = [], this.merges = [], this.result = "success";
}
get failed() {
return this.conflicts.length > 0;
}
get reason() {
return this.result;
}
toString() {
return this.conflicts.length ? `CONFLICTS: ${this.conflicts.join(", ")}` : "OK";
}
}
class ie {
constructor() {
this.remoteMessages = {
all: []
}, this.created = [], this.deleted = [], this.files = [], this.deletions = {}, this.insertions = {}, this.summary = {
changes: 0,
deletions: 0,
insertions: 0
};
}
}
class gr {
constructor() {
this.remote = "", this.hash = {
local: "",
remote: ""
}, this.branch = {
local: "",
remote: ""
}, this.message = "";
}
toString() {
return this.message;
}
}
function tt(t) {
return t.objects = t.objects || {
compressing: 0,
counting: 0,
enumerating: 0,
packReused: 0,
reused: { count: 0, delta: 0 },
total: { count: 0, delta: 0 }
};
}
function Ct(t) {
const e = /^\s*(\d+)/.exec(t), n = /delta (\d+)/i.exec(t);
return {
count: p(e && e[1] || "0"),
delta: p(n && n[1] || "0")
};
}
const yr = [
new x(
/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,
(t, [e, n]) => {
const r = e.toLowerCase(), s = tt(t.remoteMessages);
Object.assign(s, { [r]: p(n) });
}
),
new x(
/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,
(t, [e, n]) => {
const r = e.toLowerCase(), s = tt(t.remoteMessages);
Object.assign(s, { [r]: p(n) });
}
),
new x(
/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,
(t, [e, n, r]) => {
const s = tt(t.remoteMessages);
s.total = Ct(e), s.reused = Ct(n), s.packReused = p(r);
}
)
], wr = [
new x(/^remote:\s*(.+)$/, (t, [e]) => (t.remoteMessages.all.push(e.trim()), !1)),
...yr,
new x(
[/create a (?:pull|merge) request/i, /\s(https?:\/\/\S+)$/],
(t, [e]) => {
t.remoteMessages.pullRequestUrl = e;
}
),
new x(
[/found (\d+) vulnerabilities.+\(([^)]+)\)/i, /\s(https?:\/\/\S+)$/],
(t, [e, n, r]) => {
t.remoteMessages.vulnerabilities = {
count: p(e),
summary: n,
url: r
};
}
)
];
function ae(t, e) {
return E({ remoteMessages: new br() }, wr, e);
}
class br {
constructor() {
this.all = [];
}
}
const Tr = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/, kr = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/, _r = /^(create|delete) mode \d+ (.+)/, vr = [
new l(Tr, (t, [e, n, r]) => {
t.files.push(e), n && (t.insertions[e] = n.length), r && (t.deletions[e] = r.length);
}),
new l(kr, (t, [e, , n, , r]) => n !== void 0 || r !== void 0 ? (t.summary.changes = +e || 0, t.summary.insertions = +n || 0, t.summary.deletions = +r || 0, !0) : !1),
new l(_r, (t, [e, n]) => {
S(t.files, n), S(e === "create" ? t.created : t.deleted, n);
})
], Er = [
new l(/^from\s(.+)$/i, (t, [e]) => {
t.remote = e;
}),
new l(/^fatal:\s(.+)$/, (t, [e]) => {
t.message = e;
}),
new l(
/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,
(t, [e, n, r, s]) => {
t.branch.local = r, t.hash.local = e, t.branch.remote = s, t.hash.remote = n;
}
)
], Sr = (t, e) => E(new ie(), vr, [t, e]), ue = (t, e) => Object.assign(
new ie(),
Sr(t, e),
ae(t, e)
);
function Rr(t, e) {
const n = E(new gr(), Er, [t, e]);
return n.message && n;
}
const Or = [
new l(/^Auto-merging\s+(.+)$/, (t, [e]) => {
t.merges.push(e);
}),
new l(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/, (t, [e, n]) => {
t.conflicts.push(new Z(e, n));
}),
new l(
/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,
(t, [e, n, r]) => {
t.conflicts.push(new Z(e, n, { deleteRef: r }));
}
),
new l(/^CONFLICT\s+\((.+)\):/, (t, [e]) => {
t.conflicts.push(new Z(e, null));
}),
new l(/^Automatic merge failed;\s+(.+)$/, (t, [e]) => {
t.result = e;
})
], Cr = (t, e) => Object.assign(Ar(t), ue(t, e)), Ar = (t) => E(new dr(), Or, t);
function At(t) {
return t.length ? {
commands: ["merge", ...t],
format: "utf-8",
parser(e, n) {
const r = Cr(e, n);
if (r.failed)
throw new at(r);
return r;
}
} : b("Git.merge requires at least one option");
}
function xr(t, e, n) {
const r = n.includes("deleted"), s = n.includes("tag") || /^refs\/tags/.test(t), o = !n.includes("new");
return {
deleted: r,
tag: s,
branch: !s,
new: !o,
alreadyUpdated: o,
local: t,
remote: e
};
}
const Nr = [
new l(/^Pushing to (.+)$/, (t, [e]) => {
t.repo = e;
}),
new l(/^updating local tracking ref '(.+)'/, (t, [e]) => {
t.ref = {
...t.ref || {},
local: e
};
}),
new l(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/, (t, [e, n, r]) => {
t.pushed.push(xr(e, n, r));
}),
new l(
/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,
(t, [e, n, r]) => {
t.branch = {
...t.branch || {},
local: e,
remote: n,
remoteName: r
};
}
),
new l(
/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,
(t, [e, n, r, s]) => {
t.update = {
head: {
local: e,
remote: n
},
hash: {
from: r,
to: s
}
};
}
)
], $r = (t, e) => {
const n = Pr(t, e), r = ae(t, e);
return {
...n,
...r
};
}, Pr = (t, e) => E({ pushed: [] }, Nr, [t, e]);
function Mr(t = {}, e) {
return S(e, "--tags"), ce(t, e);
}
function ce(t = {}, e) {
const n = ["push", ...e];
return t.branch && n.splice(1, 0, t.branch), t.remote && n.splice(1, 0, t.remote), ct(n, "-v"), S(n, "--verbose"), S(n, "--porcelain"), {
commands: n,
format: "utf-8",
parser: $r
};
}
function Dr() {
return {
showBuffer() {
const t = ["show", ...h(arguments, 1)];
return t.includes("--binary") || t.splice(1, 0, "--binary"), this._runTask(
Gt(t),
u(arguments)
);
},
show() {
const t = ["show", ...h(arguments, 1)];
return this._runTask(
g(t),
u(arguments)
);
}
};
}
const Lr = /^(.+)\0(.+)$/;
class jr {
constructor(e, n, r) {
if (this.path = e, this.index = n, this.working_dir = r, n === "R" || r === "R") {
const s = Lr.exec(e) || [null, e, e];
this.from = s[2] || "", this.path = s[1] || "";
}
}
}
class Br {
constructor() {
this.not_added = [], this.conflicted = [], this.created = [], this.deleted = [], this.ignored = void 0, this.modified = [], this.renamed = [], this.files = [], this.staged = [], this.ahead = 0, this.behind = 0, this.current = null, this.tracking = null, this.detached = !1, this.isClean = () => !this.files.length;
}
}
function xt(t) {
const [e, n] = t.split(I);
return {
from: n || e,
to: e
};
}
function _(t, e, n) {
return [`${t}${e}`, n];
}
function et(t, ...e) {
return e.map((n) => _(t, n, (r, s) => r.conflicted.push(s)));
}
const Ir = new Map([
_(
" ",
"A",
(t, e) => t.created.push(e)
),
_(
" ",
"D",
(t, e) => t.deleted.push(e)
),
_(
" ",
"M",
(t, e) => t.modified.push(e)
),
_("A", " ", (t, e) => {
t.created.push(e), t.staged.push(e);
}),
_("A", "M", (t, e) => {
t.created.push(e), t.staged.push(e), t.modified.push(e);
}),
_("D", " ", (t, e) => {
t.deleted.push(e), t.staged.push(e);
}),
_("M", " ", (t, e) => {
t.modified.push(e), t.staged.push(e);
}),
_("M", "M", (t, e) => {
t.modified.push(e), t.staged.push(e);
}),
_("R", " ", (t, e) => {
t.renamed.push(xt(e));
}),
_("R", "M", (t, e) => {
const n = xt(e);
t.renamed.push(n), t.modified.push(n.to);
}),
_("!", "!", (t, e) => {
(t.ignored = t.ignored || []).push(e);
}),
_(
"?",
"?",
(t, e) => t.not_added.push(e)
),
...et(
"A",
"A",
"U"
/* UNMERGED */
),
...et(
"D",
"D",
"U"
/* UNMERGED */
),
...et(
"U",
"A",
"D",
"U"
/* UNMERGED */
),
[
"##",
(t, e) => {
const n = /ahead (\d+)/, r = /behind (\d+)/, s = /^(.+?(?=(?:\.{3}|\s|$)))/, o = /\.{3}(\S*)/, i = /\son\s(\S+?)(?=\.{3}|$)/;
let a = n.exec(e);
t.ahead = a && +a[1] || 0, a = r.exec(e), t.behind = a && +a[1] || 0, a = s.exec(e), t.current = d(a?.[1], m, null), a = o.exec(e), t.tracking = d(a?.[1], m, null), a = i.exec(e), a && (t.current = d(a?.[1], m, t.current)), t.detached = /\(no branch\)/.test(e);
}
]
]), Ur = function(t) {
const e = t.split(I), n = new Br();
for (let r = 0, s = e.length; r < s; ) {
let o = e[r++].trim();
o && (o.charAt(0) === "R" && (o += I + (e[r++] || "")), Fr(n, o));
}
return n;
};
function Fr(t, e) {
const n = e.trim();
switch (" ") {
case n.charAt(2):
return r(n.charAt(0), n.charAt(1), n.slice(3));
case n.charAt(1):
return r(" ", n.charAt(0), n.slice(2));
default:
return;
}
function r(s, o, i) {
const a = `${s}${o}`, c = Ir.get(a);
c && c(t, i), a !== "##" && a !== "!!" && t.files.push(new jr(i, s, o));
}
}
const Gr = ["--null", "-z"];
function zr(t) {
return {
format: "utf-8",
commands: [
"status",
"--porcelain",
"-b",
"-u",
"--null",
...t.filter((n) => !Gr.includes(n))
],
parser(n) {
return Ur(n);
}
};
}
const fe = "installed=false";
function q(t = 0, e = 0, n = 0, r = "", s = !0) {
return Object.defineProperty(
{
major: t,
minor: e,
patch: n,
agent: r,
installed: s
},
"toString",
{
value() {
return `${this.major}.${this.minor}.${this.patch}`;
},
configurable: !1,
enumerable: !1
}
);
}
function qr() {
return q(0, 0, 0, "", !1);
}
function Wr() {
return {
version() {
return this._runTask({
commands: ["--version"],
format: "utf-8",
parser: Kr,
onError(t, e, n, r) {
if (t.exitCode === V.NOT_FOUND)
return n(Buffer.from(fe));
r(e);
}
});
}
};
}
const Hr = [
new l(
/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,
(t, [e, n, r, s = ""]) => {
Object.assign(
t,
q(p(e), p(n), p(r), s)
);
}
),
new l(
/version (\d+)\.(\d+)\.(\D+)(.+)?$/,
(t, [e, n, r, s = ""]) => {
Object.assign(t, q(p(e), p(n), r, s));
}
)
];
function Kr(t) {
return t === fe ? qr() : E(q(0, 0, 0, t), Hr, t);
}
class le {
constructor(e) {
this._executor = e;
}
_runTask(e, n) {
const r = this._executor.chain(), s = r.push(e);
return n && Ln(e, s, n), Object.create(this, {
then: { value: s.then.bind(s) },
catch: { value: s.catch.bind(s) },
_executor: { value: r }
});
}
add(e) {
return this._runTask(
g(["add", ...v(e)]),
u(arguments)
);
}
cwd(e) {
const n = u(arguments);
return typeof e == "string" ? this._runTask(St(e, this._executor), n) : typeof e?.path == "string" ? this._runTask(
St(
e.path,
e.root && this._executor || void 0
),
n
) : this._runTask(
b("Git.cwd: workingDirectory must be supplied as a string"),
n
);
}
hashObject(e, n) {
return this._runTask(
Vn(e, n === !0),
u(arguments)
);
}
init(e) {
return this._runTask(
Zn(e === !0, this._executor.cwd, h(arguments)),
u(arguments)
);
}
merge() {
return this._runTask(
At(h(arguments)),
u(arguments)
);
}
mergeFromTo(e, n) {
return m(e) && m(n) ? this._runTask(
At([e, n, ...h(arguments)]),
u(arguments, !1)
) : this._runTask(
b(
"Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings"
)
);
}
outputHandler(e) {
return this._executor.outputHandler = e, this;
}
push() {
const e = ce(
{
remote: d(arguments[0], m),
branch: d(arguments[1], m)
},
h(arguments)
);
return this._runTask(e, u(arguments));
}
stash() {
return this._runTask(
g(["stash", ...h(arguments)]),
u(arguments)
);
}
status() {
return this._runTask(
zr(h(arguments)),
u(arguments)
);
}
}
Object.assign(
le.prototype,
jn(),
In(),
zn(),
Tn(),
Hn(),
Kn(),
On(),
er(),
pr(),
Dr(),
Wr()
);
const Vr = /* @__PURE__ */ (() => {
let t = 0;
return () => {
t++;
const { promise: e, done: n } = Ee();
return {
promise: e,
done: n,
id: t
};
};
})();
class Xr {
constructor(e = 2) {
this.concurrency = e, this.logger = $("", "scheduler"), this.pending = [], this.running = [], this.logger("Constructed, concurrency=%s", e);
}
schedule() {
if (!this.pending.length || this.running.length >= this.concurrency) {
this.logger(
"Schedule attempt ignored, pending=%s running=%s concurrency=%s",
this.pending.length,
this.running.length,
this.concurrency
);
return;
}
const e = S(this.running, this.pending.shift());
this.logger("Attempting id=%s", e.id), e.done(() => {
this.logger("Completing id=", e.id), ct(this.running, e), this.schedule();
});
}
next() {
const { promise: e, id: n } = S(this.pending, Vr());
return this.logger("Scheduling id=%s", n), this.schedule(), e;
}
}
function Yr(t, e) {
return g(["apply", ...e, ...t]);
}
var he = /* @__PURE__ */ ((t) => (t.CURRENT = "*", t.LINKED = "+", t))(he || {});
class Qr {
constructor() {
this.all = [], this.branches = {}, this.current = "", this.detached = !1;
}
push(e, n, r, s, o) {
e === "*" && (this.detached = n, this.current = r), this.all.push(r), this.branches[r] = {
current: e === "*",
linkedWorkTree: e === "+",
name: r,
commit: s,
label: o
};
}
}
const Jr = [
new l(
/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,
(t, [e, n, r, s]) => {
t.push(Nt(e), !0, n, r, s);
}
),
new l(
/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,
(t, [e, n, r, s]) => {
t.push(Nt(e), !1, n, r, s);
}
)
], Zr = new l(/^(\S+)$/s, (t, [e]) => {
t.push(he.CURRENT, !1, e, "", "");
});
function Nt(t) {
return t ? t.charAt(0) : "";
}
function me(t, e = !1) {
return E(
new Qr(),
e ? [Zr] : Jr,
t
);
}
class ts {
constructor() {
this.all = [], this.branches = {}, this.errors = [];
}
get success() {
return !this.errors.length;
}
}
function es(t, e) {
return {
branch: t,
hash: e,
success: !0
};
}
function ns(t) {
return {
branch: t,
hash: null,
success: !1
};
}
const rs = /(\S+)\s+\(\S+\s([^)]+)\)/, pe = /^error[^']+'([^']+)'/m, ss = [
new l(rs, (t, [e, n]) => {
const r = es(e, n);
t.all.push(r), t.branches[e] = r;
}),
new l(pe, (t, [e]) => {
const n = ns(e);
t.errors.push(n), t.all.push(n), t.branches[e] = n;
})
], gt = (t, e) => E(new ts(), ss, [t, e]);
function de(t, e) {
return e === V.ERROR && pe.test(t);
}
function os(t) {
const e = ["-d", "-D", "--delete"];
return t.some((n) => e.includes(n));
}
function is(t) {
const e = os(t), n = t.includes("--show-current"), r = ["branch", ...t];
return r.length === 1 && r.push("-a"), r.includes("-v") || r.splice(1, 0, "-v"), {
format: "utf-8",
commands: r,
parser(s, o) {
return e ? gt(s, o).all[0] : me(s, n);
}
};
}
function as() {
return {
format: "utf-8",
commands: ["branch", "-v"],
parser(t) {
return me(t);
}
};
}
function us(t, e = !1) {
return {
format: "utf-8",
commands: ["branch", "-v", e ? "-D" : "-d", ...t],
parser(n, r) {
return gt(n, r);
},
onError({ exitCode: n, stdOut: r }, s, o, i) {
if (!de(String(s), n))
return i(s);
o(r);
}
};
}
function cs(t, e = !1) {
const n = {
format: "utf-8",
commands: ["branch", "-v", e ? "-D" : "-d", t],
parser(r, s) {
return gt(r, s).branches[t];
},
onError({ exitCode: r, stdErr: s, stdOut: o }, i, a, c) {
if (!de(String(i), r))
return c(i);
throw new at(
n.parser(F(o), F(s)),
String(i)
);
}
};
return n;
}
function fs(t) {
return {
commands: ["check-ignore", ...t],
format: "utf-8",
parser: ls
};
}
function ls(t) {
return t.split(/\n/g).map(hs).filter(Boolean);
}
function hs(t) {
const e = t.trim().replace(/^["']|["']$/g, "");
return e && Se(e);
}
const ms = [
new l(/From (.+)$/, (t, [e]) => {
t.remote = e;
}),
new l(/\* \[new branch]\s+(\S+)\s*-> (.+)$/, (t, [e, n]) => {
t.branches.push({
name: e,
tracking: n
});
}),
new l(/\* \[new tag]\s+(\S+)\s*-> (.+)$/, (t, [e, n]) => {
t.tags.push({
name: e,
tracking: n
});
}),
new l(/- \[deleted]\s+\S+\s*-> (.+)$/, (t, [e]) => {
t.deleted.push({
tracking: e
});
}),
new l(
/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,
(t, [e, n, r, s]) => {
t.updated.push({
name: r,
tracking: s,
to: n,
from: e
});
}
)
];
function ps(t, e) {
return E({
raw: t,
remote: null,
branches: [],
tags: [],
updated: [],
deleted: []
}, ms, [t, e]);
}
function ds(t) {
return /^--upload-pack(=|$)/.test(t);
}
function gs(t, e, n) {
const r = ["fetch", ...n];
return t && e && r.push(t, e), r.find(ds) ? b("git.fetch: potential exploit argument blocked.") : {
commands: r,
format: "utf-8",
parser: ps
};
}
const ys = [
new l(/^Renaming (.+) to (.+)$/, (t, [e, n]) => {
t.moves.push({ from: e, to: n });
})
];
function ws(t) {
return E({ moves: [] }, ys, t);
}
function bs(t, e) {
return {
commands: ["mv", "-v", ...v(t), e],
format: "utf-8",
parser: ws
};
}
function Ts(t, e, n) {
const r = ["pull", ...n];
return t && e && r.splice(1, 0, t, e), {
commands: r,
format: "utf-8",
parser(s, o) {
return ue(s, o);
},
onError(s, o, i, a) {
const c = Rr(
F(s.stdOut),
F(s.stdErr)
);
if (c)
return a(new at(c));
a(o);
}
};
}
function ks(t) {
const e = {};
return ge(t, ([n]) => e[n] = { name: n }), Object.values(e);
}
function _s(t) {
const e = {};
return ge(t, ([n, r, s]) => {
Object.hasOwn(e, n) || (e[n] = {
name: n,
refs: { fetch: "", push: "" }
}), s && r && (e[n].refs[s.replace(/[^a-z]/g, "")] = r);
}), Object.values(e);
}
function ge(t, e) {
ut(t, (n) => e(n.split(/\s+/)));
}
function vs(t, e, n) {
return g(["remote", "add", ...n, t, e]);
}
function Es(t) {
const e = ["remote"];
return t && e.push("-v"), {
commands: e,
format: "utf-8",
parser: t ? _s : ks
};
}
function Ss(t) {
const e = [...t];
return e[0] !== "ls-remote" && e.unshift("ls-remote"), g(e);
}
function Rs(t) {
const e = [...t];
return e[0] !== "remote" && e.unshift("remote"), g(e);
}
function Os(t) {
return g(["remote", "remove", t]);
}
function Cs(t = {}, e) {
const n = oe(t), r = ["stash", "list", ...n.commands, ...e], s = re(
n.splitter,
n.fields,
pt(r)
);
return dt(r) || {
commands: r,
format: "utf-8",
parser: s
};
}
function As(t, e) {
return X(["add", t, e]);
}
function xs(t) {
return X(["init", ...t]);
}
function X(t) {
const e = [...t];
return e[0] !== "submodule" && e.unshift("submodule"), g(e);
}
function Ns(t) {
return X(["update", ...t]);
}
class $s {
constructor(e, n) {
this.all = e, this.latest = n;
}
}
const Ps = function(t, e = !1) {
const n = t.split(`
`).map(Ds).filter(Boolean);
e || n.sort(function(s, o) {
const i = s.split("."), a = o.split(".");
if (i.length === 1 || a.length === 1)
return Ms(B(i[0]), B(a[0]));
for (let c = 0, y = Math.max(i.length, a.length); c < y; c++) {
const w = ye(B(i[c]), B(a[c]));
if (w)
return w;
}
return 0;
});
const r = e ? n[0] : [...n].reverse().find((s) => s.indexOf(".") >= 0);
return new $s(n, r);
};
function Ms(t, e) {
const n = Number.isNaN(t), r = Number.isNaN(e);
return n !== r ? n ? 1 : -1 : n ? ye(t, e) : 0;
}
function ye(t, e) {
return t === e ? 0 : t > e ? 1 : -1;
}
function Ds(t) {
return t.trim();
}
function B(t) {
return typeof t == "string" && parseInt(t.replace(/^\D+/g, ""), 10) || 0;
}
function Ls(t = []) {
const e = t.some((n) => /^--sort=/.test(n));
return {
format: "utf-8",
commands: ["tag", "-l", ...t],
parser(n) {
return Ps(n, e);
}
};
}
function js(t) {
return {
format: "utf-8",
commands: ["tag", t],
parser() {
return { name: t };
}
};
}
function Bs(t, e) {
return {
format: "utf-8",
commands: ["tag", "-a", "-m", e, t],
parser() {
return { name: t };
}
};
}
function f(t, e) {
this._plugins = e, this._executor = new Dn(
t.baseDir,
new Xr(t.maxConcurrentProcesses),
e
), this._trimmed = t.trimmed;
}
(f.prototype = Object.create(le.prototype)).constructor = f;
f.prototype.customBinary = function(t) {
return this._plugins.reconfigure("binary", t), this;
};
f.prototype.env = function(t, e) {
return arguments.length === 1 && typeof t == "object" ? this._executor.env = t : (this._executor.env = this._executor.env || {})[t] = e, this;
};
f.prototype.stashList = function(t) {
return this._runTask(
Cs(
ht(arguments) || {},
K(t) && t || []
),
u(arguments)
);
};
f.prototype.mv = function(t, e) {
return this._runTask(bs(t, e), u(arguments));
};
f.prototype.checkoutLatestTag = function(t) {
var e = this;
return this.pull(function() {
e.tags(function(n, r) {
e.checkout(r.latest, t);
});
});
};
f.prototype.pull = function(t, e, n, r) {
return this._runTask(
Ts(
d(t, m),
d(e, m),
h(arguments)
),
u(arguments)
);
};
f.prototype.fetch = function(t, e) {
return this._runTask(
gs(
d(t, m),
d(e, m),
h(arguments)
),
u(arguments)
);
};
f.prototype.tags = function(t, e) {
return this._runTask(
Ls(h(arguments)),
u(arguments)
);
};
f.prototype.rebase = function() {
return this._runTask(
g(["rebase", ...h(arguments)]),
u(arguments)
);
};
f.prototype.reset = function(t) {
return this._runTask(
An(xn(t), h(arguments)),
u(arguments)
);
};
f.prototype.revert = function(t) {
const e = u(arguments);
return typeof t != "string" ? this._runTask(b("Commit must be a string"), e) : this._runTask(
g(["revert", ...h(arguments, 0, !0), t]),
e
);
};
f.prototype.addTag = function(t) {
const e = typeof t == "string" ? js(t) : b("Git.addTag requires a tag name");
return this._runTask(e, u(arguments));
};
f.prototype.addAnnotatedTag = function(t, e) {
return this._runTask(
Bs(t, e),
u(arguments)
);
};
f.prototype.deleteLocalBranch = function(t, e, n) {
return this._runTask(
cs(t, typeof e == "boolean" ? e : !1),
u(arguments)
);
};
f.prototype.deleteLocalBranches = function(t, e, n) {
return this._runTask(
us(t, typeof e == "boolean" ? e : !1),
u(arguments)
);
};
f.prototype.branch = function(t, e) {
return this._runTask(
is(h(arguments)),
u(arguments)
);
};
f.prototype.branchLocal = function(t) {
return this._runTask(as(), u(arguments));
};
f.prototype.raw = function(t) {
const e = !Array.isArray(t), n = [].slice.call(e ? arguments : t, 0);
for (let s = 0; s < n.length && e; s++)
if (!st(n[s])) {
n.splice(s, n.length - s);
break;
}
n.push(...h(arguments, 0, !0));
var r = u(arguments);
return n.length ? this._runTask(g(n, this._trimmed), r) : this._runTask(
b("Raw: must supply one or more command to execute"),
r
);
};
f.prototype.submoduleAdd = function(t, e, n) {
return this._runTask(As(t, e), u(arguments));
};
f.prototype.submoduleUpdate = function(t, e) {
return this._runTask(
Ns(h(arguments, !0)),
u(arguments)
);
};
f.prototype.submoduleInit = function(t, e) {
return this._runTask(
xs(h(arguments, !0)),
u(arguments)
);
};
f.prototype.subModule = function(t, e) {
return this._runTask(
X(h(arguments)),
u(arguments)
);
};
f.prototype.listRemote = function() {
return this._runTask(
Ss(h(arguments)),
u(arguments)
);
};
f.prototype.addRemote = function(t, e, n) {
return this._runTask(
vs(t, e, h(arguments)),
u(arguments)
);
};
f.prototype.removeRemote = function(t, e) {
return this._runTask(Os(t), u(arguments));
};
f.prototype.getRemotes = function(t, e) {
return this._runTask(Es(t === !0), u(arguments));
};
f.prototype.remote = function(t, e) {
return this._runTask(
Rs(h(arguments)),
u(arguments)
);
};
f.prototype.tag = function(t, e) {
const n = h(arguments);
return n[0] !== "tag" && n.unshift("tag"), this._runTask(g(n), u(arguments));
};
f.prototype.updateServerInfo = function(t) {
return this._runTask(
g(["update-server-info"]),
u(arguments)
);
};
f.prototype.pushTags = function(t, e) {
const n = Mr(
{ remote: d(t, m) },
h(arguments)
);
return this._runTask(n, u(arguments));
};
f.prototype.rm = function(t) {
return this._runTask(
g(["rm", "-f", ...v(t)]),
u(arguments)
);
};
f.prototype.rmKeepLocal = function(t) {
return this._runTask(
g(["rm", "--cached", ...v(t)]),
u(arguments)
);
};
f.prototype.catFile = function(t, e) {
return this._catFile("utf-8", arguments);
};
f.prototype.binaryCatFile = function() {
return this._catFile("buffer", arguments);
};
f.prototype._catFile = function(t, e) {
var n = u(e), r = ["cat-file"], s = e[0];
if (typeof s == "string")
return this._runTask(
b("Git.catFile: options must be supplied as an array of strings"),
n
);
Array.isArray(s) && r.push.apply(r, s);
const o = t === "buffer" ? Gt(r) : g(r);
return this._runTask(o, n);
};
f.prototype.diff = function(t, e) {
const n = m(t) ? b(
"git.diff: supplying options as a single string is no longer supported, switch to an array of strings"
) : g(["diff", ...h(arguments)]);
return this._runTask(n, u(arguments));
};
f.prototype.diffSummary = function() {
return this._runTask(
fr(h(arguments, 1)),
u(arguments)
);
};
f.prototype.applyPatch = function(t) {
const e = G(t) ? Yr(v(t), h([].slice.call(arguments, 1))) : b(
"git.applyPatch requires one or more string patches as the first argument"
);
return this._runTask(e, u(arguments));
};
f.prototype.revparse = function() {
const t = ["rev-parse", ...h(arguments, !0)];
return this._runTask(
g(t, !0),
u(arguments)
);
};
f.prototype.clean = function(t, e, n) {
const r = un(t), s = r && t.join("") || d(t, m) || "", o = h([].slice.call(arguments, r ? 1 : 0));
return this._runTask(
on(s, o),
u(arguments)
);
};
f.prototype.exec = function(t) {
const e = {
commands: [],
format: "utf-8",
parser() {
typeof t == "function" && t();
}
};
return this._runTask(e);
};
f.prototype.checkIgnore = function(t, e) {
return this._runTask(
fs(v(d(t, G, []))),
u(arguments)
);
};
f.prototype.checkIsRepo = function(t, e) {
return this._runTask(
We(d(t, m)),
u(arguments)
);
};
function Is(t) {
return t ? [{
type: "spawn.before",
action(r, s) {
t.aborted && s.kill(new A(void 0, "abort", "Abort already signaled"));
}
}, {
type: "spawn.after",
action(r, s) {
function o() {
s.kill(new A(void 0, "abort", "Abort signal received"));
}
t.addEventListener("abort", o), s.spawned.on("close", () => t.removeEventListener("abort", o));
}
}] : void 0;
}
const Us = $("", "plugin:allowEnvironment");
function Fs(t, e = !1) {
const n = new Set(t.map((r) => r.toLowerCase().trim()));
return {
type: "spawn.options",
action(r, s) {
const o = { ...r.env ?? process.env }, i = new Set(
Object.keys(s.env).map((a) => a.toLowerCase().trim())
);
for (const a of Object.keys(o)) {
const c = a.toLowerCase().trim();
if (!(!Gs(c) || n.has(c))) {
if (i.has(c))
throw new A(
void 0,
"allowEnvironment",
`Use of "${a}" is blocked by the environment guard - add it to the allowEnvironment option to permit it`
);
Us("removing ambient guarded environment variable %s", a), delete o[a];
}
}
return {
...r,
env: {
...o,
GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS: String(!e)
}
};
}
};
}
function Gs(t) {
const e = t.toLowerCase().trim();
return e.startsWith("git_") || Re(e);
}
function zs(t = {}) {
return {
type: "spawn.args",
action(e, { env: n }) {
for (const r of Oe(e, n))
if (t[r.category] !== !0)
throw new A(void 0, "unsafe", r.message);
return e;
}
};
}
function qs(t) {
const e = U(t, "-c");
return {
type: "spawn.args",
action(n) {
return [...e, ...n];
}
};
}
const $t = P().promise;
function Ws({
onClose: t = !0,
onExit: e = 50
} = {}) {
function n() {
let s = -1;
const o = {
close: P(),
closeTimeout: P(),
exit: P(),
exitTimeout: P()
}, i = Promise.race([
t === !1 ? $t : o.closeTimeout.promise,
e === !1 ? $t : o.exitTimeout.promise
]);
return r(t, o.close, o.closeTimeout), r(e, o.exit, o.exitTimeout), {
close(a) {
s = a, o.close.done();
},
exit(a) {
s = a, o.exit.done();
},
get exitCode() {
return s;
},
result: i
};
}
function r(s, o, i) {
s !== !1 && (s === !0 ? o.promise : o.promise.then(() => wt(s))).then(i.done);
}
return {
type: "spawn.after",
async action(s, { spawned: o, close: i }) {
const a = n();
let c = !0, y = () => {
c = !1;
};
o.stdout?.on("data", y), o.stderr?.on("data", y), o.on("error", y), o.on("close", (w) => a.close(w)), o.on("exit", (w) => a.exit(w));
try {
await a.result, c && await wt(50), i(a.exitCode);
} catch (w) {
i(a.exitCode, w);
}
}
};
}
const we = $("", "plugin:binary"), Hs = "Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings", Ks = "Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option";
function Vs(t) {
return !t || !/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(t);
}
function Pt(t, e) {
if (t.length < 1 || t.length > 2)
throw new A(void 0, "binary", Hs);
if (t.some(Vs))
if (e)
we("permitted unsafe binary %o", t);
else
throw new A(void 0, "binary", Ks);
const [r, s] = t;
return {
binary: r,
prefix: s
};
}
function Xs(t, e = ["git"], n = !1) {
let r = Pt(v(e), n);
t.on("binary", (s) => {
r = Pt(v(s), n), we.info("reconfiguring %o", r);
}), t.append("spawn.binary", () => r.binary), t.append("spawn.args", (s) => r.prefix ? [r.prefix, ...s] : s);
}
const be = {
DISALLOWED_ABBREVIATED: {
text: "disallowed abbreviated or ambiguous option",
solution: "Unambiguous abbreviated options blocked with unsafe.allowAbbreviatedOptions setting: {message}"
},
UNKNOWN: {
text: "~ unknown ~",
solution: void 0
}
};
function Ys(t) {
if (!t)
return "UNKNOWN";
for (const [e, { text: n }] of Object.entries(be))
if (t.startsWith(`fatal: ${n}`))
return e;
return "UNKNOWN";
}
class Qs extends O {
constructor(e = "") {
const n = Ys(e);
super(void 0, be[n].solution?.replace("{message}", e) ?? e), this.reason = n;
}
}
function Js(t) {
return !!(t.exitCode && t.stdErr.length);
}
function Zs(t) {
return Buffer.concat([...t.stdOut, ...t.stdErr]);
}
function to(t = !1, e = Js, n = Zs) {
return (r, s) => !t && r || !e(s) ? r : n(s);
}
function eo(t, e) {
return t === 128 && e.startsWith("fatal:") ? new Qs(e) : new O(void 0, e);
}
function Mt(t) {
return {
type: "task.error",
action(e, n) {
const r = t(e.error, {
stdErr: n.stdErr,
stdOut: n.stdOut,
exitCode: n.exitCode
});
return Buffer.isBuffer(r) ? {
error: eo(n.exitCode, r.toString("utf-8"))
} : {
error: r
};
}
};
}
const nt = $("", "plugin:input");
function no(t) {
return {
type: "spawn.after",
action(e, { commands: n, input: r, spawned: { stdin: s } }) {
if (!s)
return;
const o = t?.([...n]) ?? r;
if (!o)
return nt("generated zero length content, not writing to stdin");
nt("writing %s bytes to stdin", Le(o)), s.on("error", (i) => {
i.code !== "EPIPE" && nt("[ERROR] stdin error %o", i);
}), s.end(o);
}
};
}
class ro {
constructor() {
this.plugins = /* @__PURE__ */ new Set(), this.events = new Ce();
}
on(e, n) {
this.events.on(e, n);
}
reconfigure(e, n) {
this.events.emit(e, n);
}
append(e, n) {
const r = S(this.plugins, { type: e, action: n });
return () => this.plugins.delete(r);
}
add(e) {
const n = [];
return v(e).forEach(
(r) => {
r && this.plugins.add(S(n, r));
}
), () => {
n.forEach((r) => {
this.plugins.delete(r);
});
};
}
exec(e, n, r) {
let s = n;
const o = Object.freeze(Object.create(r));
for (const i of this.plugins)
i.type === e && (s = i.action(s, o));
return s;
}
}
function so(t) {
const e = "--progress", n = ["checkout", "clone", "fetch", "pull", "push"];
return [{
type: "spawn.args",
action(o, i) {
return n.includes(i.method) ? De(o, e) : o;
}
}, {
type: "spawn.after",
action(o, i) {
i.commands.includes(e) && i.spawned.stderr?.on("data", (a) => {
const c = /^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(a.toString("utf8"));
c && t({
method: i.method,
stage: oo(c[1]),
progress: p(c[2]),
processed: p(c[3]),
total: p(c[4])
});
});
}
}];
}
function oo(t) {
return String(t.toLowerCase().split(" ", 1)) || "unknown";
}
function io(t) {
const e = je(t, ["uid", "gid"]);
return {
type: "spawn.options",
action(n) {
return { ...e, ...n };
}
};
}
function ao() {
return {
type: "spawn.args",
action(t) {
const e = [];
let n;
function r(s) {
(n = n || []).push(...s);
}
for (let s = 0; s < t.length; s++) {
const o = t[s];
if (D(o)) {
r(yt(o));
continue;
}
if (o === "--") {
r(
t.slice(s + 1).flatMap((i) => D(i) && yt(i) || i)
);
break;
}
e.push(o);
}
return n ? [...e, "--", ...n.map(String)] : e;
}
};
}
function uo({
block: t,
stdErr: e = !0,
stdOut: n = !0
}) {
if (t > 0)
return {
type: "spawn.after",
action(r, s) {
let o;
function i() {
o && clearTimeout(o), o = setTimeout(c, t);
}
function a() {
s.spawned.stdout?.off("data", i), s.spawned.stderr?.off("data", i), s.spawned.off("exit", a), s.spawned.off("close", a), o && clearTimeout(o);
}
function c() {
a(), s.kill(new A(void 0, "timeout", "block timeout reached"));
}
n && s.spawned.stdout?.on("data", i), e && s.spawned.stderr?.on("data", i), s.spawned.on("exit", a), s.spawned.on("close", a), i();
}
};
}
const wo = (t, e) => {
const n = new ro(), r = Ge(
t && (typeof t == "string" ? { baseDir: t } : t) || {},
e
);
if (!Lt(r.baseDir))
throw new Ae(
r,
"Cannot use simple-git on a directory that does not exist"
);
return Array.isArray(r.config) && n.add(qs(r.config)), n.add(zs(r.unsafe)), n.add(Ws(r.completion)), r.abort && n.add(Is(r.abort)), r.progress && n.add(so(r.progress)), r.timeout && n.add(uo(r.timeout)), r.spawnOptions && n.add(io(r.spawnOptions)), n.add(ao()), n.add(no(r.input)), n.add(Mt(to(!0))), r.errors && n.add(Mt(r.errors)), Xs(n, r.binary, r.unsafe?.allowUnsafeCustomBinary), n.add(
Fs(r.allowEnvironment ?? [], r.unsafe?.allowAbbreviatedOptions)
), new f(r, n);
};
export {
qe as CheckRepoActions,
zt as CleanOptions,
Kt as DiffNameStatus,
Ht as GitConfigScope,
Ae as GitConstructError,
O as GitError,
A as GitPluginError,
at as GitResponseError,
Vt as ResetMode,
xe as TaskConfigurationError,
Sn as grepQueryBuilder,
ko as pathspec,
wo as simpleGit
};
//# sourceMappingURL=index.mjs.map