github.com/jfrog/frogbot@v1.1.1-0.20231221090046-821a26f50338/action/node_modules/simple-git/dist/esm/index.js (about)

     1  var __defProp = Object.defineProperty;
     2  var __defProps = Object.defineProperties;
     3  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
     4  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
     5  var __getOwnPropNames = Object.getOwnPropertyNames;
     6  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
     7  var __hasOwnProp = Object.prototype.hasOwnProperty;
     8  var __propIsEnum = Object.prototype.propertyIsEnumerable;
     9  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
    10  var __spreadValues = (a, b) => {
    11    for (var prop in b || (b = {}))
    12      if (__hasOwnProp.call(b, prop))
    13        __defNormalProp(a, prop, b[prop]);
    14    if (__getOwnPropSymbols)
    15      for (var prop of __getOwnPropSymbols(b)) {
    16        if (__propIsEnum.call(b, prop))
    17          __defNormalProp(a, prop, b[prop]);
    18      }
    19    return a;
    20  };
    21  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
    22  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
    23  var __esm = (fn, res) => function __init() {
    24    return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
    25  };
    26  var __commonJS = (cb, mod) => function __require() {
    27    return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
    28  };
    29  var __export = (target, all) => {
    30    for (var name in all)
    31      __defProp(target, name, { get: all[name], enumerable: true });
    32  };
    33  var __reExport = (target, module, copyDefault, desc) => {
    34    if (module && typeof module === "object" || typeof module === "function") {
    35      for (let key of __getOwnPropNames(module))
    36        if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
    37          __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
    38    }
    39    return target;
    40  };
    41  var __toCommonJS = /* @__PURE__ */ ((cache2) => {
    42    return (module, temp) => {
    43      return cache2 && cache2.get(module) || (temp = __reExport(__markAsModule({}), module, 1), cache2 && cache2.set(module, temp), temp);
    44    };
    45  })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
    46  var __async = (__this, __arguments, generator) => {
    47    return new Promise((resolve, reject) => {
    48      var fulfilled = (value) => {
    49        try {
    50          step(generator.next(value));
    51        } catch (e) {
    52          reject(e);
    53        }
    54      };
    55      var rejected = (value) => {
    56        try {
    57          step(generator.throw(value));
    58        } catch (e) {
    59          reject(e);
    60        }
    61      };
    62      var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    63      step((generator = generator.apply(__this, __arguments)).next());
    64    });
    65  };
    66  
    67  // src/lib/args/pathspec.ts
    68  function pathspec(...paths) {
    69    const key = new String(paths);
    70    cache.set(key, paths);
    71    return key;
    72  }
    73  function isPathSpec(path) {
    74    return path instanceof String && cache.has(path);
    75  }
    76  function toPaths(pathSpec) {
    77    return cache.get(pathSpec) || [];
    78  }
    79  var cache;
    80  var init_pathspec = __esm({
    81    "src/lib/args/pathspec.ts"() {
    82      cache = /* @__PURE__ */ new WeakMap();
    83    }
    84  });
    85  
    86  // src/lib/errors/git-error.ts
    87  var GitError;
    88  var init_git_error = __esm({
    89    "src/lib/errors/git-error.ts"() {
    90      GitError = class extends Error {
    91        constructor(task, message) {
    92          super(message);
    93          this.task = task;
    94          Object.setPrototypeOf(this, new.target.prototype);
    95        }
    96      };
    97    }
    98  });
    99  
   100  // src/lib/errors/git-response-error.ts
   101  var GitResponseError;
   102  var init_git_response_error = __esm({
   103    "src/lib/errors/git-response-error.ts"() {
   104      init_git_error();
   105      GitResponseError = class extends GitError {
   106        constructor(git, message) {
   107          super(void 0, message || String(git));
   108          this.git = git;
   109        }
   110      };
   111    }
   112  });
   113  
   114  // src/lib/errors/task-configuration-error.ts
   115  var TaskConfigurationError;
   116  var init_task_configuration_error = __esm({
   117    "src/lib/errors/task-configuration-error.ts"() {
   118      init_git_error();
   119      TaskConfigurationError = class extends GitError {
   120        constructor(message) {
   121          super(void 0, message);
   122        }
   123      };
   124    }
   125  });
   126  
   127  // src/lib/utils/util.ts
   128  import { exists, FOLDER } from "@kwsites/file-exists";
   129  function asFunction(source) {
   130    return typeof source === "function" ? source : NOOP;
   131  }
   132  function isUserFunction(source) {
   133    return typeof source === "function" && source !== NOOP;
   134  }
   135  function splitOn(input, char) {
   136    const index = input.indexOf(char);
   137    if (index <= 0) {
   138      return [input, ""];
   139    }
   140    return [input.substr(0, index), input.substr(index + 1)];
   141  }
   142  function first(input, offset = 0) {
   143    return isArrayLike(input) && input.length > offset ? input[offset] : void 0;
   144  }
   145  function last(input, offset = 0) {
   146    if (isArrayLike(input) && input.length > offset) {
   147      return input[input.length - 1 - offset];
   148    }
   149  }
   150  function isArrayLike(input) {
   151    return !!(input && typeof input.length === "number");
   152  }
   153  function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
   154    return input.split(separator).reduce((output, line) => {
   155      const lineContent = trimmed2 ? line.trim() : line;
   156      if (lineContent) {
   157        output.push(lineContent);
   158      }
   159      return output;
   160    }, []);
   161  }
   162  function forEachLineWithContent(input, callback) {
   163    return toLinesWithContent(input, true).map((line) => callback(line));
   164  }
   165  function folderExists(path) {
   166    return exists(path, FOLDER);
   167  }
   168  function append(target, item) {
   169    if (Array.isArray(target)) {
   170      if (!target.includes(item)) {
   171        target.push(item);
   172      }
   173    } else {
   174      target.add(item);
   175    }
   176    return item;
   177  }
   178  function including(target, item) {
   179    if (Array.isArray(target) && !target.includes(item)) {
   180      target.push(item);
   181    }
   182    return target;
   183  }
   184  function remove(target, item) {
   185    if (Array.isArray(target)) {
   186      const index = target.indexOf(item);
   187      if (index >= 0) {
   188        target.splice(index, 1);
   189      }
   190    } else {
   191      target.delete(item);
   192    }
   193    return item;
   194  }
   195  function asArray(source) {
   196    return Array.isArray(source) ? source : [source];
   197  }
   198  function asStringArray(source) {
   199    return asArray(source).map(String);
   200  }
   201  function asNumber(source, onNaN = 0) {
   202    if (source == null) {
   203      return onNaN;
   204    }
   205    const num = parseInt(source, 10);
   206    return isNaN(num) ? onNaN : num;
   207  }
   208  function prefixedArray(input, prefix) {
   209    const output = [];
   210    for (let i = 0, max = input.length; i < max; i++) {
   211      output.push(prefix, input[i]);
   212    }
   213    return output;
   214  }
   215  function bufferToString(input) {
   216    return (Array.isArray(input) ? Buffer.concat(input) : input).toString("utf-8");
   217  }
   218  function pick(source, properties) {
   219    return Object.assign({}, ...properties.map((property) => property in source ? { [property]: source[property] } : {}));
   220  }
   221  function delay(duration = 0) {
   222    return new Promise((done) => setTimeout(done, duration));
   223  }
   224  var NULL, NOOP, objectToString;
   225  var init_util = __esm({
   226    "src/lib/utils/util.ts"() {
   227      NULL = "\0";
   228      NOOP = () => {
   229      };
   230      objectToString = Object.prototype.toString.call.bind(Object.prototype.toString);
   231    }
   232  });
   233  
   234  // src/lib/utils/argument-filters.ts
   235  function filterType(input, filter, def) {
   236    if (filter(input)) {
   237      return input;
   238    }
   239    return arguments.length > 2 ? def : void 0;
   240  }
   241  function filterPrimitives(input, omit) {
   242    const type = isPathSpec(input) ? "string" : typeof input;
   243    return /number|string|boolean/.test(type) && (!omit || !omit.includes(type));
   244  }
   245  function filterPlainObject(input) {
   246    return !!input && objectToString(input) === "[object Object]";
   247  }
   248  function filterFunction(input) {
   249    return typeof input === "function";
   250  }
   251  var filterArray, filterString, filterStringArray, filterStringOrStringArray, filterHasLength;
   252  var init_argument_filters = __esm({
   253    "src/lib/utils/argument-filters.ts"() {
   254      init_util();
   255      init_pathspec();
   256      filterArray = (input) => {
   257        return Array.isArray(input);
   258      };
   259      filterString = (input) => {
   260        return typeof input === "string";
   261      };
   262      filterStringArray = (input) => {
   263        return Array.isArray(input) && input.every(filterString);
   264      };
   265      filterStringOrStringArray = (input) => {
   266        return filterString(input) || Array.isArray(input) && input.every(filterString);
   267      };
   268      filterHasLength = (input) => {
   269        if (input == null || "number|boolean|function".includes(typeof input)) {
   270          return false;
   271        }
   272        return Array.isArray(input) || typeof input === "string" || typeof input.length === "number";
   273      };
   274    }
   275  });
   276  
   277  // src/lib/utils/exit-codes.ts
   278  var ExitCodes;
   279  var init_exit_codes = __esm({
   280    "src/lib/utils/exit-codes.ts"() {
   281      ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
   282        ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
   283        ExitCodes2[ExitCodes2["ERROR"] = 1] = "ERROR";
   284        ExitCodes2[ExitCodes2["NOT_FOUND"] = -2] = "NOT_FOUND";
   285        ExitCodes2[ExitCodes2["UNCLEAN"] = 128] = "UNCLEAN";
   286        return ExitCodes2;
   287      })(ExitCodes || {});
   288    }
   289  });
   290  
   291  // src/lib/utils/git-output-streams.ts
   292  var GitOutputStreams;
   293  var init_git_output_streams = __esm({
   294    "src/lib/utils/git-output-streams.ts"() {
   295      GitOutputStreams = class {
   296        constructor(stdOut, stdErr) {
   297          this.stdOut = stdOut;
   298          this.stdErr = stdErr;
   299        }
   300        asStrings() {
   301          return new GitOutputStreams(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
   302        }
   303      };
   304    }
   305  });
   306  
   307  // src/lib/utils/line-parser.ts
   308  var LineParser, RemoteLineParser;
   309  var init_line_parser = __esm({
   310    "src/lib/utils/line-parser.ts"() {
   311      LineParser = class {
   312        constructor(regExp, useMatches) {
   313          this.matches = [];
   314          this.parse = (line, target) => {
   315            this.resetMatches();
   316            if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) {
   317              return false;
   318            }
   319            return this.useMatches(target, this.prepareMatches()) !== false;
   320          };
   321          this._regExp = Array.isArray(regExp) ? regExp : [regExp];
   322          if (useMatches) {
   323            this.useMatches = useMatches;
   324          }
   325        }
   326        useMatches(target, match) {
   327          throw new Error(`LineParser:useMatches not implemented`);
   328        }
   329        resetMatches() {
   330          this.matches.length = 0;
   331        }
   332        prepareMatches() {
   333          return this.matches;
   334        }
   335        addMatch(reg, index, line) {
   336          const matched = line && reg.exec(line);
   337          if (matched) {
   338            this.pushMatch(index, matched);
   339          }
   340          return !!matched;
   341        }
   342        pushMatch(_index, matched) {
   343          this.matches.push(...matched.slice(1));
   344        }
   345      };
   346      RemoteLineParser = class extends LineParser {
   347        addMatch(reg, index, line) {
   348          return /^remote:\s/.test(String(line)) && super.addMatch(reg, index, line);
   349        }
   350        pushMatch(index, matched) {
   351          if (index > 0 || matched.length > 1) {
   352            super.pushMatch(index, matched);
   353          }
   354        }
   355      };
   356    }
   357  });
   358  
   359  // src/lib/utils/simple-git-options.ts
   360  function createInstanceConfig(...options) {
   361    const baseDir = process.cwd();
   362    const config = Object.assign(__spreadValues({ baseDir }, defaultOptions), ...options.filter((o) => typeof o === "object" && o));
   363    config.baseDir = config.baseDir || baseDir;
   364    config.trimmed = config.trimmed === true;
   365    return config;
   366  }
   367  var defaultOptions;
   368  var init_simple_git_options = __esm({
   369    "src/lib/utils/simple-git-options.ts"() {
   370      defaultOptions = {
   371        binary: "git",
   372        maxConcurrentProcesses: 5,
   373        config: [],
   374        trimmed: false
   375      };
   376    }
   377  });
   378  
   379  // src/lib/utils/task-options.ts
   380  function appendTaskOptions(options, commands = []) {
   381    if (!filterPlainObject(options)) {
   382      return commands;
   383    }
   384    return Object.keys(options).reduce((commands2, key) => {
   385      const value = options[key];
   386      if (isPathSpec(value)) {
   387        commands2.push(value);
   388      } else if (filterPrimitives(value, ["boolean"])) {
   389        commands2.push(key + "=" + value);
   390      } else {
   391        commands2.push(key);
   392      }
   393      return commands2;
   394    }, commands);
   395  }
   396  function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
   397    const command = [];
   398    for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive; i < max; i++) {
   399      if ("string|number".includes(typeof args[i])) {
   400        command.push(String(args[i]));
   401      }
   402    }
   403    appendTaskOptions(trailingOptionsArgument(args), command);
   404    if (!objectOnly) {
   405      command.push(...trailingArrayArgument(args));
   406    }
   407    return command;
   408  }
   409  function trailingArrayArgument(args) {
   410    const hasTrailingCallback = typeof last(args) === "function";
   411    return filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []);
   412  }
   413  function trailingOptionsArgument(args) {
   414    const hasTrailingCallback = filterFunction(last(args));
   415    return filterType(last(args, hasTrailingCallback ? 1 : 0), filterPlainObject);
   416  }
   417  function trailingFunctionArgument(args, includeNoop = true) {
   418    const callback = asFunction(last(args));
   419    return includeNoop || isUserFunction(callback) ? callback : void 0;
   420  }
   421  var init_task_options = __esm({
   422    "src/lib/utils/task-options.ts"() {
   423      init_argument_filters();
   424      init_util();
   425      init_pathspec();
   426    }
   427  });
   428  
   429  // src/lib/utils/task-parser.ts
   430  function callTaskParser(parser3, streams) {
   431    return parser3(streams.stdOut, streams.stdErr);
   432  }
   433  function parseStringResponse(result, parsers12, texts, trim = true) {
   434    asArray(texts).forEach((text) => {
   435      for (let lines = toLinesWithContent(text, trim), i = 0, max = lines.length; i < max; i++) {
   436        const line = (offset = 0) => {
   437          if (i + offset >= max) {
   438            return;
   439          }
   440          return lines[i + offset];
   441        };
   442        parsers12.some(({ parse }) => parse(line, result));
   443      }
   444    });
   445    return result;
   446  }
   447  var init_task_parser = __esm({
   448    "src/lib/utils/task-parser.ts"() {
   449      init_util();
   450    }
   451  });
   452  
   453  // src/lib/utils/index.ts
   454  var utils_exports = {};
   455  __export(utils_exports, {
   456    ExitCodes: () => ExitCodes,
   457    GitOutputStreams: () => GitOutputStreams,
   458    LineParser: () => LineParser,
   459    NOOP: () => NOOP,
   460    NULL: () => NULL,
   461    RemoteLineParser: () => RemoteLineParser,
   462    append: () => append,
   463    appendTaskOptions: () => appendTaskOptions,
   464    asArray: () => asArray,
   465    asFunction: () => asFunction,
   466    asNumber: () => asNumber,
   467    asStringArray: () => asStringArray,
   468    bufferToString: () => bufferToString,
   469    callTaskParser: () => callTaskParser,
   470    createInstanceConfig: () => createInstanceConfig,
   471    delay: () => delay,
   472    filterArray: () => filterArray,
   473    filterFunction: () => filterFunction,
   474    filterHasLength: () => filterHasLength,
   475    filterPlainObject: () => filterPlainObject,
   476    filterPrimitives: () => filterPrimitives,
   477    filterString: () => filterString,
   478    filterStringArray: () => filterStringArray,
   479    filterStringOrStringArray: () => filterStringOrStringArray,
   480    filterType: () => filterType,
   481    first: () => first,
   482    folderExists: () => folderExists,
   483    forEachLineWithContent: () => forEachLineWithContent,
   484    getTrailingOptions: () => getTrailingOptions,
   485    including: () => including,
   486    isUserFunction: () => isUserFunction,
   487    last: () => last,
   488    objectToString: () => objectToString,
   489    parseStringResponse: () => parseStringResponse,
   490    pick: () => pick,
   491    prefixedArray: () => prefixedArray,
   492    remove: () => remove,
   493    splitOn: () => splitOn,
   494    toLinesWithContent: () => toLinesWithContent,
   495    trailingFunctionArgument: () => trailingFunctionArgument,
   496    trailingOptionsArgument: () => trailingOptionsArgument
   497  });
   498  var init_utils = __esm({
   499    "src/lib/utils/index.ts"() {
   500      init_argument_filters();
   501      init_exit_codes();
   502      init_git_output_streams();
   503      init_line_parser();
   504      init_simple_git_options();
   505      init_task_options();
   506      init_task_parser();
   507      init_util();
   508    }
   509  });
   510  
   511  // src/lib/tasks/check-is-repo.ts
   512  var check_is_repo_exports = {};
   513  __export(check_is_repo_exports, {
   514    CheckRepoActions: () => CheckRepoActions,
   515    checkIsBareRepoTask: () => checkIsBareRepoTask,
   516    checkIsRepoRootTask: () => checkIsRepoRootTask,
   517    checkIsRepoTask: () => checkIsRepoTask
   518  });
   519  function checkIsRepoTask(action) {
   520    switch (action) {
   521      case "bare" /* BARE */:
   522        return checkIsBareRepoTask();
   523      case "root" /* IS_REPO_ROOT */:
   524        return checkIsRepoRootTask();
   525    }
   526    const commands = ["rev-parse", "--is-inside-work-tree"];
   527    return {
   528      commands,
   529      format: "utf-8",
   530      onError,
   531      parser
   532    };
   533  }
   534  function checkIsRepoRootTask() {
   535    const commands = ["rev-parse", "--git-dir"];
   536    return {
   537      commands,
   538      format: "utf-8",
   539      onError,
   540      parser(path) {
   541        return /^\.(git)?$/.test(path.trim());
   542      }
   543    };
   544  }
   545  function checkIsBareRepoTask() {
   546    const commands = ["rev-parse", "--is-bare-repository"];
   547    return {
   548      commands,
   549      format: "utf-8",
   550      onError,
   551      parser
   552    };
   553  }
   554  function isNotRepoMessage(error) {
   555    return /(Not a git repository|Kein Git-Repository)/i.test(String(error));
   556  }
   557  var CheckRepoActions, onError, parser;
   558  var init_check_is_repo = __esm({
   559    "src/lib/tasks/check-is-repo.ts"() {
   560      init_utils();
   561      CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
   562        CheckRepoActions2["BARE"] = "bare";
   563        CheckRepoActions2["IN_TREE"] = "tree";
   564        CheckRepoActions2["IS_REPO_ROOT"] = "root";
   565        return CheckRepoActions2;
   566      })(CheckRepoActions || {});
   567      onError = ({ exitCode }, error, done, fail) => {
   568        if (exitCode === 128 /* UNCLEAN */ && isNotRepoMessage(error)) {
   569          return done(Buffer.from("false"));
   570        }
   571        fail(error);
   572      };
   573      parser = (text) => {
   574        return text.trim() === "true";
   575      };
   576    }
   577  });
   578  
   579  // src/lib/responses/CleanSummary.ts
   580  function cleanSummaryParser(dryRun, text) {
   581    const summary = new CleanResponse(dryRun);
   582    const regexp = dryRun ? dryRunRemovalRegexp : removalRegexp;
   583    toLinesWithContent(text).forEach((line) => {
   584      const removed = line.replace(regexp, "");
   585      summary.paths.push(removed);
   586      (isFolderRegexp.test(removed) ? summary.folders : summary.files).push(removed);
   587    });
   588    return summary;
   589  }
   590  var CleanResponse, removalRegexp, dryRunRemovalRegexp, isFolderRegexp;
   591  var init_CleanSummary = __esm({
   592    "src/lib/responses/CleanSummary.ts"() {
   593      init_utils();
   594      CleanResponse = class {
   595        constructor(dryRun) {
   596          this.dryRun = dryRun;
   597          this.paths = [];
   598          this.files = [];
   599          this.folders = [];
   600        }
   601      };
   602      removalRegexp = /^[a-z]+\s*/i;
   603      dryRunRemovalRegexp = /^[a-z]+\s+[a-z]+\s*/i;
   604      isFolderRegexp = /\/$/;
   605    }
   606  });
   607  
   608  // src/lib/tasks/task.ts
   609  var task_exports = {};
   610  __export(task_exports, {
   611    EMPTY_COMMANDS: () => EMPTY_COMMANDS,
   612    adhocExecTask: () => adhocExecTask,
   613    configurationErrorTask: () => configurationErrorTask,
   614    isBufferTask: () => isBufferTask,
   615    isEmptyTask: () => isEmptyTask,
   616    straightThroughBufferTask: () => straightThroughBufferTask,
   617    straightThroughStringTask: () => straightThroughStringTask
   618  });
   619  function adhocExecTask(parser3) {
   620    return {
   621      commands: EMPTY_COMMANDS,
   622      format: "empty",
   623      parser: parser3
   624    };
   625  }
   626  function configurationErrorTask(error) {
   627    return {
   628      commands: EMPTY_COMMANDS,
   629      format: "empty",
   630      parser() {
   631        throw typeof error === "string" ? new TaskConfigurationError(error) : error;
   632      }
   633    };
   634  }
   635  function straightThroughStringTask(commands, trimmed2 = false) {
   636    return {
   637      commands,
   638      format: "utf-8",
   639      parser(text) {
   640        return trimmed2 ? String(text).trim() : text;
   641      }
   642    };
   643  }
   644  function straightThroughBufferTask(commands) {
   645    return {
   646      commands,
   647      format: "buffer",
   648      parser(buffer) {
   649        return buffer;
   650      }
   651    };
   652  }
   653  function isBufferTask(task) {
   654    return task.format === "buffer";
   655  }
   656  function isEmptyTask(task) {
   657    return task.format === "empty" || !task.commands.length;
   658  }
   659  var EMPTY_COMMANDS;
   660  var init_task = __esm({
   661    "src/lib/tasks/task.ts"() {
   662      init_task_configuration_error();
   663      EMPTY_COMMANDS = [];
   664    }
   665  });
   666  
   667  // src/lib/tasks/clean.ts
   668  var clean_exports = {};
   669  __export(clean_exports, {
   670    CONFIG_ERROR_INTERACTIVE_MODE: () => CONFIG_ERROR_INTERACTIVE_MODE,
   671    CONFIG_ERROR_MODE_REQUIRED: () => CONFIG_ERROR_MODE_REQUIRED,
   672    CONFIG_ERROR_UNKNOWN_OPTION: () => CONFIG_ERROR_UNKNOWN_OPTION,
   673    CleanOptions: () => CleanOptions,
   674    cleanTask: () => cleanTask,
   675    cleanWithOptionsTask: () => cleanWithOptionsTask,
   676    isCleanOptionsArray: () => isCleanOptionsArray
   677  });
   678  function cleanWithOptionsTask(mode, customArgs) {
   679    const { cleanMode, options, valid } = getCleanOptions(mode);
   680    if (!cleanMode) {
   681      return configurationErrorTask(CONFIG_ERROR_MODE_REQUIRED);
   682    }
   683    if (!valid.options) {
   684      return configurationErrorTask(CONFIG_ERROR_UNKNOWN_OPTION + JSON.stringify(mode));
   685    }
   686    options.push(...customArgs);
   687    if (options.some(isInteractiveMode)) {
   688      return configurationErrorTask(CONFIG_ERROR_INTERACTIVE_MODE);
   689    }
   690    return cleanTask(cleanMode, options);
   691  }
   692  function cleanTask(mode, customArgs) {
   693    const commands = ["clean", `-${mode}`, ...customArgs];
   694    return {
   695      commands,
   696      format: "utf-8",
   697      parser(text) {
   698        return cleanSummaryParser(mode === "n" /* DRY_RUN */, text);
   699      }
   700    };
   701  }
   702  function isCleanOptionsArray(input) {
   703    return Array.isArray(input) && input.every((test) => CleanOptionValues.has(test));
   704  }
   705  function getCleanOptions(input) {
   706    let cleanMode;
   707    let options = [];
   708    let valid = { cleanMode: false, options: true };
   709    input.replace(/[^a-z]i/g, "").split("").forEach((char) => {
   710      if (isCleanMode(char)) {
   711        cleanMode = char;
   712        valid.cleanMode = true;
   713      } else {
   714        valid.options = valid.options && isKnownOption(options[options.length] = `-${char}`);
   715      }
   716    });
   717    return {
   718      cleanMode,
   719      options,
   720      valid
   721    };
   722  }
   723  function isCleanMode(cleanMode) {
   724    return cleanMode === "f" /* FORCE */ || cleanMode === "n" /* DRY_RUN */;
   725  }
   726  function isKnownOption(option) {
   727    return /^-[a-z]$/i.test(option) && CleanOptionValues.has(option.charAt(1));
   728  }
   729  function isInteractiveMode(option) {
   730    if (/^-[^\-]/.test(option)) {
   731      return option.indexOf("i") > 0;
   732    }
   733    return option === "--interactive";
   734  }
   735  var CONFIG_ERROR_INTERACTIVE_MODE, CONFIG_ERROR_MODE_REQUIRED, CONFIG_ERROR_UNKNOWN_OPTION, CleanOptions, CleanOptionValues;
   736  var init_clean = __esm({
   737    "src/lib/tasks/clean.ts"() {
   738      init_CleanSummary();
   739      init_utils();
   740      init_task();
   741      CONFIG_ERROR_INTERACTIVE_MODE = "Git clean interactive mode is not supported";
   742      CONFIG_ERROR_MODE_REQUIRED = 'Git clean mode parameter ("n" or "f") is required';
   743      CONFIG_ERROR_UNKNOWN_OPTION = "Git clean unknown option found in: ";
   744      CleanOptions = /* @__PURE__ */ ((CleanOptions2) => {
   745        CleanOptions2["DRY_RUN"] = "n";
   746        CleanOptions2["FORCE"] = "f";
   747        CleanOptions2["IGNORED_INCLUDED"] = "x";
   748        CleanOptions2["IGNORED_ONLY"] = "X";
   749        CleanOptions2["EXCLUDING"] = "e";
   750        CleanOptions2["QUIET"] = "q";
   751        CleanOptions2["RECURSIVE"] = "d";
   752        return CleanOptions2;
   753      })(CleanOptions || {});
   754      CleanOptionValues = /* @__PURE__ */ new Set([
   755        "i",
   756        ...asStringArray(Object.values(CleanOptions))
   757      ]);
   758    }
   759  });
   760  
   761  // src/lib/responses/ConfigList.ts
   762  function configListParser(text) {
   763    const config = new ConfigList();
   764    for (const item of configParser(text)) {
   765      config.addValue(item.file, String(item.key), item.value);
   766    }
   767    return config;
   768  }
   769  function configGetParser(text, key) {
   770    let value = null;
   771    const values = [];
   772    const scopes = /* @__PURE__ */ new Map();
   773    for (const item of configParser(text, key)) {
   774      if (item.key !== key) {
   775        continue;
   776      }
   777      values.push(value = item.value);
   778      if (!scopes.has(item.file)) {
   779        scopes.set(item.file, []);
   780      }
   781      scopes.get(item.file).push(value);
   782    }
   783    return {
   784      key,
   785      paths: Array.from(scopes.keys()),
   786      scopes,
   787      value,
   788      values
   789    };
   790  }
   791  function configFilePath(filePath) {
   792    return filePath.replace(/^(file):/, "");
   793  }
   794  function* configParser(text, requestedKey = null) {
   795    const lines = text.split("\0");
   796    for (let i = 0, max = lines.length - 1; i < max; ) {
   797      const file = configFilePath(lines[i++]);
   798      let value = lines[i++];
   799      let key = requestedKey;
   800      if (value.includes("\n")) {
   801        const line = splitOn(value, "\n");
   802        key = line[0];
   803        value = line[1];
   804      }
   805      yield { file, key, value };
   806    }
   807  }
   808  var ConfigList;
   809  var init_ConfigList = __esm({
   810    "src/lib/responses/ConfigList.ts"() {
   811      init_utils();
   812      ConfigList = class {
   813        constructor() {
   814          this.files = [];
   815          this.values = /* @__PURE__ */ Object.create(null);
   816        }
   817        get all() {
   818          if (!this._all) {
   819            this._all = this.files.reduce((all, file) => {
   820              return Object.assign(all, this.values[file]);
   821            }, {});
   822          }
   823          return this._all;
   824        }
   825        addFile(file) {
   826          if (!(file in this.values)) {
   827            const latest = last(this.files);
   828            this.values[file] = latest ? Object.create(this.values[latest]) : {};
   829            this.files.push(file);
   830          }
   831          return this.values[file];
   832        }
   833        addValue(file, key, value) {
   834          const values = this.addFile(file);
   835          if (!values.hasOwnProperty(key)) {
   836            values[key] = value;
   837          } else if (Array.isArray(values[key])) {
   838            values[key].push(value);
   839          } else {
   840            values[key] = [values[key], value];
   841          }
   842          this._all = void 0;
   843        }
   844      };
   845    }
   846  });
   847  
   848  // src/lib/tasks/config.ts
   849  function asConfigScope(scope, fallback) {
   850    if (typeof scope === "string" && GitConfigScope.hasOwnProperty(scope)) {
   851      return scope;
   852    }
   853    return fallback;
   854  }
   855  function addConfigTask(key, value, append2, scope) {
   856    const commands = ["config", `--${scope}`];
   857    if (append2) {
   858      commands.push("--add");
   859    }
   860    commands.push(key, value);
   861    return {
   862      commands,
   863      format: "utf-8",
   864      parser(text) {
   865        return text;
   866      }
   867    };
   868  }
   869  function getConfigTask(key, scope) {
   870    const commands = ["config", "--null", "--show-origin", "--get-all", key];
   871    if (scope) {
   872      commands.splice(1, 0, `--${scope}`);
   873    }
   874    return {
   875      commands,
   876      format: "utf-8",
   877      parser(text) {
   878        return configGetParser(text, key);
   879      }
   880    };
   881  }
   882  function listConfigTask(scope) {
   883    const commands = ["config", "--list", "--show-origin", "--null"];
   884    if (scope) {
   885      commands.push(`--${scope}`);
   886    }
   887    return {
   888      commands,
   889      format: "utf-8",
   890      parser(text) {
   891        return configListParser(text);
   892      }
   893    };
   894  }
   895  function config_default() {
   896    return {
   897      addConfig(key, value, ...rest) {
   898        return this._runTask(addConfigTask(key, value, rest[0] === true, asConfigScope(rest[1], "local" /* local */)), trailingFunctionArgument(arguments));
   899      },
   900      getConfig(key, scope) {
   901        return this._runTask(getConfigTask(key, asConfigScope(scope, void 0)), trailingFunctionArgument(arguments));
   902      },
   903      listConfig(...rest) {
   904        return this._runTask(listConfigTask(asConfigScope(rest[0], void 0)), trailingFunctionArgument(arguments));
   905      }
   906    };
   907  }
   908  var GitConfigScope;
   909  var init_config = __esm({
   910    "src/lib/tasks/config.ts"() {
   911      init_ConfigList();
   912      init_utils();
   913      GitConfigScope = /* @__PURE__ */ ((GitConfigScope2) => {
   914        GitConfigScope2["system"] = "system";
   915        GitConfigScope2["global"] = "global";
   916        GitConfigScope2["local"] = "local";
   917        GitConfigScope2["worktree"] = "worktree";
   918        return GitConfigScope2;
   919      })(GitConfigScope || {});
   920    }
   921  });
   922  
   923  // src/lib/tasks/grep.ts
   924  function grepQueryBuilder(...params) {
   925    return new GrepQuery().param(...params);
   926  }
   927  function parseGrep(grep) {
   928    const paths = /* @__PURE__ */ new Set();
   929    const results = {};
   930    forEachLineWithContent(grep, (input) => {
   931      const [path, line, preview] = input.split(NULL);
   932      paths.add(path);
   933      (results[path] = results[path] || []).push({
   934        line: asNumber(line),
   935        path,
   936        preview
   937      });
   938    });
   939    return {
   940      paths,
   941      results
   942    };
   943  }
   944  function grep_default() {
   945    return {
   946      grep(searchTerm) {
   947        const then = trailingFunctionArgument(arguments);
   948        const options = getTrailingOptions(arguments);
   949        for (const option of disallowedOptions) {
   950          if (options.includes(option)) {
   951            return this._runTask(configurationErrorTask(`git.grep: use of "${option}" is not supported.`), then);
   952          }
   953        }
   954        if (typeof searchTerm === "string") {
   955          searchTerm = grepQueryBuilder().param(searchTerm);
   956        }
   957        const commands = ["grep", "--null", "-n", "--full-name", ...options, ...searchTerm];
   958        return this._runTask({
   959          commands,
   960          format: "utf-8",
   961          parser(stdOut) {
   962            return parseGrep(stdOut);
   963          }
   964        }, then);
   965      }
   966    };
   967  }
   968  var disallowedOptions, Query, _a, GrepQuery;
   969  var init_grep = __esm({
   970    "src/lib/tasks/grep.ts"() {
   971      init_utils();
   972      init_task();
   973      disallowedOptions = ["-h"];
   974      Query = Symbol("grepQuery");
   975      GrepQuery = class {
   976        constructor() {
   977          this[_a] = [];
   978        }
   979        *[(_a = Query, Symbol.iterator)]() {
   980          for (const query of this[Query]) {
   981            yield query;
   982          }
   983        }
   984        and(...and) {
   985          and.length && this[Query].push("--and", "(", ...prefixedArray(and, "-e"), ")");
   986          return this;
   987        }
   988        param(...param) {
   989          this[Query].push(...prefixedArray(param, "-e"));
   990          return this;
   991        }
   992      };
   993    }
   994  });
   995  
   996  // src/lib/tasks/reset.ts
   997  var reset_exports = {};
   998  __export(reset_exports, {
   999    ResetMode: () => ResetMode,
  1000    getResetMode: () => getResetMode,
  1001    resetTask: () => resetTask
  1002  });
  1003  function resetTask(mode, customArgs) {
  1004    const commands = ["reset"];
  1005    if (isValidResetMode(mode)) {
  1006      commands.push(`--${mode}`);
  1007    }
  1008    commands.push(...customArgs);
  1009    return straightThroughStringTask(commands);
  1010  }
  1011  function getResetMode(mode) {
  1012    if (isValidResetMode(mode)) {
  1013      return mode;
  1014    }
  1015    switch (typeof mode) {
  1016      case "string":
  1017      case "undefined":
  1018        return "soft" /* SOFT */;
  1019    }
  1020    return;
  1021  }
  1022  function isValidResetMode(mode) {
  1023    return ResetModes.includes(mode);
  1024  }
  1025  var ResetMode, ResetModes;
  1026  var init_reset = __esm({
  1027    "src/lib/tasks/reset.ts"() {
  1028      init_task();
  1029      ResetMode = /* @__PURE__ */ ((ResetMode2) => {
  1030        ResetMode2["MIXED"] = "mixed";
  1031        ResetMode2["SOFT"] = "soft";
  1032        ResetMode2["HARD"] = "hard";
  1033        ResetMode2["MERGE"] = "merge";
  1034        ResetMode2["KEEP"] = "keep";
  1035        return ResetMode2;
  1036      })(ResetMode || {});
  1037      ResetModes = Array.from(Object.values(ResetMode));
  1038    }
  1039  });
  1040  
  1041  // src/lib/git-logger.ts
  1042  import debug from "debug";
  1043  function createLog() {
  1044    return debug("simple-git");
  1045  }
  1046  function prefixedLogger(to, prefix, forward) {
  1047    if (!prefix || !String(prefix).replace(/\s*/, "")) {
  1048      return !forward ? to : (message, ...args) => {
  1049        to(message, ...args);
  1050        forward(message, ...args);
  1051      };
  1052    }
  1053    return (message, ...args) => {
  1054      to(`%s ${message}`, prefix, ...args);
  1055      if (forward) {
  1056        forward(message, ...args);
  1057      }
  1058    };
  1059  }
  1060  function childLoggerName(name, childDebugger, { namespace: parentNamespace }) {
  1061    if (typeof name === "string") {
  1062      return name;
  1063    }
  1064    const childNamespace = childDebugger && childDebugger.namespace || "";
  1065    if (childNamespace.startsWith(parentNamespace)) {
  1066      return childNamespace.substr(parentNamespace.length + 1);
  1067    }
  1068    return childNamespace || parentNamespace;
  1069  }
  1070  function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
  1071    const labelPrefix = label && `[${label}]` || "";
  1072    const spawned = [];
  1073    const debugDebugger = typeof verbose === "string" ? infoDebugger.extend(verbose) : verbose;
  1074    const key = childLoggerName(filterType(verbose, filterString), debugDebugger, infoDebugger);
  1075    return step(initialStep);
  1076    function sibling(name, initial) {
  1077      return append(spawned, createLogger(label, key.replace(/^[^:]+/, name), initial, infoDebugger));
  1078    }
  1079    function step(phase) {
  1080      const stepPrefix = phase && `[${phase}]` || "";
  1081      const debug2 = debugDebugger && prefixedLogger(debugDebugger, stepPrefix) || NOOP;
  1082      const info = prefixedLogger(infoDebugger, `${labelPrefix} ${stepPrefix}`, debug2);
  1083      return Object.assign(debugDebugger ? debug2 : info, {
  1084        label,
  1085        sibling,
  1086        info,
  1087        step
  1088      });
  1089    }
  1090  }
  1091  var init_git_logger = __esm({
  1092    "src/lib/git-logger.ts"() {
  1093      init_utils();
  1094      debug.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
  1095      debug.formatters.B = (value) => {
  1096        if (Buffer.isBuffer(value)) {
  1097          return value.toString("utf8");
  1098        }
  1099        return objectToString(value);
  1100      };
  1101    }
  1102  });
  1103  
  1104  // src/lib/runners/tasks-pending-queue.ts
  1105  var _TasksPendingQueue, TasksPendingQueue;
  1106  var init_tasks_pending_queue = __esm({
  1107    "src/lib/runners/tasks-pending-queue.ts"() {
  1108      init_git_error();
  1109      init_git_logger();
  1110      _TasksPendingQueue = class {
  1111        constructor(logLabel = "GitExecutor") {
  1112          this.logLabel = logLabel;
  1113          this._queue = /* @__PURE__ */ new Map();
  1114        }
  1115        withProgress(task) {
  1116          return this._queue.get(task);
  1117        }
  1118        createProgress(task) {
  1119          const name = _TasksPendingQueue.getName(task.commands[0]);
  1120          const logger = createLogger(this.logLabel, name);
  1121          return {
  1122            task,
  1123            logger,
  1124            name
  1125          };
  1126        }
  1127        push(task) {
  1128          const progress = this.createProgress(task);
  1129          progress.logger("Adding task to the queue, commands = %o", task.commands);
  1130          this._queue.set(task, progress);
  1131          return progress;
  1132        }
  1133        fatal(err) {
  1134          for (const [task, { logger }] of Array.from(this._queue.entries())) {
  1135            if (task === err.task) {
  1136              logger.info(`Failed %o`, err);
  1137              logger(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`);
  1138            } else {
  1139              logger.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`, err.message);
  1140            }
  1141            this.complete(task);
  1142          }
  1143          if (this._queue.size !== 0) {
  1144            throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`);
  1145          }
  1146        }
  1147        complete(task) {
  1148          const progress = this.withProgress(task);
  1149          if (progress) {
  1150            this._queue.delete(task);
  1151          }
  1152        }
  1153        attempt(task) {
  1154          const progress = this.withProgress(task);
  1155          if (!progress) {
  1156            throw new GitError(void 0, "TasksPendingQueue: attempt called for an unknown task");
  1157          }
  1158          progress.logger("Starting task");
  1159          return progress;
  1160        }
  1161        static getName(name = "empty") {
  1162          return `task:${name}:${++_TasksPendingQueue.counter}`;
  1163        }
  1164      };
  1165      TasksPendingQueue = _TasksPendingQueue;
  1166      TasksPendingQueue.counter = 0;
  1167    }
  1168  });
  1169  
  1170  // src/lib/runners/git-executor-chain.ts
  1171  import { spawn } from "child_process";
  1172  function pluginContext(task, commands) {
  1173    return {
  1174      method: first(task.commands) || "",
  1175      commands
  1176    };
  1177  }
  1178  function onErrorReceived(target, logger) {
  1179    return (err) => {
  1180      logger(`[ERROR] child process exception %o`, err);
  1181      target.push(Buffer.from(String(err.stack), "ascii"));
  1182    };
  1183  }
  1184  function onDataReceived(target, name, logger, output) {
  1185    return (buffer) => {
  1186      logger(`%s received %L bytes`, name, buffer);
  1187      output(`%B`, buffer);
  1188      target.push(buffer);
  1189    };
  1190  }
  1191  var GitExecutorChain;
  1192  var init_git_executor_chain = __esm({
  1193    "src/lib/runners/git-executor-chain.ts"() {
  1194      init_git_error();
  1195      init_task();
  1196      init_utils();
  1197      init_tasks_pending_queue();
  1198      GitExecutorChain = class {
  1199        constructor(_executor, _scheduler, _plugins) {
  1200          this._executor = _executor;
  1201          this._scheduler = _scheduler;
  1202          this._plugins = _plugins;
  1203          this._chain = Promise.resolve();
  1204          this._queue = new TasksPendingQueue();
  1205        }
  1206        get binary() {
  1207          return this._executor.binary;
  1208        }
  1209        get cwd() {
  1210          return this._cwd || this._executor.cwd;
  1211        }
  1212        set cwd(cwd) {
  1213          this._cwd = cwd;
  1214        }
  1215        get env() {
  1216          return this._executor.env;
  1217        }
  1218        get outputHandler() {
  1219          return this._executor.outputHandler;
  1220        }
  1221        chain() {
  1222          return this;
  1223        }
  1224        push(task) {
  1225          this._queue.push(task);
  1226          return this._chain = this._chain.then(() => this.attemptTask(task));
  1227        }
  1228        attemptTask(task) {
  1229          return __async(this, null, function* () {
  1230            const onScheduleComplete = yield this._scheduler.next();
  1231            const onQueueComplete = () => this._queue.complete(task);
  1232            try {
  1233              const { logger } = this._queue.attempt(task);
  1234              return yield isEmptyTask(task) ? this.attemptEmptyTask(task, logger) : this.attemptRemoteTask(task, logger);
  1235            } catch (e) {
  1236              throw this.onFatalException(task, e);
  1237            } finally {
  1238              onQueueComplete();
  1239              onScheduleComplete();
  1240            }
  1241          });
  1242        }
  1243        onFatalException(task, e) {
  1244          const gitError = e instanceof GitError ? Object.assign(e, { task }) : new GitError(task, e && String(e));
  1245          this._chain = Promise.resolve();
  1246          this._queue.fatal(gitError);
  1247          return gitError;
  1248        }
  1249        attemptRemoteTask(task, logger) {
  1250          return __async(this, null, function* () {
  1251            const args = this._plugins.exec("spawn.args", [...task.commands], pluginContext(task, task.commands));
  1252            const raw = yield this.gitResponse(task, this.binary, args, this.outputHandler, logger.step("SPAWN"));
  1253            const outputStreams = yield this.handleTaskData(task, args, raw, logger.step("HANDLE"));
  1254            logger(`passing response to task's parser as a %s`, task.format);
  1255            if (isBufferTask(task)) {
  1256              return callTaskParser(task.parser, outputStreams);
  1257            }
  1258            return callTaskParser(task.parser, outputStreams.asStrings());
  1259          });
  1260        }
  1261        attemptEmptyTask(task, logger) {
  1262          return __async(this, null, function* () {
  1263            logger(`empty task bypassing child process to call to task's parser`);
  1264            return task.parser(this);
  1265          });
  1266        }
  1267        handleTaskData(task, args, result, logger) {
  1268          const { exitCode, rejection, stdOut, stdErr } = result;
  1269          return new Promise((done, fail) => {
  1270            logger(`Preparing to handle process response exitCode=%d stdOut=`, exitCode);
  1271            const { error } = this._plugins.exec("task.error", { error: rejection }, __spreadValues(__spreadValues({}, pluginContext(task, args)), result));
  1272            if (error && task.onError) {
  1273              logger.info(`exitCode=%s handling with custom error handler`);
  1274              return task.onError(result, error, (newStdOut) => {
  1275                logger.info(`custom error handler treated as success`);
  1276                logger(`custom error returned a %s`, objectToString(newStdOut));
  1277                done(new GitOutputStreams(Array.isArray(newStdOut) ? Buffer.concat(newStdOut) : newStdOut, Buffer.concat(stdErr)));
  1278              }, fail);
  1279            }
  1280            if (error) {
  1281              logger.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`, exitCode, stdErr.length, rejection);
  1282              return fail(error);
  1283            }
  1284            logger.info(`retrieving task output complete`);
  1285            done(new GitOutputStreams(Buffer.concat(stdOut), Buffer.concat(stdErr)));
  1286          });
  1287        }
  1288        gitResponse(task, command, args, outputHandler, logger) {
  1289          return __async(this, null, function* () {
  1290            const outputLogger = logger.sibling("output");
  1291            const spawnOptions = this._plugins.exec("spawn.options", {
  1292              cwd: this.cwd,
  1293              env: this.env,
  1294              windowsHide: true
  1295            }, pluginContext(task, task.commands));
  1296            return new Promise((done) => {
  1297              const stdOut = [];
  1298              const stdErr = [];
  1299              logger.info(`%s %o`, command, args);
  1300              logger("%O", spawnOptions);
  1301              let rejection = this._beforeSpawn(task, args);
  1302              if (rejection) {
  1303                return done({
  1304                  stdOut,
  1305                  stdErr,
  1306                  exitCode: 9901,
  1307                  rejection
  1308                });
  1309              }
  1310              this._plugins.exec("spawn.before", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
  1311                kill(reason) {
  1312                  rejection = reason || rejection;
  1313                }
  1314              }));
  1315              const spawned = spawn(command, args, spawnOptions);
  1316              spawned.stdout.on("data", onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut")));
  1317              spawned.stderr.on("data", onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr")));
  1318              spawned.on("error", onErrorReceived(stdErr, logger));
  1319              if (outputHandler) {
  1320                logger(`Passing child process stdOut/stdErr to custom outputHandler`);
  1321                outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
  1322              }
  1323              this._plugins.exec("spawn.after", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
  1324                spawned,
  1325                close(exitCode, reason) {
  1326                  done({
  1327                    stdOut,
  1328                    stdErr,
  1329                    exitCode,
  1330                    rejection: rejection || reason
  1331                  });
  1332                },
  1333                kill(reason) {
  1334                  if (spawned.killed) {
  1335                    return;
  1336                  }
  1337                  rejection = reason;
  1338                  spawned.kill("SIGINT");
  1339                }
  1340              }));
  1341            });
  1342          });
  1343        }
  1344        _beforeSpawn(task, args) {
  1345          let rejection;
  1346          this._plugins.exec("spawn.before", void 0, __spreadProps(__spreadValues({}, pluginContext(task, args)), {
  1347            kill(reason) {
  1348              rejection = reason || rejection;
  1349            }
  1350          }));
  1351          return rejection;
  1352        }
  1353      };
  1354    }
  1355  });
  1356  
  1357  // src/lib/runners/git-executor.ts
  1358  var git_executor_exports = {};
  1359  __export(git_executor_exports, {
  1360    GitExecutor: () => GitExecutor
  1361  });
  1362  var GitExecutor;
  1363  var init_git_executor = __esm({
  1364    "src/lib/runners/git-executor.ts"() {
  1365      init_git_executor_chain();
  1366      GitExecutor = class {
  1367        constructor(binary = "git", cwd, _scheduler, _plugins) {
  1368          this.binary = binary;
  1369          this.cwd = cwd;
  1370          this._scheduler = _scheduler;
  1371          this._plugins = _plugins;
  1372          this._chain = new GitExecutorChain(this, this._scheduler, this._plugins);
  1373        }
  1374        chain() {
  1375          return new GitExecutorChain(this, this._scheduler, this._plugins);
  1376        }
  1377        push(task) {
  1378          return this._chain.push(task);
  1379        }
  1380      };
  1381    }
  1382  });
  1383  
  1384  // src/lib/task-callback.ts
  1385  function taskCallback(task, response, callback = NOOP) {
  1386    const onSuccess = (data) => {
  1387      callback(null, data);
  1388    };
  1389    const onError2 = (err) => {
  1390      if ((err == null ? void 0 : err.task) === task) {
  1391        callback(err instanceof GitResponseError ? addDeprecationNoticeToError(err) : err, void 0);
  1392      }
  1393    };
  1394    response.then(onSuccess, onError2);
  1395  }
  1396  function addDeprecationNoticeToError(err) {
  1397    let log = (name) => {
  1398      console.warn(`simple-git deprecation notice: accessing GitResponseError.${name} should be GitResponseError.git.${name}, this will no longer be available in version 3`);
  1399      log = NOOP;
  1400    };
  1401    return Object.create(err, Object.getOwnPropertyNames(err.git).reduce(descriptorReducer, {}));
  1402    function descriptorReducer(all, name) {
  1403      if (name in err) {
  1404        return all;
  1405      }
  1406      all[name] = {
  1407        enumerable: false,
  1408        configurable: false,
  1409        get() {
  1410          log(name);
  1411          return err.git[name];
  1412        }
  1413      };
  1414      return all;
  1415    }
  1416  }
  1417  var init_task_callback = __esm({
  1418    "src/lib/task-callback.ts"() {
  1419      init_git_response_error();
  1420      init_utils();
  1421    }
  1422  });
  1423  
  1424  // src/lib/tasks/change-working-directory.ts
  1425  function changeWorkingDirectoryTask(directory, root) {
  1426    return adhocExecTask((instance) => {
  1427      if (!folderExists(directory)) {
  1428        throw new Error(`Git.cwd: cannot change to non-directory "${directory}"`);
  1429      }
  1430      return (root || instance).cwd = directory;
  1431    });
  1432  }
  1433  var init_change_working_directory = __esm({
  1434    "src/lib/tasks/change-working-directory.ts"() {
  1435      init_utils();
  1436      init_task();
  1437    }
  1438  });
  1439  
  1440  // src/lib/tasks/checkout.ts
  1441  function checkoutTask(args) {
  1442    const commands = ["checkout", ...args];
  1443    if (commands[1] === "-b" && commands.includes("-B")) {
  1444      commands[1] = remove(commands, "-B");
  1445    }
  1446    return straightThroughStringTask(commands);
  1447  }
  1448  function checkout_default() {
  1449    return {
  1450      checkout() {
  1451        return this._runTask(checkoutTask(getTrailingOptions(arguments, 1)), trailingFunctionArgument(arguments));
  1452      },
  1453      checkoutBranch(branchName, startPoint) {
  1454        return this._runTask(checkoutTask(["-b", branchName, startPoint, ...getTrailingOptions(arguments)]), trailingFunctionArgument(arguments));
  1455      },
  1456      checkoutLocalBranch(branchName) {
  1457        return this._runTask(checkoutTask(["-b", branchName, ...getTrailingOptions(arguments)]), trailingFunctionArgument(arguments));
  1458      }
  1459    };
  1460  }
  1461  var init_checkout = __esm({
  1462    "src/lib/tasks/checkout.ts"() {
  1463      init_utils();
  1464      init_task();
  1465    }
  1466  });
  1467  
  1468  // src/lib/parsers/parse-commit.ts
  1469  function parseCommitResult(stdOut) {
  1470    const result = {
  1471      author: null,
  1472      branch: "",
  1473      commit: "",
  1474      root: false,
  1475      summary: {
  1476        changes: 0,
  1477        insertions: 0,
  1478        deletions: 0
  1479      }
  1480    };
  1481    return parseStringResponse(result, parsers, stdOut);
  1482  }
  1483  var parsers;
  1484  var init_parse_commit = __esm({
  1485    "src/lib/parsers/parse-commit.ts"() {
  1486      init_utils();
  1487      parsers = [
  1488        new LineParser(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/, (result, [branch, root, commit]) => {
  1489          result.branch = branch;
  1490          result.commit = commit;
  1491          result.root = !!root;
  1492        }),
  1493        new LineParser(/\s*Author:\s(.+)/i, (result, [author]) => {
  1494          const parts = author.split("<");
  1495          const email = parts.pop();
  1496          if (!email || !email.includes("@")) {
  1497            return;
  1498          }
  1499          result.author = {
  1500            email: email.substr(0, email.length - 1),
  1501            name: parts.join("<").trim()
  1502          };
  1503        }),
  1504        new LineParser(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g, (result, [changes, insertions, deletions]) => {
  1505          result.summary.changes = parseInt(changes, 10) || 0;
  1506          result.summary.insertions = parseInt(insertions, 10) || 0;
  1507          result.summary.deletions = parseInt(deletions, 10) || 0;
  1508        }),
  1509        new LineParser(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/, (result, [changes, lines, direction]) => {
  1510          result.summary.changes = parseInt(changes, 10) || 0;
  1511          const count = parseInt(lines, 10) || 0;
  1512          if (direction === "-") {
  1513            result.summary.deletions = count;
  1514          } else if (direction === "+") {
  1515            result.summary.insertions = count;
  1516          }
  1517        })
  1518      ];
  1519    }
  1520  });
  1521  
  1522  // src/lib/tasks/commit.ts
  1523  function commitTask(message, files, customArgs) {
  1524    const commands = [
  1525      "-c",
  1526      "core.abbrev=40",
  1527      "commit",
  1528      ...prefixedArray(message, "-m"),
  1529      ...files,
  1530      ...customArgs
  1531    ];
  1532    return {
  1533      commands,
  1534      format: "utf-8",
  1535      parser: parseCommitResult
  1536    };
  1537  }
  1538  function commit_default() {
  1539    return {
  1540      commit(message, ...rest) {
  1541        const next = trailingFunctionArgument(arguments);
  1542        const task = rejectDeprecatedSignatures(message) || commitTask(asArray(message), asArray(filterType(rest[0], filterStringOrStringArray, [])), [...filterType(rest[1], filterArray, []), ...getTrailingOptions(arguments, 0, true)]);
  1543        return this._runTask(task, next);
  1544      }
  1545    };
  1546    function rejectDeprecatedSignatures(message) {
  1547      return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
  1548    }
  1549  }
  1550  var init_commit = __esm({
  1551    "src/lib/tasks/commit.ts"() {
  1552      init_parse_commit();
  1553      init_utils();
  1554      init_task();
  1555    }
  1556  });
  1557  
  1558  // src/lib/tasks/hash-object.ts
  1559  function hashObjectTask(filePath, write) {
  1560    const commands = ["hash-object", filePath];
  1561    if (write) {
  1562      commands.push("-w");
  1563    }
  1564    return straightThroughStringTask(commands, true);
  1565  }
  1566  var init_hash_object = __esm({
  1567    "src/lib/tasks/hash-object.ts"() {
  1568      init_task();
  1569    }
  1570  });
  1571  
  1572  // src/lib/responses/InitSummary.ts
  1573  function parseInit(bare, path, text) {
  1574    const response = String(text).trim();
  1575    let result;
  1576    if (result = initResponseRegex.exec(response)) {
  1577      return new InitSummary(bare, path, false, result[1]);
  1578    }
  1579    if (result = reInitResponseRegex.exec(response)) {
  1580      return new InitSummary(bare, path, true, result[1]);
  1581    }
  1582    let gitDir = "";
  1583    const tokens = response.split(" ");
  1584    while (tokens.length) {
  1585      const token = tokens.shift();
  1586      if (token === "in") {
  1587        gitDir = tokens.join(" ");
  1588        break;
  1589      }
  1590    }
  1591    return new InitSummary(bare, path, /^re/i.test(response), gitDir);
  1592  }
  1593  var InitSummary, initResponseRegex, reInitResponseRegex;
  1594  var init_InitSummary = __esm({
  1595    "src/lib/responses/InitSummary.ts"() {
  1596      InitSummary = class {
  1597        constructor(bare, path, existing, gitDir) {
  1598          this.bare = bare;
  1599          this.path = path;
  1600          this.existing = existing;
  1601          this.gitDir = gitDir;
  1602        }
  1603      };
  1604      initResponseRegex = /^Init.+ repository in (.+)$/;
  1605      reInitResponseRegex = /^Rein.+ in (.+)$/;
  1606    }
  1607  });
  1608  
  1609  // src/lib/tasks/init.ts
  1610  function hasBareCommand(command) {
  1611    return command.includes(bareCommand);
  1612  }
  1613  function initTask(bare = false, path, customArgs) {
  1614    const commands = ["init", ...customArgs];
  1615    if (bare && !hasBareCommand(commands)) {
  1616      commands.splice(1, 0, bareCommand);
  1617    }
  1618    return {
  1619      commands,
  1620      format: "utf-8",
  1621      parser(text) {
  1622        return parseInit(commands.includes("--bare"), path, text);
  1623      }
  1624    };
  1625  }
  1626  var bareCommand;
  1627  var init_init = __esm({
  1628    "src/lib/tasks/init.ts"() {
  1629      init_InitSummary();
  1630      bareCommand = "--bare";
  1631    }
  1632  });
  1633  
  1634  // src/lib/args/log-format.ts
  1635  function logFormatFromCommand(customArgs) {
  1636    for (let i = 0; i < customArgs.length; i++) {
  1637      const format = logFormatRegex.exec(customArgs[i]);
  1638      if (format) {
  1639        return `--${format[1]}`;
  1640      }
  1641    }
  1642    return "" /* NONE */;
  1643  }
  1644  function isLogFormat(customArg) {
  1645    return logFormatRegex.test(customArg);
  1646  }
  1647  var logFormatRegex;
  1648  var init_log_format = __esm({
  1649    "src/lib/args/log-format.ts"() {
  1650      logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
  1651    }
  1652  });
  1653  
  1654  // src/lib/responses/DiffSummary.ts
  1655  var DiffSummary;
  1656  var init_DiffSummary = __esm({
  1657    "src/lib/responses/DiffSummary.ts"() {
  1658      DiffSummary = class {
  1659        constructor() {
  1660          this.changed = 0;
  1661          this.deletions = 0;
  1662          this.insertions = 0;
  1663          this.files = [];
  1664        }
  1665      };
  1666    }
  1667  });
  1668  
  1669  // src/lib/parsers/parse-diff-summary.ts
  1670  function getDiffParser(format = "" /* NONE */) {
  1671    const parser3 = diffSummaryParsers[format];
  1672    return (stdOut) => parseStringResponse(new DiffSummary(), parser3, stdOut, false);
  1673  }
  1674  var statParser, numStatParser, nameOnlyParser, nameStatusParser, diffSummaryParsers;
  1675  var init_parse_diff_summary = __esm({
  1676    "src/lib/parsers/parse-diff-summary.ts"() {
  1677      init_log_format();
  1678      init_DiffSummary();
  1679      init_utils();
  1680      statParser = [
  1681        new LineParser(/(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/, (result, [file, changes, alterations = ""]) => {
  1682          result.files.push({
  1683            file: file.trim(),
  1684            changes: asNumber(changes),
  1685            insertions: alterations.replace(/[^+]/g, "").length,
  1686            deletions: alterations.replace(/[^-]/g, "").length,
  1687            binary: false
  1688          });
  1689        }),
  1690        new LineParser(/(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/, (result, [file, before, after]) => {
  1691          result.files.push({
  1692            file: file.trim(),
  1693            before: asNumber(before),
  1694            after: asNumber(after),
  1695            binary: true
  1696          });
  1697        }),
  1698        new LineParser(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/, (result, [changed, summary]) => {
  1699          const inserted = /(\d+) i/.exec(summary);
  1700          const deleted = /(\d+) d/.exec(summary);
  1701          result.changed = asNumber(changed);
  1702          result.insertions = asNumber(inserted == null ? void 0 : inserted[1]);
  1703          result.deletions = asNumber(deleted == null ? void 0 : deleted[1]);
  1704        })
  1705      ];
  1706      numStatParser = [
  1707        new LineParser(/(\d+)\t(\d+)\t(.+)$/, (result, [changesInsert, changesDelete, file]) => {
  1708          const insertions = asNumber(changesInsert);
  1709          const deletions = asNumber(changesDelete);
  1710          result.changed++;
  1711          result.insertions += insertions;
  1712          result.deletions += deletions;
  1713          result.files.push({
  1714            file,
  1715            changes: insertions + deletions,
  1716            insertions,
  1717            deletions,
  1718            binary: false
  1719          });
  1720        }),
  1721        new LineParser(/-\t-\t(.+)$/, (result, [file]) => {
  1722          result.changed++;
  1723          result.files.push({
  1724            file,
  1725            after: 0,
  1726            before: 0,
  1727            binary: true
  1728          });
  1729        })
  1730      ];
  1731      nameOnlyParser = [
  1732        new LineParser(/(.+)$/, (result, [file]) => {
  1733          result.changed++;
  1734          result.files.push({
  1735            file,
  1736            changes: 0,
  1737            insertions: 0,
  1738            deletions: 0,
  1739            binary: false
  1740          });
  1741        })
  1742      ];
  1743      nameStatusParser = [
  1744        new LineParser(/([ACDMRTUXB])\s*(.+)$/, (result, [_status, file]) => {
  1745          result.changed++;
  1746          result.files.push({
  1747            file,
  1748            changes: 0,
  1749            insertions: 0,
  1750            deletions: 0,
  1751            binary: false
  1752          });
  1753        })
  1754      ];
  1755      diffSummaryParsers = {
  1756        ["" /* NONE */]: statParser,
  1757        ["--stat" /* STAT */]: statParser,
  1758        ["--numstat" /* NUM_STAT */]: numStatParser,
  1759        ["--name-status" /* NAME_STATUS */]: nameStatusParser,
  1760        ["--name-only" /* NAME_ONLY */]: nameOnlyParser
  1761      };
  1762    }
  1763  });
  1764  
  1765  // src/lib/parsers/parse-list-log-summary.ts
  1766  function lineBuilder(tokens, fields) {
  1767    return fields.reduce((line, field, index) => {
  1768      line[field] = tokens[index] || "";
  1769      return line;
  1770    }, /* @__PURE__ */ Object.create({ diff: null }));
  1771  }
  1772  function createListLogSummaryParser(splitter = SPLITTER, fields = defaultFieldNames, logFormat = "" /* NONE */) {
  1773    const parseDiffResult = getDiffParser(logFormat);
  1774    return function(stdOut) {
  1775      const all = toLinesWithContent(stdOut, true, START_BOUNDARY).map(function(item) {
  1776        const lineDetail = item.trim().split(COMMIT_BOUNDARY);
  1777        const listLogLine = lineBuilder(lineDetail[0].trim().split(splitter), fields);
  1778        if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
  1779          listLogLine.diff = parseDiffResult(lineDetail[1]);
  1780        }
  1781        return listLogLine;
  1782      });
  1783      return {
  1784        all,
  1785        latest: all.length && all[0] || null,
  1786        total: all.length
  1787      };
  1788    };
  1789  }
  1790  var START_BOUNDARY, COMMIT_BOUNDARY, SPLITTER, defaultFieldNames;
  1791  var init_parse_list_log_summary = __esm({
  1792    "src/lib/parsers/parse-list-log-summary.ts"() {
  1793      init_utils();
  1794      init_parse_diff_summary();
  1795      init_log_format();
  1796      START_BOUNDARY = "\xF2\xF2\xF2\xF2\xF2\xF2 ";
  1797      COMMIT_BOUNDARY = " \xF2\xF2";
  1798      SPLITTER = " \xF2 ";
  1799      defaultFieldNames = ["hash", "date", "message", "refs", "author_name", "author_email"];
  1800    }
  1801  });
  1802  
  1803  // src/lib/tasks/diff.ts
  1804  var diff_exports = {};
  1805  __export(diff_exports, {
  1806    diffSummaryTask: () => diffSummaryTask,
  1807    validateLogFormatConfig: () => validateLogFormatConfig
  1808  });
  1809  function diffSummaryTask(customArgs) {
  1810    let logFormat = logFormatFromCommand(customArgs);
  1811    const commands = ["diff"];
  1812    if (logFormat === "" /* NONE */) {
  1813      logFormat = "--stat" /* STAT */;
  1814      commands.push("--stat=4096");
  1815    }
  1816    commands.push(...customArgs);
  1817    return validateLogFormatConfig(commands) || {
  1818      commands,
  1819      format: "utf-8",
  1820      parser: getDiffParser(logFormat)
  1821    };
  1822  }
  1823  function validateLogFormatConfig(customArgs) {
  1824    const flags = customArgs.filter(isLogFormat);
  1825    if (flags.length > 1) {
  1826      return configurationErrorTask(`Summary flags are mutually exclusive - pick one of ${flags.join(",")}`);
  1827    }
  1828    if (flags.length && customArgs.includes("-z")) {
  1829      return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
  1830    }
  1831  }
  1832  var init_diff = __esm({
  1833    "src/lib/tasks/diff.ts"() {
  1834      init_log_format();
  1835      init_parse_diff_summary();
  1836      init_task();
  1837    }
  1838  });
  1839  
  1840  // src/lib/tasks/log.ts
  1841  function prettyFormat(format, splitter) {
  1842    const fields = [];
  1843    const formatStr = [];
  1844    Object.keys(format).forEach((field) => {
  1845      fields.push(field);
  1846      formatStr.push(String(format[field]));
  1847    });
  1848    return [fields, formatStr.join(splitter)];
  1849  }
  1850  function userOptions(input) {
  1851    return Object.keys(input).reduce((out, key) => {
  1852      if (!(key in excludeOptions)) {
  1853        out[key] = input[key];
  1854      }
  1855      return out;
  1856    }, {});
  1857  }
  1858  function parseLogOptions(opt = {}, customArgs = []) {
  1859    const splitter = filterType(opt.splitter, filterString, SPLITTER);
  1860    const format = !filterPrimitives(opt.format) && opt.format ? opt.format : {
  1861      hash: "%H",
  1862      date: opt.strictDate === false ? "%ai" : "%aI",
  1863      message: "%s",
  1864      refs: "%D",
  1865      body: opt.multiLine ? "%B" : "%b",
  1866      author_name: opt.mailMap !== false ? "%aN" : "%an",
  1867      author_email: opt.mailMap !== false ? "%aE" : "%ae"
  1868    };
  1869    const [fields, formatStr] = prettyFormat(format, splitter);
  1870    const suffix = [];
  1871    const command = [
  1872      `--pretty=format:${START_BOUNDARY}${formatStr}${COMMIT_BOUNDARY}`,
  1873      ...customArgs
  1874    ];
  1875    const maxCount = opt.n || opt["max-count"] || opt.maxCount;
  1876    if (maxCount) {
  1877      command.push(`--max-count=${maxCount}`);
  1878    }
  1879    if (opt.from || opt.to) {
  1880      const rangeOperator = opt.symmetric !== false ? "..." : "..";
  1881      suffix.push(`${opt.from || ""}${rangeOperator}${opt.to || ""}`);
  1882    }
  1883    if (filterString(opt.file)) {
  1884      suffix.push("--follow", opt.file);
  1885    }
  1886    appendTaskOptions(userOptions(opt), command);
  1887    return {
  1888      fields,
  1889      splitter,
  1890      commands: [...command, ...suffix]
  1891    };
  1892  }
  1893  function logTask(splitter, fields, customArgs) {
  1894    const parser3 = createListLogSummaryParser(splitter, fields, logFormatFromCommand(customArgs));
  1895    return {
  1896      commands: ["log", ...customArgs],
  1897      format: "utf-8",
  1898      parser: parser3
  1899    };
  1900  }
  1901  function log_default() {
  1902    return {
  1903      log(...rest) {
  1904        const next = trailingFunctionArgument(arguments);
  1905        const options = parseLogOptions(trailingOptionsArgument(arguments), filterType(arguments[0], filterArray));
  1906        const task = rejectDeprecatedSignatures(...rest) || validateLogFormatConfig(options.commands) || createLogTask(options);
  1907        return this._runTask(task, next);
  1908      }
  1909    };
  1910    function createLogTask(options) {
  1911      return logTask(options.splitter, options.fields, options.commands);
  1912    }
  1913    function rejectDeprecatedSignatures(from, to) {
  1914      return filterString(from) && filterString(to) && configurationErrorTask(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`);
  1915    }
  1916  }
  1917  var excludeOptions;
  1918  var init_log = __esm({
  1919    "src/lib/tasks/log.ts"() {
  1920      init_log_format();
  1921      init_parse_list_log_summary();
  1922      init_utils();
  1923      init_task();
  1924      init_diff();
  1925      excludeOptions = /* @__PURE__ */ ((excludeOptions2) => {
  1926        excludeOptions2[excludeOptions2["--pretty"] = 0] = "--pretty";
  1927        excludeOptions2[excludeOptions2["max-count"] = 1] = "max-count";
  1928        excludeOptions2[excludeOptions2["maxCount"] = 2] = "maxCount";
  1929        excludeOptions2[excludeOptions2["n"] = 3] = "n";
  1930        excludeOptions2[excludeOptions2["file"] = 4] = "file";
  1931        excludeOptions2[excludeOptions2["format"] = 5] = "format";
  1932        excludeOptions2[excludeOptions2["from"] = 6] = "from";
  1933        excludeOptions2[excludeOptions2["to"] = 7] = "to";
  1934        excludeOptions2[excludeOptions2["splitter"] = 8] = "splitter";
  1935        excludeOptions2[excludeOptions2["symmetric"] = 9] = "symmetric";
  1936        excludeOptions2[excludeOptions2["mailMap"] = 10] = "mailMap";
  1937        excludeOptions2[excludeOptions2["multiLine"] = 11] = "multiLine";
  1938        excludeOptions2[excludeOptions2["strictDate"] = 12] = "strictDate";
  1939        return excludeOptions2;
  1940      })(excludeOptions || {});
  1941    }
  1942  });
  1943  
  1944  // src/lib/responses/MergeSummary.ts
  1945  var MergeSummaryConflict, MergeSummaryDetail;
  1946  var init_MergeSummary = __esm({
  1947    "src/lib/responses/MergeSummary.ts"() {
  1948      MergeSummaryConflict = class {
  1949        constructor(reason, file = null, meta) {
  1950          this.reason = reason;
  1951          this.file = file;
  1952          this.meta = meta;
  1953        }
  1954        toString() {
  1955          return `${this.file}:${this.reason}`;
  1956        }
  1957      };
  1958      MergeSummaryDetail = class {
  1959        constructor() {
  1960          this.conflicts = [];
  1961          this.merges = [];
  1962          this.result = "success";
  1963        }
  1964        get failed() {
  1965          return this.conflicts.length > 0;
  1966        }
  1967        get reason() {
  1968          return this.result;
  1969        }
  1970        toString() {
  1971          if (this.conflicts.length) {
  1972            return `CONFLICTS: ${this.conflicts.join(", ")}`;
  1973          }
  1974          return "OK";
  1975        }
  1976      };
  1977    }
  1978  });
  1979  
  1980  // src/lib/responses/PullSummary.ts
  1981  var PullSummary, PullFailedSummary;
  1982  var init_PullSummary = __esm({
  1983    "src/lib/responses/PullSummary.ts"() {
  1984      PullSummary = class {
  1985        constructor() {
  1986          this.remoteMessages = {
  1987            all: []
  1988          };
  1989          this.created = [];
  1990          this.deleted = [];
  1991          this.files = [];
  1992          this.deletions = {};
  1993          this.insertions = {};
  1994          this.summary = {
  1995            changes: 0,
  1996            deletions: 0,
  1997            insertions: 0
  1998          };
  1999        }
  2000      };
  2001      PullFailedSummary = class {
  2002        constructor() {
  2003          this.remote = "";
  2004          this.hash = {
  2005            local: "",
  2006            remote: ""
  2007          };
  2008          this.branch = {
  2009            local: "",
  2010            remote: ""
  2011          };
  2012          this.message = "";
  2013        }
  2014        toString() {
  2015          return this.message;
  2016        }
  2017      };
  2018    }
  2019  });
  2020  
  2021  // src/lib/parsers/parse-remote-objects.ts
  2022  function objectEnumerationResult(remoteMessages) {
  2023    return remoteMessages.objects = remoteMessages.objects || {
  2024      compressing: 0,
  2025      counting: 0,
  2026      enumerating: 0,
  2027      packReused: 0,
  2028      reused: { count: 0, delta: 0 },
  2029      total: { count: 0, delta: 0 }
  2030    };
  2031  }
  2032  function asObjectCount(source) {
  2033    const count = /^\s*(\d+)/.exec(source);
  2034    const delta = /delta (\d+)/i.exec(source);
  2035    return {
  2036      count: asNumber(count && count[1] || "0"),
  2037      delta: asNumber(delta && delta[1] || "0")
  2038    };
  2039  }
  2040  var remoteMessagesObjectParsers;
  2041  var init_parse_remote_objects = __esm({
  2042    "src/lib/parsers/parse-remote-objects.ts"() {
  2043      init_utils();
  2044      remoteMessagesObjectParsers = [
  2045        new RemoteLineParser(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i, (result, [action, count]) => {
  2046          const key = action.toLowerCase();
  2047          const enumeration = objectEnumerationResult(result.remoteMessages);
  2048          Object.assign(enumeration, { [key]: asNumber(count) });
  2049        }),
  2050        new RemoteLineParser(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i, (result, [action, count]) => {
  2051          const key = action.toLowerCase();
  2052          const enumeration = objectEnumerationResult(result.remoteMessages);
  2053          Object.assign(enumeration, { [key]: asNumber(count) });
  2054        }),
  2055        new RemoteLineParser(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i, (result, [total, reused, packReused]) => {
  2056          const objects = objectEnumerationResult(result.remoteMessages);
  2057          objects.total = asObjectCount(total);
  2058          objects.reused = asObjectCount(reused);
  2059          objects.packReused = asNumber(packReused);
  2060        })
  2061      ];
  2062    }
  2063  });
  2064  
  2065  // src/lib/parsers/parse-remote-messages.ts
  2066  function parseRemoteMessages(_stdOut, stdErr) {
  2067    return parseStringResponse({ remoteMessages: new RemoteMessageSummary() }, parsers2, stdErr);
  2068  }
  2069  var parsers2, RemoteMessageSummary;
  2070  var init_parse_remote_messages = __esm({
  2071    "src/lib/parsers/parse-remote-messages.ts"() {
  2072      init_utils();
  2073      init_parse_remote_objects();
  2074      parsers2 = [
  2075        new RemoteLineParser(/^remote:\s*(.+)$/, (result, [text]) => {
  2076          result.remoteMessages.all.push(text.trim());
  2077          return false;
  2078        }),
  2079        ...remoteMessagesObjectParsers,
  2080        new RemoteLineParser([/create a (?:pull|merge) request/i, /\s(https?:\/\/\S+)$/], (result, [pullRequestUrl]) => {
  2081          result.remoteMessages.pullRequestUrl = pullRequestUrl;
  2082        }),
  2083        new RemoteLineParser([/found (\d+) vulnerabilities.+\(([^)]+)\)/i, /\s(https?:\/\/\S+)$/], (result, [count, summary, url]) => {
  2084          result.remoteMessages.vulnerabilities = {
  2085            count: asNumber(count),
  2086            summary,
  2087            url
  2088          };
  2089        })
  2090      ];
  2091      RemoteMessageSummary = class {
  2092        constructor() {
  2093          this.all = [];
  2094        }
  2095      };
  2096    }
  2097  });
  2098  
  2099  // src/lib/parsers/parse-pull.ts
  2100  function parsePullErrorResult(stdOut, stdErr) {
  2101    const pullError = parseStringResponse(new PullFailedSummary(), errorParsers, [stdOut, stdErr]);
  2102    return pullError.message && pullError;
  2103  }
  2104  var FILE_UPDATE_REGEX, SUMMARY_REGEX, ACTION_REGEX, parsers3, errorParsers, parsePullDetail, parsePullResult;
  2105  var init_parse_pull = __esm({
  2106    "src/lib/parsers/parse-pull.ts"() {
  2107      init_PullSummary();
  2108      init_utils();
  2109      init_parse_remote_messages();
  2110      FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
  2111      SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
  2112      ACTION_REGEX = /^(create|delete) mode \d+ (.+)/;
  2113      parsers3 = [
  2114        new LineParser(FILE_UPDATE_REGEX, (result, [file, insertions, deletions]) => {
  2115          result.files.push(file);
  2116          if (insertions) {
  2117            result.insertions[file] = insertions.length;
  2118          }
  2119          if (deletions) {
  2120            result.deletions[file] = deletions.length;
  2121          }
  2122        }),
  2123        new LineParser(SUMMARY_REGEX, (result, [changes, , insertions, , deletions]) => {
  2124          if (insertions !== void 0 || deletions !== void 0) {
  2125            result.summary.changes = +changes || 0;
  2126            result.summary.insertions = +insertions || 0;
  2127            result.summary.deletions = +deletions || 0;
  2128            return true;
  2129          }
  2130          return false;
  2131        }),
  2132        new LineParser(ACTION_REGEX, (result, [action, file]) => {
  2133          append(result.files, file);
  2134          append(action === "create" ? result.created : result.deleted, file);
  2135        })
  2136      ];
  2137      errorParsers = [
  2138        new LineParser(/^from\s(.+)$/i, (result, [remote]) => void (result.remote = remote)),
  2139        new LineParser(/^fatal:\s(.+)$/, (result, [message]) => void (result.message = message)),
  2140        new LineParser(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/, (result, [hashLocal, hashRemote, branchLocal, branchRemote]) => {
  2141          result.branch.local = branchLocal;
  2142          result.hash.local = hashLocal;
  2143          result.branch.remote = branchRemote;
  2144          result.hash.remote = hashRemote;
  2145        })
  2146      ];
  2147      parsePullDetail = (stdOut, stdErr) => {
  2148        return parseStringResponse(new PullSummary(), parsers3, [stdOut, stdErr]);
  2149      };
  2150      parsePullResult = (stdOut, stdErr) => {
  2151        return Object.assign(new PullSummary(), parsePullDetail(stdOut, stdErr), parseRemoteMessages(stdOut, stdErr));
  2152      };
  2153    }
  2154  });
  2155  
  2156  // src/lib/parsers/parse-merge.ts
  2157  var parsers4, parseMergeResult, parseMergeDetail;
  2158  var init_parse_merge = __esm({
  2159    "src/lib/parsers/parse-merge.ts"() {
  2160      init_MergeSummary();
  2161      init_utils();
  2162      init_parse_pull();
  2163      parsers4 = [
  2164        new LineParser(/^Auto-merging\s+(.+)$/, (summary, [autoMerge]) => {
  2165          summary.merges.push(autoMerge);
  2166        }),
  2167        new LineParser(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/, (summary, [reason, file]) => {
  2168          summary.conflicts.push(new MergeSummaryConflict(reason, file));
  2169        }),
  2170        new LineParser(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/, (summary, [reason, file, deleteRef]) => {
  2171          summary.conflicts.push(new MergeSummaryConflict(reason, file, { deleteRef }));
  2172        }),
  2173        new LineParser(/^CONFLICT\s+\((.+)\):/, (summary, [reason]) => {
  2174          summary.conflicts.push(new MergeSummaryConflict(reason, null));
  2175        }),
  2176        new LineParser(/^Automatic merge failed;\s+(.+)$/, (summary, [result]) => {
  2177          summary.result = result;
  2178        })
  2179      ];
  2180      parseMergeResult = (stdOut, stdErr) => {
  2181        return Object.assign(parseMergeDetail(stdOut, stdErr), parsePullResult(stdOut, stdErr));
  2182      };
  2183      parseMergeDetail = (stdOut) => {
  2184        return parseStringResponse(new MergeSummaryDetail(), parsers4, stdOut);
  2185      };
  2186    }
  2187  });
  2188  
  2189  // src/lib/tasks/merge.ts
  2190  function mergeTask(customArgs) {
  2191    if (!customArgs.length) {
  2192      return configurationErrorTask("Git.merge requires at least one option");
  2193    }
  2194    return {
  2195      commands: ["merge", ...customArgs],
  2196      format: "utf-8",
  2197      parser(stdOut, stdErr) {
  2198        const merge = parseMergeResult(stdOut, stdErr);
  2199        if (merge.failed) {
  2200          throw new GitResponseError(merge);
  2201        }
  2202        return merge;
  2203      }
  2204    };
  2205  }
  2206  var init_merge = __esm({
  2207    "src/lib/tasks/merge.ts"() {
  2208      init_git_response_error();
  2209      init_parse_merge();
  2210      init_task();
  2211    }
  2212  });
  2213  
  2214  // src/lib/parsers/parse-push.ts
  2215  function pushResultPushedItem(local, remote, status) {
  2216    const deleted = status.includes("deleted");
  2217    const tag = status.includes("tag") || /^refs\/tags/.test(local);
  2218    const alreadyUpdated = !status.includes("new");
  2219    return {
  2220      deleted,
  2221      tag,
  2222      branch: !tag,
  2223      new: !alreadyUpdated,
  2224      alreadyUpdated,
  2225      local,
  2226      remote
  2227    };
  2228  }
  2229  var parsers5, parsePushResult, parsePushDetail;
  2230  var init_parse_push = __esm({
  2231    "src/lib/parsers/parse-push.ts"() {
  2232      init_utils();
  2233      init_parse_remote_messages();
  2234      parsers5 = [
  2235        new LineParser(/^Pushing to (.+)$/, (result, [repo]) => {
  2236          result.repo = repo;
  2237        }),
  2238        new LineParser(/^updating local tracking ref '(.+)'/, (result, [local]) => {
  2239          result.ref = __spreadProps(__spreadValues({}, result.ref || {}), {
  2240            local
  2241          });
  2242        }),
  2243        new LineParser(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/, (result, [local, remote, type]) => {
  2244          result.pushed.push(pushResultPushedItem(local, remote, type));
  2245        }),
  2246        new LineParser(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/, (result, [local, remote, remoteName]) => {
  2247          result.branch = __spreadProps(__spreadValues({}, result.branch || {}), {
  2248            local,
  2249            remote,
  2250            remoteName
  2251          });
  2252        }),
  2253        new LineParser(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/, (result, [local, remote, from, to]) => {
  2254          result.update = {
  2255            head: {
  2256              local,
  2257              remote
  2258            },
  2259            hash: {
  2260              from,
  2261              to
  2262            }
  2263          };
  2264        })
  2265      ];
  2266      parsePushResult = (stdOut, stdErr) => {
  2267        const pushDetail = parsePushDetail(stdOut, stdErr);
  2268        const responseDetail = parseRemoteMessages(stdOut, stdErr);
  2269        return __spreadValues(__spreadValues({}, pushDetail), responseDetail);
  2270      };
  2271      parsePushDetail = (stdOut, stdErr) => {
  2272        return parseStringResponse({ pushed: [] }, parsers5, [stdOut, stdErr]);
  2273      };
  2274    }
  2275  });
  2276  
  2277  // src/lib/tasks/push.ts
  2278  var push_exports = {};
  2279  __export(push_exports, {
  2280    pushTagsTask: () => pushTagsTask,
  2281    pushTask: () => pushTask
  2282  });
  2283  function pushTagsTask(ref = {}, customArgs) {
  2284    append(customArgs, "--tags");
  2285    return pushTask(ref, customArgs);
  2286  }
  2287  function pushTask(ref = {}, customArgs) {
  2288    const commands = ["push", ...customArgs];
  2289    if (ref.branch) {
  2290      commands.splice(1, 0, ref.branch);
  2291    }
  2292    if (ref.remote) {
  2293      commands.splice(1, 0, ref.remote);
  2294    }
  2295    remove(commands, "-v");
  2296    append(commands, "--verbose");
  2297    append(commands, "--porcelain");
  2298    return {
  2299      commands,
  2300      format: "utf-8",
  2301      parser: parsePushResult
  2302    };
  2303  }
  2304  var init_push = __esm({
  2305    "src/lib/tasks/push.ts"() {
  2306      init_parse_push();
  2307      init_utils();
  2308    }
  2309  });
  2310  
  2311  // src/lib/tasks/show.ts
  2312  function show_default() {
  2313    return {
  2314      showBuffer() {
  2315        const commands = ["show", ...getTrailingOptions(arguments, 1)];
  2316        if (!commands.includes("--binary")) {
  2317          commands.splice(1, 0, "--binary");
  2318        }
  2319        return this._runTask(straightThroughBufferTask(commands), trailingFunctionArgument(arguments));
  2320      },
  2321      show() {
  2322        const commands = ["show", ...getTrailingOptions(arguments, 1)];
  2323        return this._runTask(straightThroughStringTask(commands), trailingFunctionArgument(arguments));
  2324      }
  2325    };
  2326  }
  2327  var init_show = __esm({
  2328    "src/lib/tasks/show.ts"() {
  2329      init_utils();
  2330      init_task();
  2331    }
  2332  });
  2333  
  2334  // src/lib/responses/FileStatusSummary.ts
  2335  var fromPathRegex, FileStatusSummary;
  2336  var init_FileStatusSummary = __esm({
  2337    "src/lib/responses/FileStatusSummary.ts"() {
  2338      fromPathRegex = /^(.+) -> (.+)$/;
  2339      FileStatusSummary = class {
  2340        constructor(path, index, working_dir) {
  2341          this.path = path;
  2342          this.index = index;
  2343          this.working_dir = working_dir;
  2344          if (index + working_dir === "R") {
  2345            const detail = fromPathRegex.exec(path) || [null, path, path];
  2346            this.from = detail[1] || "";
  2347            this.path = detail[2] || "";
  2348          }
  2349        }
  2350      };
  2351    }
  2352  });
  2353  
  2354  // src/lib/responses/StatusSummary.ts
  2355  function renamedFile(line) {
  2356    const [to, from] = line.split(NULL);
  2357    return {
  2358      from: from || to,
  2359      to
  2360    };
  2361  }
  2362  function parser2(indexX, indexY, handler) {
  2363    return [`${indexX}${indexY}`, handler];
  2364  }
  2365  function conflicts(indexX, ...indexY) {
  2366    return indexY.map((y) => parser2(indexX, y, (result, file) => append(result.conflicted, file)));
  2367  }
  2368  function splitLine(result, lineStr) {
  2369    const trimmed2 = lineStr.trim();
  2370    switch (" ") {
  2371      case trimmed2.charAt(2):
  2372        return data(trimmed2.charAt(0), trimmed2.charAt(1), trimmed2.substr(3));
  2373      case trimmed2.charAt(1):
  2374        return data(" " /* NONE */, trimmed2.charAt(0), trimmed2.substr(2));
  2375      default:
  2376        return;
  2377    }
  2378    function data(index, workingDir, path) {
  2379      const raw = `${index}${workingDir}`;
  2380      const handler = parsers6.get(raw);
  2381      if (handler) {
  2382        handler(result, path);
  2383      }
  2384      if (raw !== "##" && raw !== "!!") {
  2385        result.files.push(new FileStatusSummary(path.replace(/\0.+$/, ""), index, workingDir));
  2386      }
  2387    }
  2388  }
  2389  var StatusSummary, parsers6, parseStatusSummary;
  2390  var init_StatusSummary = __esm({
  2391    "src/lib/responses/StatusSummary.ts"() {
  2392      init_utils();
  2393      init_FileStatusSummary();
  2394      StatusSummary = class {
  2395        constructor() {
  2396          this.not_added = [];
  2397          this.conflicted = [];
  2398          this.created = [];
  2399          this.deleted = [];
  2400          this.ignored = void 0;
  2401          this.modified = [];
  2402          this.renamed = [];
  2403          this.files = [];
  2404          this.staged = [];
  2405          this.ahead = 0;
  2406          this.behind = 0;
  2407          this.current = null;
  2408          this.tracking = null;
  2409          this.detached = false;
  2410          this.isClean = () => {
  2411            return !this.files.length;
  2412          };
  2413        }
  2414      };
  2415      parsers6 = new Map([
  2416        parser2(" " /* NONE */, "A" /* ADDED */, (result, file) => append(result.created, file)),
  2417        parser2(" " /* NONE */, "D" /* DELETED */, (result, file) => append(result.deleted, file)),
  2418        parser2(" " /* NONE */, "M" /* MODIFIED */, (result, file) => append(result.modified, file)),
  2419        parser2("A" /* ADDED */, " " /* NONE */, (result, file) => append(result.created, file) && append(result.staged, file)),
  2420        parser2("A" /* ADDED */, "M" /* MODIFIED */, (result, file) => append(result.created, file) && append(result.staged, file) && append(result.modified, file)),
  2421        parser2("D" /* DELETED */, " " /* NONE */, (result, file) => append(result.deleted, file) && append(result.staged, file)),
  2422        parser2("M" /* MODIFIED */, " " /* NONE */, (result, file) => append(result.modified, file) && append(result.staged, file)),
  2423        parser2("M" /* MODIFIED */, "M" /* MODIFIED */, (result, file) => append(result.modified, file) && append(result.staged, file)),
  2424        parser2("R" /* RENAMED */, " " /* NONE */, (result, file) => {
  2425          append(result.renamed, renamedFile(file));
  2426        }),
  2427        parser2("R" /* RENAMED */, "M" /* MODIFIED */, (result, file) => {
  2428          const renamed = renamedFile(file);
  2429          append(result.renamed, renamed);
  2430          append(result.modified, renamed.to);
  2431        }),
  2432        parser2("!" /* IGNORED */, "!" /* IGNORED */, (_result, _file) => {
  2433          append(_result.ignored = _result.ignored || [], _file);
  2434        }),
  2435        parser2("?" /* UNTRACKED */, "?" /* UNTRACKED */, (result, file) => append(result.not_added, file)),
  2436        ...conflicts("A" /* ADDED */, "A" /* ADDED */, "U" /* UNMERGED */),
  2437        ...conflicts("D" /* DELETED */, "D" /* DELETED */, "U" /* UNMERGED */),
  2438        ...conflicts("U" /* UNMERGED */, "A" /* ADDED */, "D" /* DELETED */, "U" /* UNMERGED */),
  2439        [
  2440          "##",
  2441          (result, line) => {
  2442            const aheadReg = /ahead (\d+)/;
  2443            const behindReg = /behind (\d+)/;
  2444            const currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
  2445            const trackingReg = /\.{3}(\S*)/;
  2446            const onEmptyBranchReg = /\son\s([\S]+)$/;
  2447            let regexResult;
  2448            regexResult = aheadReg.exec(line);
  2449            result.ahead = regexResult && +regexResult[1] || 0;
  2450            regexResult = behindReg.exec(line);
  2451            result.behind = regexResult && +regexResult[1] || 0;
  2452            regexResult = currentReg.exec(line);
  2453            result.current = regexResult && regexResult[1];
  2454            regexResult = trackingReg.exec(line);
  2455            result.tracking = regexResult && regexResult[1];
  2456            regexResult = onEmptyBranchReg.exec(line);
  2457            result.current = regexResult && regexResult[1] || result.current;
  2458            result.detached = /\(no branch\)/.test(line);
  2459          }
  2460        ]
  2461      ]);
  2462      parseStatusSummary = function(text) {
  2463        const lines = text.split(NULL);
  2464        const status = new StatusSummary();
  2465        for (let i = 0, l = lines.length; i < l; ) {
  2466          let line = lines[i++].trim();
  2467          if (!line) {
  2468            continue;
  2469          }
  2470          if (line.charAt(0) === "R" /* RENAMED */) {
  2471            line += NULL + (lines[i++] || "");
  2472          }
  2473          splitLine(status, line);
  2474        }
  2475        return status;
  2476      };
  2477    }
  2478  });
  2479  
  2480  // src/lib/tasks/status.ts
  2481  function statusTask(customArgs) {
  2482    const commands = [
  2483      "status",
  2484      "--porcelain",
  2485      "-b",
  2486      "-u",
  2487      "--null",
  2488      ...customArgs.filter((arg) => !ignoredOptions.includes(arg))
  2489    ];
  2490    return {
  2491      format: "utf-8",
  2492      commands,
  2493      parser(text) {
  2494        return parseStatusSummary(text);
  2495      }
  2496    };
  2497  }
  2498  var ignoredOptions;
  2499  var init_status = __esm({
  2500    "src/lib/tasks/status.ts"() {
  2501      init_StatusSummary();
  2502      ignoredOptions = ["--null", "-z"];
  2503    }
  2504  });
  2505  
  2506  // src/lib/tasks/version.ts
  2507  function versionResponse(major = 0, minor = 0, patch = 0, agent = "", installed = true) {
  2508    return Object.defineProperty({
  2509      major,
  2510      minor,
  2511      patch,
  2512      agent,
  2513      installed
  2514    }, "toString", {
  2515      value() {
  2516        return `${this.major}.${this.minor}.${this.patch}`;
  2517      },
  2518      configurable: false,
  2519      enumerable: false
  2520    });
  2521  }
  2522  function notInstalledResponse() {
  2523    return versionResponse(0, 0, 0, "", false);
  2524  }
  2525  function version_default() {
  2526    return {
  2527      version() {
  2528        return this._runTask({
  2529          commands: ["--version"],
  2530          format: "utf-8",
  2531          parser: versionParser,
  2532          onError(result, error, done, fail) {
  2533            if (result.exitCode === -2 /* NOT_FOUND */) {
  2534              return done(Buffer.from(NOT_INSTALLED));
  2535            }
  2536            fail(error);
  2537          }
  2538        });
  2539      }
  2540    };
  2541  }
  2542  function versionParser(stdOut) {
  2543    if (stdOut === NOT_INSTALLED) {
  2544      return notInstalledResponse();
  2545    }
  2546    return parseStringResponse(versionResponse(0, 0, 0, stdOut), parsers7, stdOut);
  2547  }
  2548  var NOT_INSTALLED, parsers7;
  2549  var init_version = __esm({
  2550    "src/lib/tasks/version.ts"() {
  2551      init_utils();
  2552      NOT_INSTALLED = "installed=false";
  2553      parsers7 = [
  2554        new LineParser(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/, (result, [major, minor, patch, agent = ""]) => {
  2555          Object.assign(result, versionResponse(asNumber(major), asNumber(minor), asNumber(patch), agent));
  2556        }),
  2557        new LineParser(/version (\d+)\.(\d+)\.(\D+)(.+)?$/, (result, [major, minor, patch, agent = ""]) => {
  2558          Object.assign(result, versionResponse(asNumber(major), asNumber(minor), patch, agent));
  2559        })
  2560      ];
  2561    }
  2562  });
  2563  
  2564  // src/lib/simple-git-api.ts
  2565  var simple_git_api_exports = {};
  2566  __export(simple_git_api_exports, {
  2567    SimpleGitApi: () => SimpleGitApi
  2568  });
  2569  var SimpleGitApi;
  2570  var init_simple_git_api = __esm({
  2571    "src/lib/simple-git-api.ts"() {
  2572      init_task_callback();
  2573      init_change_working_directory();
  2574      init_checkout();
  2575      init_commit();
  2576      init_config();
  2577      init_grep();
  2578      init_hash_object();
  2579      init_init();
  2580      init_log();
  2581      init_merge();
  2582      init_push();
  2583      init_show();
  2584      init_status();
  2585      init_task();
  2586      init_version();
  2587      init_utils();
  2588      SimpleGitApi = class {
  2589        constructor(_executor) {
  2590          this._executor = _executor;
  2591        }
  2592        _runTask(task, then) {
  2593          const chain = this._executor.chain();
  2594          const promise = chain.push(task);
  2595          if (then) {
  2596            taskCallback(task, promise, then);
  2597          }
  2598          return Object.create(this, {
  2599            then: { value: promise.then.bind(promise) },
  2600            catch: { value: promise.catch.bind(promise) },
  2601            _executor: { value: chain }
  2602          });
  2603        }
  2604        add(files) {
  2605          return this._runTask(straightThroughStringTask(["add", ...asArray(files)]), trailingFunctionArgument(arguments));
  2606        }
  2607        cwd(directory) {
  2608          const next = trailingFunctionArgument(arguments);
  2609          if (typeof directory === "string") {
  2610            return this._runTask(changeWorkingDirectoryTask(directory, this._executor), next);
  2611          }
  2612          if (typeof (directory == null ? void 0 : directory.path) === "string") {
  2613            return this._runTask(changeWorkingDirectoryTask(directory.path, directory.root && this._executor || void 0), next);
  2614          }
  2615          return this._runTask(configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"), next);
  2616        }
  2617        hashObject(path, write) {
  2618          return this._runTask(hashObjectTask(path, write === true), trailingFunctionArgument(arguments));
  2619        }
  2620        init(bare) {
  2621          return this._runTask(initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
  2622        }
  2623        merge() {
  2624          return this._runTask(mergeTask(getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
  2625        }
  2626        mergeFromTo(remote, branch) {
  2627          if (!(filterString(remote) && filterString(branch))) {
  2628            return this._runTask(configurationErrorTask(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`));
  2629          }
  2630          return this._runTask(mergeTask([remote, branch, ...getTrailingOptions(arguments)]), trailingFunctionArgument(arguments, false));
  2631        }
  2632        outputHandler(handler) {
  2633          this._executor.outputHandler = handler;
  2634          return this;
  2635        }
  2636        push() {
  2637          const task = pushTask({
  2638            remote: filterType(arguments[0], filterString),
  2639            branch: filterType(arguments[1], filterString)
  2640          }, getTrailingOptions(arguments));
  2641          return this._runTask(task, trailingFunctionArgument(arguments));
  2642        }
  2643        stash() {
  2644          return this._runTask(straightThroughStringTask(["stash", ...getTrailingOptions(arguments)]), trailingFunctionArgument(arguments));
  2645        }
  2646        status() {
  2647          return this._runTask(statusTask(getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
  2648        }
  2649      };
  2650      Object.assign(SimpleGitApi.prototype, checkout_default(), commit_default(), config_default(), grep_default(), log_default(), show_default(), version_default());
  2651    }
  2652  });
  2653  
  2654  // src/lib/runners/scheduler.ts
  2655  var scheduler_exports = {};
  2656  __export(scheduler_exports, {
  2657    Scheduler: () => Scheduler
  2658  });
  2659  import { createDeferred } from "@kwsites/promise-deferred";
  2660  var createScheduledTask, Scheduler;
  2661  var init_scheduler = __esm({
  2662    "src/lib/runners/scheduler.ts"() {
  2663      init_utils();
  2664      init_git_logger();
  2665      createScheduledTask = (() => {
  2666        let id = 0;
  2667        return () => {
  2668          id++;
  2669          const { promise, done } = createDeferred();
  2670          return {
  2671            promise,
  2672            done,
  2673            id
  2674          };
  2675        };
  2676      })();
  2677      Scheduler = class {
  2678        constructor(concurrency = 2) {
  2679          this.concurrency = concurrency;
  2680          this.logger = createLogger("", "scheduler");
  2681          this.pending = [];
  2682          this.running = [];
  2683          this.logger(`Constructed, concurrency=%s`, concurrency);
  2684        }
  2685        schedule() {
  2686          if (!this.pending.length || this.running.length >= this.concurrency) {
  2687            this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`, this.pending.length, this.running.length, this.concurrency);
  2688            return;
  2689          }
  2690          const task = append(this.running, this.pending.shift());
  2691          this.logger(`Attempting id=%s`, task.id);
  2692          task.done(() => {
  2693            this.logger(`Completing id=`, task.id);
  2694            remove(this.running, task);
  2695            this.schedule();
  2696          });
  2697        }
  2698        next() {
  2699          const { promise, id } = append(this.pending, createScheduledTask());
  2700          this.logger(`Scheduling id=%s`, id);
  2701          this.schedule();
  2702          return promise;
  2703        }
  2704      };
  2705    }
  2706  });
  2707  
  2708  // src/lib/tasks/apply-patch.ts
  2709  var apply_patch_exports = {};
  2710  __export(apply_patch_exports, {
  2711    applyPatchTask: () => applyPatchTask
  2712  });
  2713  function applyPatchTask(patches, customArgs) {
  2714    return straightThroughStringTask(["apply", ...customArgs, ...patches]);
  2715  }
  2716  var init_apply_patch = __esm({
  2717    "src/lib/tasks/apply-patch.ts"() {
  2718      init_task();
  2719    }
  2720  });
  2721  
  2722  // src/lib/responses/BranchDeleteSummary.ts
  2723  function branchDeletionSuccess(branch, hash) {
  2724    return {
  2725      branch,
  2726      hash,
  2727      success: true
  2728    };
  2729  }
  2730  function branchDeletionFailure(branch) {
  2731    return {
  2732      branch,
  2733      hash: null,
  2734      success: false
  2735    };
  2736  }
  2737  var BranchDeletionBatch;
  2738  var init_BranchDeleteSummary = __esm({
  2739    "src/lib/responses/BranchDeleteSummary.ts"() {
  2740      BranchDeletionBatch = class {
  2741        constructor() {
  2742          this.all = [];
  2743          this.branches = {};
  2744          this.errors = [];
  2745        }
  2746        get success() {
  2747          return !this.errors.length;
  2748        }
  2749      };
  2750    }
  2751  });
  2752  
  2753  // src/lib/parsers/parse-branch-delete.ts
  2754  function hasBranchDeletionError(data, processExitCode) {
  2755    return processExitCode === 1 /* ERROR */ && deleteErrorRegex.test(data);
  2756  }
  2757  var deleteSuccessRegex, deleteErrorRegex, parsers8, parseBranchDeletions;
  2758  var init_parse_branch_delete = __esm({
  2759    "src/lib/parsers/parse-branch-delete.ts"() {
  2760      init_BranchDeleteSummary();
  2761      init_utils();
  2762      deleteSuccessRegex = /(\S+)\s+\(\S+\s([^)]+)\)/;
  2763      deleteErrorRegex = /^error[^']+'([^']+)'/m;
  2764      parsers8 = [
  2765        new LineParser(deleteSuccessRegex, (result, [branch, hash]) => {
  2766          const deletion = branchDeletionSuccess(branch, hash);
  2767          result.all.push(deletion);
  2768          result.branches[branch] = deletion;
  2769        }),
  2770        new LineParser(deleteErrorRegex, (result, [branch]) => {
  2771          const deletion = branchDeletionFailure(branch);
  2772          result.errors.push(deletion);
  2773          result.all.push(deletion);
  2774          result.branches[branch] = deletion;
  2775        })
  2776      ];
  2777      parseBranchDeletions = (stdOut, stdErr) => {
  2778        return parseStringResponse(new BranchDeletionBatch(), parsers8, [stdOut, stdErr]);
  2779      };
  2780    }
  2781  });
  2782  
  2783  // src/lib/responses/BranchSummary.ts
  2784  var BranchSummaryResult;
  2785  var init_BranchSummary = __esm({
  2786    "src/lib/responses/BranchSummary.ts"() {
  2787      BranchSummaryResult = class {
  2788        constructor() {
  2789          this.all = [];
  2790          this.branches = {};
  2791          this.current = "";
  2792          this.detached = false;
  2793        }
  2794        push(status, detached, name, commit, label) {
  2795          if (status === "*" /* CURRENT */) {
  2796            this.detached = detached;
  2797            this.current = name;
  2798          }
  2799          this.all.push(name);
  2800          this.branches[name] = {
  2801            current: status === "*" /* CURRENT */,
  2802            linkedWorkTree: status === "+" /* LINKED */,
  2803            name,
  2804            commit,
  2805            label
  2806          };
  2807        }
  2808      };
  2809    }
  2810  });
  2811  
  2812  // src/lib/parsers/parse-branch.ts
  2813  function branchStatus(input) {
  2814    return input ? input.charAt(0) : "";
  2815  }
  2816  function parseBranchSummary(stdOut) {
  2817    return parseStringResponse(new BranchSummaryResult(), parsers9, stdOut);
  2818  }
  2819  var parsers9;
  2820  var init_parse_branch = __esm({
  2821    "src/lib/parsers/parse-branch.ts"() {
  2822      init_BranchSummary();
  2823      init_utils();
  2824      parsers9 = [
  2825        new LineParser(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/, (result, [current, name, commit, label]) => {
  2826          result.push(branchStatus(current), true, name, commit, label);
  2827        }),
  2828        new LineParser(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s, (result, [current, name, commit, label]) => {
  2829          result.push(branchStatus(current), false, name, commit, label);
  2830        })
  2831      ];
  2832    }
  2833  });
  2834  
  2835  // src/lib/tasks/branch.ts
  2836  var branch_exports = {};
  2837  __export(branch_exports, {
  2838    branchLocalTask: () => branchLocalTask,
  2839    branchTask: () => branchTask,
  2840    containsDeleteBranchCommand: () => containsDeleteBranchCommand,
  2841    deleteBranchTask: () => deleteBranchTask,
  2842    deleteBranchesTask: () => deleteBranchesTask
  2843  });
  2844  function containsDeleteBranchCommand(commands) {
  2845    const deleteCommands = ["-d", "-D", "--delete"];
  2846    return commands.some((command) => deleteCommands.includes(command));
  2847  }
  2848  function branchTask(customArgs) {
  2849    const isDelete = containsDeleteBranchCommand(customArgs);
  2850    const commands = ["branch", ...customArgs];
  2851    if (commands.length === 1) {
  2852      commands.push("-a");
  2853    }
  2854    if (!commands.includes("-v")) {
  2855      commands.splice(1, 0, "-v");
  2856    }
  2857    return {
  2858      format: "utf-8",
  2859      commands,
  2860      parser(stdOut, stdErr) {
  2861        if (isDelete) {
  2862          return parseBranchDeletions(stdOut, stdErr).all[0];
  2863        }
  2864        return parseBranchSummary(stdOut);
  2865      }
  2866    };
  2867  }
  2868  function branchLocalTask() {
  2869    const parser3 = parseBranchSummary;
  2870    return {
  2871      format: "utf-8",
  2872      commands: ["branch", "-v"],
  2873      parser: parser3
  2874    };
  2875  }
  2876  function deleteBranchesTask(branches, forceDelete = false) {
  2877    return {
  2878      format: "utf-8",
  2879      commands: ["branch", "-v", forceDelete ? "-D" : "-d", ...branches],
  2880      parser(stdOut, stdErr) {
  2881        return parseBranchDeletions(stdOut, stdErr);
  2882      },
  2883      onError({ exitCode, stdOut }, error, done, fail) {
  2884        if (!hasBranchDeletionError(String(error), exitCode)) {
  2885          return fail(error);
  2886        }
  2887        done(stdOut);
  2888      }
  2889    };
  2890  }
  2891  function deleteBranchTask(branch, forceDelete = false) {
  2892    const task = {
  2893      format: "utf-8",
  2894      commands: ["branch", "-v", forceDelete ? "-D" : "-d", branch],
  2895      parser(stdOut, stdErr) {
  2896        return parseBranchDeletions(stdOut, stdErr).branches[branch];
  2897      },
  2898      onError({ exitCode, stdErr, stdOut }, error, _, fail) {
  2899        if (!hasBranchDeletionError(String(error), exitCode)) {
  2900          return fail(error);
  2901        }
  2902        throw new GitResponseError(task.parser(bufferToString(stdOut), bufferToString(stdErr)), String(error));
  2903      }
  2904    };
  2905    return task;
  2906  }
  2907  var init_branch = __esm({
  2908    "src/lib/tasks/branch.ts"() {
  2909      init_git_response_error();
  2910      init_parse_branch_delete();
  2911      init_parse_branch();
  2912      init_utils();
  2913    }
  2914  });
  2915  
  2916  // src/lib/responses/CheckIgnore.ts
  2917  var parseCheckIgnore;
  2918  var init_CheckIgnore = __esm({
  2919    "src/lib/responses/CheckIgnore.ts"() {
  2920      parseCheckIgnore = (text) => {
  2921        return text.split(/\n/g).map((line) => line.trim()).filter((file) => !!file);
  2922      };
  2923    }
  2924  });
  2925  
  2926  // src/lib/tasks/check-ignore.ts
  2927  var check_ignore_exports = {};
  2928  __export(check_ignore_exports, {
  2929    checkIgnoreTask: () => checkIgnoreTask
  2930  });
  2931  function checkIgnoreTask(paths) {
  2932    return {
  2933      commands: ["check-ignore", ...paths],
  2934      format: "utf-8",
  2935      parser: parseCheckIgnore
  2936    };
  2937  }
  2938  var init_check_ignore = __esm({
  2939    "src/lib/tasks/check-ignore.ts"() {
  2940      init_CheckIgnore();
  2941    }
  2942  });
  2943  
  2944  // src/lib/tasks/clone.ts
  2945  var clone_exports = {};
  2946  __export(clone_exports, {
  2947    cloneMirrorTask: () => cloneMirrorTask,
  2948    cloneTask: () => cloneTask
  2949  });
  2950  function disallowedCommand(command) {
  2951    return /^--upload-pack(=|$)/.test(command);
  2952  }
  2953  function cloneTask(repo, directory, customArgs) {
  2954    const commands = ["clone", ...customArgs];
  2955    filterString(repo) && commands.push(repo);
  2956    filterString(directory) && commands.push(directory);
  2957    const banned = commands.find(disallowedCommand);
  2958    if (banned) {
  2959      return configurationErrorTask(`git.fetch: potential exploit argument blocked.`);
  2960    }
  2961    return straightThroughStringTask(commands);
  2962  }
  2963  function cloneMirrorTask(repo, directory, customArgs) {
  2964    append(customArgs, "--mirror");
  2965    return cloneTask(repo, directory, customArgs);
  2966  }
  2967  var init_clone = __esm({
  2968    "src/lib/tasks/clone.ts"() {
  2969      init_task();
  2970      init_utils();
  2971    }
  2972  });
  2973  
  2974  // src/lib/parsers/parse-fetch.ts
  2975  function parseFetchResult(stdOut, stdErr) {
  2976    const result = {
  2977      raw: stdOut,
  2978      remote: null,
  2979      branches: [],
  2980      tags: [],
  2981      updated: [],
  2982      deleted: []
  2983    };
  2984    return parseStringResponse(result, parsers10, [stdOut, stdErr]);
  2985  }
  2986  var parsers10;
  2987  var init_parse_fetch = __esm({
  2988    "src/lib/parsers/parse-fetch.ts"() {
  2989      init_utils();
  2990      parsers10 = [
  2991        new LineParser(/From (.+)$/, (result, [remote]) => {
  2992          result.remote = remote;
  2993        }),
  2994        new LineParser(/\* \[new branch]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
  2995          result.branches.push({
  2996            name,
  2997            tracking
  2998          });
  2999        }),
  3000        new LineParser(/\* \[new tag]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
  3001          result.tags.push({
  3002            name,
  3003            tracking
  3004          });
  3005        }),
  3006        new LineParser(/- \[deleted]\s+\S+\s*-> (.+)$/, (result, [tracking]) => {
  3007          result.deleted.push({
  3008            tracking
  3009          });
  3010        }),
  3011        new LineParser(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/, (result, [from, to, name, tracking]) => {
  3012          result.updated.push({
  3013            name,
  3014            tracking,
  3015            to,
  3016            from
  3017          });
  3018        })
  3019      ];
  3020    }
  3021  });
  3022  
  3023  // src/lib/tasks/fetch.ts
  3024  var fetch_exports = {};
  3025  __export(fetch_exports, {
  3026    fetchTask: () => fetchTask
  3027  });
  3028  function disallowedCommand2(command) {
  3029    return /^--upload-pack(=|$)/.test(command);
  3030  }
  3031  function fetchTask(remote, branch, customArgs) {
  3032    const commands = ["fetch", ...customArgs];
  3033    if (remote && branch) {
  3034      commands.push(remote, branch);
  3035    }
  3036    const banned = commands.find(disallowedCommand2);
  3037    if (banned) {
  3038      return configurationErrorTask(`git.fetch: potential exploit argument blocked.`);
  3039    }
  3040    return {
  3041      commands,
  3042      format: "utf-8",
  3043      parser: parseFetchResult
  3044    };
  3045  }
  3046  var init_fetch = __esm({
  3047    "src/lib/tasks/fetch.ts"() {
  3048      init_parse_fetch();
  3049      init_task();
  3050    }
  3051  });
  3052  
  3053  // src/lib/parsers/parse-move.ts
  3054  function parseMoveResult(stdOut) {
  3055    return parseStringResponse({ moves: [] }, parsers11, stdOut);
  3056  }
  3057  var parsers11;
  3058  var init_parse_move = __esm({
  3059    "src/lib/parsers/parse-move.ts"() {
  3060      init_utils();
  3061      parsers11 = [
  3062        new LineParser(/^Renaming (.+) to (.+)$/, (result, [from, to]) => {
  3063          result.moves.push({ from, to });
  3064        })
  3065      ];
  3066    }
  3067  });
  3068  
  3069  // src/lib/tasks/move.ts
  3070  var move_exports = {};
  3071  __export(move_exports, {
  3072    moveTask: () => moveTask
  3073  });
  3074  function moveTask(from, to) {
  3075    return {
  3076      commands: ["mv", "-v", ...asArray(from), to],
  3077      format: "utf-8",
  3078      parser: parseMoveResult
  3079    };
  3080  }
  3081  var init_move = __esm({
  3082    "src/lib/tasks/move.ts"() {
  3083      init_parse_move();
  3084      init_utils();
  3085    }
  3086  });
  3087  
  3088  // src/lib/tasks/pull.ts
  3089  var pull_exports = {};
  3090  __export(pull_exports, {
  3091    pullTask: () => pullTask
  3092  });
  3093  function pullTask(remote, branch, customArgs) {
  3094    const commands = ["pull", ...customArgs];
  3095    if (remote && branch) {
  3096      commands.splice(1, 0, remote, branch);
  3097    }
  3098    return {
  3099      commands,
  3100      format: "utf-8",
  3101      parser(stdOut, stdErr) {
  3102        return parsePullResult(stdOut, stdErr);
  3103      },
  3104      onError(result, _error, _done, fail) {
  3105        const pullError = parsePullErrorResult(bufferToString(result.stdOut), bufferToString(result.stdErr));
  3106        if (pullError) {
  3107          return fail(new GitResponseError(pullError));
  3108        }
  3109        fail(_error);
  3110      }
  3111    };
  3112  }
  3113  var init_pull = __esm({
  3114    "src/lib/tasks/pull.ts"() {
  3115      init_git_response_error();
  3116      init_parse_pull();
  3117      init_utils();
  3118    }
  3119  });
  3120  
  3121  // src/lib/responses/GetRemoteSummary.ts
  3122  function parseGetRemotes(text) {
  3123    const remotes = {};
  3124    forEach(text, ([name]) => remotes[name] = { name });
  3125    return Object.values(remotes);
  3126  }
  3127  function parseGetRemotesVerbose(text) {
  3128    const remotes = {};
  3129    forEach(text, ([name, url, purpose]) => {
  3130      if (!remotes.hasOwnProperty(name)) {
  3131        remotes[name] = {
  3132          name,
  3133          refs: { fetch: "", push: "" }
  3134        };
  3135      }
  3136      if (purpose && url) {
  3137        remotes[name].refs[purpose.replace(/[^a-z]/g, "")] = url;
  3138      }
  3139    });
  3140    return Object.values(remotes);
  3141  }
  3142  function forEach(text, handler) {
  3143    forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
  3144  }
  3145  var init_GetRemoteSummary = __esm({
  3146    "src/lib/responses/GetRemoteSummary.ts"() {
  3147      init_utils();
  3148    }
  3149  });
  3150  
  3151  // src/lib/tasks/remote.ts
  3152  var remote_exports = {};
  3153  __export(remote_exports, {
  3154    addRemoteTask: () => addRemoteTask,
  3155    getRemotesTask: () => getRemotesTask,
  3156    listRemotesTask: () => listRemotesTask,
  3157    remoteTask: () => remoteTask,
  3158    removeRemoteTask: () => removeRemoteTask
  3159  });
  3160  function addRemoteTask(remoteName, remoteRepo, customArgs = []) {
  3161    return straightThroughStringTask(["remote", "add", ...customArgs, remoteName, remoteRepo]);
  3162  }
  3163  function getRemotesTask(verbose) {
  3164    const commands = ["remote"];
  3165    if (verbose) {
  3166      commands.push("-v");
  3167    }
  3168    return {
  3169      commands,
  3170      format: "utf-8",
  3171      parser: verbose ? parseGetRemotesVerbose : parseGetRemotes
  3172    };
  3173  }
  3174  function listRemotesTask(customArgs = []) {
  3175    const commands = [...customArgs];
  3176    if (commands[0] !== "ls-remote") {
  3177      commands.unshift("ls-remote");
  3178    }
  3179    return straightThroughStringTask(commands);
  3180  }
  3181  function remoteTask(customArgs = []) {
  3182    const commands = [...customArgs];
  3183    if (commands[0] !== "remote") {
  3184      commands.unshift("remote");
  3185    }
  3186    return straightThroughStringTask(commands);
  3187  }
  3188  function removeRemoteTask(remoteName) {
  3189    return straightThroughStringTask(["remote", "remove", remoteName]);
  3190  }
  3191  var init_remote = __esm({
  3192    "src/lib/tasks/remote.ts"() {
  3193      init_GetRemoteSummary();
  3194      init_task();
  3195    }
  3196  });
  3197  
  3198  // src/lib/tasks/stash-list.ts
  3199  var stash_list_exports = {};
  3200  __export(stash_list_exports, {
  3201    stashListTask: () => stashListTask
  3202  });
  3203  function stashListTask(opt = {}, customArgs) {
  3204    const options = parseLogOptions(opt);
  3205    const commands = ["stash", "list", ...options.commands, ...customArgs];
  3206    const parser3 = createListLogSummaryParser(options.splitter, options.fields, logFormatFromCommand(commands));
  3207    return validateLogFormatConfig(commands) || {
  3208      commands,
  3209      format: "utf-8",
  3210      parser: parser3
  3211    };
  3212  }
  3213  var init_stash_list = __esm({
  3214    "src/lib/tasks/stash-list.ts"() {
  3215      init_log_format();
  3216      init_parse_list_log_summary();
  3217      init_diff();
  3218      init_log();
  3219    }
  3220  });
  3221  
  3222  // src/lib/tasks/sub-module.ts
  3223  var sub_module_exports = {};
  3224  __export(sub_module_exports, {
  3225    addSubModuleTask: () => addSubModuleTask,
  3226    initSubModuleTask: () => initSubModuleTask,
  3227    subModuleTask: () => subModuleTask,
  3228    updateSubModuleTask: () => updateSubModuleTask
  3229  });
  3230  function addSubModuleTask(repo, path) {
  3231    return subModuleTask(["add", repo, path]);
  3232  }
  3233  function initSubModuleTask(customArgs) {
  3234    return subModuleTask(["init", ...customArgs]);
  3235  }
  3236  function subModuleTask(customArgs) {
  3237    const commands = [...customArgs];
  3238    if (commands[0] !== "submodule") {
  3239      commands.unshift("submodule");
  3240    }
  3241    return straightThroughStringTask(commands);
  3242  }
  3243  function updateSubModuleTask(customArgs) {
  3244    return subModuleTask(["update", ...customArgs]);
  3245  }
  3246  var init_sub_module = __esm({
  3247    "src/lib/tasks/sub-module.ts"() {
  3248      init_task();
  3249    }
  3250  });
  3251  
  3252  // src/lib/responses/TagList.ts
  3253  function singleSorted(a, b) {
  3254    const aIsNum = isNaN(a);
  3255    const bIsNum = isNaN(b);
  3256    if (aIsNum !== bIsNum) {
  3257      return aIsNum ? 1 : -1;
  3258    }
  3259    return aIsNum ? sorted(a, b) : 0;
  3260  }
  3261  function sorted(a, b) {
  3262    return a === b ? 0 : a > b ? 1 : -1;
  3263  }
  3264  function trimmed(input) {
  3265    return input.trim();
  3266  }
  3267  function toNumber(input) {
  3268    if (typeof input === "string") {
  3269      return parseInt(input.replace(/^\D+/g, ""), 10) || 0;
  3270    }
  3271    return 0;
  3272  }
  3273  var TagList, parseTagList;
  3274  var init_TagList = __esm({
  3275    "src/lib/responses/TagList.ts"() {
  3276      TagList = class {
  3277        constructor(all, latest) {
  3278          this.all = all;
  3279          this.latest = latest;
  3280        }
  3281      };
  3282      parseTagList = function(data, customSort = false) {
  3283        const tags = data.split("\n").map(trimmed).filter(Boolean);
  3284        if (!customSort) {
  3285          tags.sort(function(tagA, tagB) {
  3286            const partsA = tagA.split(".");
  3287            const partsB = tagB.split(".");
  3288            if (partsA.length === 1 || partsB.length === 1) {
  3289              return singleSorted(toNumber(partsA[0]), toNumber(partsB[0]));
  3290            }
  3291            for (let i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
  3292              const diff = sorted(toNumber(partsA[i]), toNumber(partsB[i]));
  3293              if (diff) {
  3294                return diff;
  3295              }
  3296            }
  3297            return 0;
  3298          });
  3299        }
  3300        const latest = customSort ? tags[0] : [...tags].reverse().find((tag) => tag.indexOf(".") >= 0);
  3301        return new TagList(tags, latest);
  3302      };
  3303    }
  3304  });
  3305  
  3306  // src/lib/tasks/tag.ts
  3307  var tag_exports = {};
  3308  __export(tag_exports, {
  3309    addAnnotatedTagTask: () => addAnnotatedTagTask,
  3310    addTagTask: () => addTagTask,
  3311    tagListTask: () => tagListTask
  3312  });
  3313  function tagListTask(customArgs = []) {
  3314    const hasCustomSort = customArgs.some((option) => /^--sort=/.test(option));
  3315    return {
  3316      format: "utf-8",
  3317      commands: ["tag", "-l", ...customArgs],
  3318      parser(text) {
  3319        return parseTagList(text, hasCustomSort);
  3320      }
  3321    };
  3322  }
  3323  function addTagTask(name) {
  3324    return {
  3325      format: "utf-8",
  3326      commands: ["tag", name],
  3327      parser() {
  3328        return { name };
  3329      }
  3330    };
  3331  }
  3332  function addAnnotatedTagTask(name, tagMessage) {
  3333    return {
  3334      format: "utf-8",
  3335      commands: ["tag", "-a", "-m", tagMessage, name],
  3336      parser() {
  3337        return { name };
  3338      }
  3339    };
  3340  }
  3341  var init_tag = __esm({
  3342    "src/lib/tasks/tag.ts"() {
  3343      init_TagList();
  3344    }
  3345  });
  3346  
  3347  // src/git.js
  3348  var require_git = __commonJS({
  3349    "src/git.js"(exports, module) {
  3350      var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
  3351      var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
  3352      var { Scheduler: Scheduler2 } = (init_scheduler(), __toCommonJS(scheduler_exports));
  3353      var { configurationErrorTask: configurationErrorTask2 } = (init_task(), __toCommonJS(task_exports));
  3354      var {
  3355        asArray: asArray2,
  3356        filterArray: filterArray2,
  3357        filterPrimitives: filterPrimitives2,
  3358        filterString: filterString2,
  3359        filterStringOrStringArray: filterStringOrStringArray2,
  3360        filterType: filterType2,
  3361        getTrailingOptions: getTrailingOptions2,
  3362        trailingFunctionArgument: trailingFunctionArgument2,
  3363        trailingOptionsArgument: trailingOptionsArgument2
  3364      } = (init_utils(), __toCommonJS(utils_exports));
  3365      var { applyPatchTask: applyPatchTask2 } = (init_apply_patch(), __toCommonJS(apply_patch_exports));
  3366      var {
  3367        branchTask: branchTask2,
  3368        branchLocalTask: branchLocalTask2,
  3369        deleteBranchesTask: deleteBranchesTask2,
  3370        deleteBranchTask: deleteBranchTask2
  3371      } = (init_branch(), __toCommonJS(branch_exports));
  3372      var { checkIgnoreTask: checkIgnoreTask2 } = (init_check_ignore(), __toCommonJS(check_ignore_exports));
  3373      var { checkIsRepoTask: checkIsRepoTask2 } = (init_check_is_repo(), __toCommonJS(check_is_repo_exports));
  3374      var { cloneTask: cloneTask2, cloneMirrorTask: cloneMirrorTask2 } = (init_clone(), __toCommonJS(clone_exports));
  3375      var { cleanWithOptionsTask: cleanWithOptionsTask2, isCleanOptionsArray: isCleanOptionsArray2 } = (init_clean(), __toCommonJS(clean_exports));
  3376      var { diffSummaryTask: diffSummaryTask2 } = (init_diff(), __toCommonJS(diff_exports));
  3377      var { fetchTask: fetchTask2 } = (init_fetch(), __toCommonJS(fetch_exports));
  3378      var { moveTask: moveTask2 } = (init_move(), __toCommonJS(move_exports));
  3379      var { pullTask: pullTask2 } = (init_pull(), __toCommonJS(pull_exports));
  3380      var { pushTagsTask: pushTagsTask2 } = (init_push(), __toCommonJS(push_exports));
  3381      var {
  3382        addRemoteTask: addRemoteTask2,
  3383        getRemotesTask: getRemotesTask2,
  3384        listRemotesTask: listRemotesTask2,
  3385        remoteTask: remoteTask2,
  3386        removeRemoteTask: removeRemoteTask2
  3387      } = (init_remote(), __toCommonJS(remote_exports));
  3388      var { getResetMode: getResetMode2, resetTask: resetTask2 } = (init_reset(), __toCommonJS(reset_exports));
  3389      var { stashListTask: stashListTask2 } = (init_stash_list(), __toCommonJS(stash_list_exports));
  3390      var {
  3391        addSubModuleTask: addSubModuleTask2,
  3392        initSubModuleTask: initSubModuleTask2,
  3393        subModuleTask: subModuleTask2,
  3394        updateSubModuleTask: updateSubModuleTask2
  3395      } = (init_sub_module(), __toCommonJS(sub_module_exports));
  3396      var { addAnnotatedTagTask: addAnnotatedTagTask2, addTagTask: addTagTask2, tagListTask: tagListTask2 } = (init_tag(), __toCommonJS(tag_exports));
  3397      var { straightThroughBufferTask: straightThroughBufferTask2, straightThroughStringTask: straightThroughStringTask2 } = (init_task(), __toCommonJS(task_exports));
  3398      function Git2(options, plugins) {
  3399        this._executor = new GitExecutor2(options.binary, options.baseDir, new Scheduler2(options.maxConcurrentProcesses), plugins);
  3400        this._trimmed = options.trimmed;
  3401      }
  3402      (Git2.prototype = Object.create(SimpleGitApi2.prototype)).constructor = Git2;
  3403      Git2.prototype.customBinary = function(command) {
  3404        this._executor.binary = command;
  3405        return this;
  3406      };
  3407      Git2.prototype.env = function(name, value) {
  3408        if (arguments.length === 1 && typeof name === "object") {
  3409          this._executor.env = name;
  3410        } else {
  3411          (this._executor.env = this._executor.env || {})[name] = value;
  3412        }
  3413        return this;
  3414      };
  3415      Git2.prototype.stashList = function(options) {
  3416        return this._runTask(stashListTask2(trailingOptionsArgument2(arguments) || {}, filterArray2(options) && options || []), trailingFunctionArgument2(arguments));
  3417      };
  3418      function createCloneTask(api, task, repoPath, localPath) {
  3419        if (typeof repoPath !== "string") {
  3420          return configurationErrorTask2(`git.${api}() requires a string 'repoPath'`);
  3421        }
  3422        return task(repoPath, filterType2(localPath, filterString2), getTrailingOptions2(arguments));
  3423      }
  3424      Git2.prototype.clone = function() {
  3425        return this._runTask(createCloneTask("clone", cloneTask2, ...arguments), trailingFunctionArgument2(arguments));
  3426      };
  3427      Git2.prototype.mirror = function() {
  3428        return this._runTask(createCloneTask("mirror", cloneMirrorTask2, ...arguments), trailingFunctionArgument2(arguments));
  3429      };
  3430      Git2.prototype.mv = function(from, to) {
  3431        return this._runTask(moveTask2(from, to), trailingFunctionArgument2(arguments));
  3432      };
  3433      Git2.prototype.checkoutLatestTag = function(then) {
  3434        var git = this;
  3435        return this.pull(function() {
  3436          git.tags(function(err, tags) {
  3437            git.checkout(tags.latest, then);
  3438          });
  3439        });
  3440      };
  3441      Git2.prototype.pull = function(remote, branch, options, then) {
  3442        return this._runTask(pullTask2(filterType2(remote, filterString2), filterType2(branch, filterString2), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3443      };
  3444      Git2.prototype.fetch = function(remote, branch) {
  3445        return this._runTask(fetchTask2(filterType2(remote, filterString2), filterType2(branch, filterString2), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3446      };
  3447      Git2.prototype.silent = function(silence) {
  3448        console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this will be an error in version 3");
  3449        return this;
  3450      };
  3451      Git2.prototype.tags = function(options, then) {
  3452        return this._runTask(tagListTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3453      };
  3454      Git2.prototype.rebase = function() {
  3455        return this._runTask(straightThroughStringTask2(["rebase", ...getTrailingOptions2(arguments)]), trailingFunctionArgument2(arguments));
  3456      };
  3457      Git2.prototype.reset = function(mode) {
  3458        return this._runTask(resetTask2(getResetMode2(mode), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3459      };
  3460      Git2.prototype.revert = function(commit) {
  3461        const next = trailingFunctionArgument2(arguments);
  3462        if (typeof commit !== "string") {
  3463          return this._runTask(configurationErrorTask2("Commit must be a string"), next);
  3464        }
  3465        return this._runTask(straightThroughStringTask2(["revert", ...getTrailingOptions2(arguments, 0, true), commit]), next);
  3466      };
  3467      Git2.prototype.addTag = function(name) {
  3468        const task = typeof name === "string" ? addTagTask2(name) : configurationErrorTask2("Git.addTag requires a tag name");
  3469        return this._runTask(task, trailingFunctionArgument2(arguments));
  3470      };
  3471      Git2.prototype.addAnnotatedTag = function(tagName, tagMessage) {
  3472        return this._runTask(addAnnotatedTagTask2(tagName, tagMessage), trailingFunctionArgument2(arguments));
  3473      };
  3474      Git2.prototype.deleteLocalBranch = function(branchName, forceDelete, then) {
  3475        return this._runTask(deleteBranchTask2(branchName, typeof forceDelete === "boolean" ? forceDelete : false), trailingFunctionArgument2(arguments));
  3476      };
  3477      Git2.prototype.deleteLocalBranches = function(branchNames, forceDelete, then) {
  3478        return this._runTask(deleteBranchesTask2(branchNames, typeof forceDelete === "boolean" ? forceDelete : false), trailingFunctionArgument2(arguments));
  3479      };
  3480      Git2.prototype.branch = function(options, then) {
  3481        return this._runTask(branchTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3482      };
  3483      Git2.prototype.branchLocal = function(then) {
  3484        return this._runTask(branchLocalTask2(), trailingFunctionArgument2(arguments));
  3485      };
  3486      Git2.prototype.raw = function(commands) {
  3487        const createRestCommands = !Array.isArray(commands);
  3488        const command = [].slice.call(createRestCommands ? arguments : commands, 0);
  3489        for (let i = 0; i < command.length && createRestCommands; i++) {
  3490          if (!filterPrimitives2(command[i])) {
  3491            command.splice(i, command.length - i);
  3492            break;
  3493          }
  3494        }
  3495        command.push(...getTrailingOptions2(arguments, 0, true));
  3496        var next = trailingFunctionArgument2(arguments);
  3497        if (!command.length) {
  3498          return this._runTask(configurationErrorTask2("Raw: must supply one or more command to execute"), next);
  3499        }
  3500        return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
  3501      };
  3502      Git2.prototype.submoduleAdd = function(repo, path, then) {
  3503        return this._runTask(addSubModuleTask2(repo, path), trailingFunctionArgument2(arguments));
  3504      };
  3505      Git2.prototype.submoduleUpdate = function(args, then) {
  3506        return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
  3507      };
  3508      Git2.prototype.submoduleInit = function(args, then) {
  3509        return this._runTask(initSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
  3510      };
  3511      Git2.prototype.subModule = function(options, then) {
  3512        return this._runTask(subModuleTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3513      };
  3514      Git2.prototype.listRemote = function() {
  3515        return this._runTask(listRemotesTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3516      };
  3517      Git2.prototype.addRemote = function(remoteName, remoteRepo, then) {
  3518        return this._runTask(addRemoteTask2(remoteName, remoteRepo, getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3519      };
  3520      Git2.prototype.removeRemote = function(remoteName, then) {
  3521        return this._runTask(removeRemoteTask2(remoteName), trailingFunctionArgument2(arguments));
  3522      };
  3523      Git2.prototype.getRemotes = function(verbose, then) {
  3524        return this._runTask(getRemotesTask2(verbose === true), trailingFunctionArgument2(arguments));
  3525      };
  3526      Git2.prototype.remote = function(options, then) {
  3527        return this._runTask(remoteTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
  3528      };
  3529      Git2.prototype.tag = function(options, then) {
  3530        const command = getTrailingOptions2(arguments);
  3531        if (command[0] !== "tag") {
  3532          command.unshift("tag");
  3533        }
  3534        return this._runTask(straightThroughStringTask2(command), trailingFunctionArgument2(arguments));
  3535      };
  3536      Git2.prototype.updateServerInfo = function(then) {
  3537        return this._runTask(straightThroughStringTask2(["update-server-info"]), trailingFunctionArgument2(arguments));
  3538      };
  3539      Git2.prototype.pushTags = function(remote, then) {
  3540        const task = pushTagsTask2({ remote: filterType2(remote, filterString2) }, getTrailingOptions2(arguments));
  3541        return this._runTask(task, trailingFunctionArgument2(arguments));
  3542      };
  3543      Git2.prototype.rm = function(files) {
  3544        return this._runTask(straightThroughStringTask2(["rm", "-f", ...asArray2(files)]), trailingFunctionArgument2(arguments));
  3545      };
  3546      Git2.prototype.rmKeepLocal = function(files) {
  3547        return this._runTask(straightThroughStringTask2(["rm", "--cached", ...asArray2(files)]), trailingFunctionArgument2(arguments));
  3548      };
  3549      Git2.prototype.catFile = function(options, then) {
  3550        return this._catFile("utf-8", arguments);
  3551      };
  3552      Git2.prototype.binaryCatFile = function() {
  3553        return this._catFile("buffer", arguments);
  3554      };
  3555      Git2.prototype._catFile = function(format, args) {
  3556        var handler = trailingFunctionArgument2(args);
  3557        var command = ["cat-file"];
  3558        var options = args[0];
  3559        if (typeof options === "string") {
  3560          return this._runTask(configurationErrorTask2("Git.catFile: options must be supplied as an array of strings"), handler);
  3561        }
  3562        if (Array.isArray(options)) {
  3563          command.push.apply(command, options);
  3564        }
  3565        const task = format === "buffer" ? straightThroughBufferTask2(command) : straightThroughStringTask2(command);
  3566        return this._runTask(task, handler);
  3567      };
  3568      Git2.prototype.diff = function(options, then) {
  3569        const task = filterString2(options) ? configurationErrorTask2("git.diff: supplying options as a single string is no longer supported, switch to an array of strings") : straightThroughStringTask2(["diff", ...getTrailingOptions2(arguments)]);
  3570        return this._runTask(task, trailingFunctionArgument2(arguments));
  3571      };
  3572      Git2.prototype.diffSummary = function() {
  3573        return this._runTask(diffSummaryTask2(getTrailingOptions2(arguments, 1)), trailingFunctionArgument2(arguments));
  3574      };
  3575      Git2.prototype.applyPatch = function(patches) {
  3576        const task = !filterStringOrStringArray2(patches) ? configurationErrorTask2(`git.applyPatch requires one or more string patches as the first argument`) : applyPatchTask2(asArray2(patches), getTrailingOptions2([].slice.call(arguments, 1)));
  3577        return this._runTask(task, trailingFunctionArgument2(arguments));
  3578      };
  3579      Git2.prototype.revparse = function() {
  3580        const commands = ["rev-parse", ...getTrailingOptions2(arguments, true)];
  3581        return this._runTask(straightThroughStringTask2(commands, true), trailingFunctionArgument2(arguments));
  3582      };
  3583      Git2.prototype.clean = function(mode, options, then) {
  3584        const usingCleanOptionsArray = isCleanOptionsArray2(mode);
  3585        const cleanMode = usingCleanOptionsArray && mode.join("") || filterType2(mode, filterString2) || "";
  3586        const customArgs = getTrailingOptions2([].slice.call(arguments, usingCleanOptionsArray ? 1 : 0));
  3587        return this._runTask(cleanWithOptionsTask2(cleanMode, customArgs), trailingFunctionArgument2(arguments));
  3588      };
  3589      Git2.prototype.exec = function(then) {
  3590        const task = {
  3591          commands: [],
  3592          format: "utf-8",
  3593          parser() {
  3594            if (typeof then === "function") {
  3595              then();
  3596            }
  3597          }
  3598        };
  3599        return this._runTask(task);
  3600      };
  3601      Git2.prototype.clearQueue = function() {
  3602        return this;
  3603      };
  3604      Git2.prototype.checkIgnore = function(pathnames, then) {
  3605        return this._runTask(checkIgnoreTask2(asArray2(filterType2(pathnames, filterStringOrStringArray2, []))), trailingFunctionArgument2(arguments));
  3606      };
  3607      Git2.prototype.checkIsRepo = function(checkType, then) {
  3608        return this._runTask(checkIsRepoTask2(filterType2(checkType, filterString2)), trailingFunctionArgument2(arguments));
  3609      };
  3610      module.exports = Git2;
  3611    }
  3612  });
  3613  
  3614  // src/lib/api.ts
  3615  init_pathspec();
  3616  
  3617  // src/lib/errors/git-construct-error.ts
  3618  init_git_error();
  3619  var GitConstructError = class extends GitError {
  3620    constructor(config, message) {
  3621      super(void 0, message);
  3622      this.config = config;
  3623    }
  3624  };
  3625  
  3626  // src/lib/api.ts
  3627  init_git_error();
  3628  
  3629  // src/lib/errors/git-plugin-error.ts
  3630  init_git_error();
  3631  var GitPluginError = class extends GitError {
  3632    constructor(task, plugin, message) {
  3633      super(task, message);
  3634      this.task = task;
  3635      this.plugin = plugin;
  3636      Object.setPrototypeOf(this, new.target.prototype);
  3637    }
  3638  };
  3639  
  3640  // src/lib/api.ts
  3641  init_git_response_error();
  3642  init_task_configuration_error();
  3643  init_check_is_repo();
  3644  init_clean();
  3645  init_config();
  3646  init_grep();
  3647  init_reset();
  3648  
  3649  // src/lib/plugins/abort-plugin.ts
  3650  function abortPlugin(signal) {
  3651    if (!signal) {
  3652      return;
  3653    }
  3654    const onSpawnAfter = {
  3655      type: "spawn.after",
  3656      action(_data, context) {
  3657        function kill() {
  3658          context.kill(new GitPluginError(void 0, "abort", "Abort signal received"));
  3659        }
  3660        signal.addEventListener("abort", kill);
  3661        context.spawned.on("close", () => signal.removeEventListener("abort", kill));
  3662      }
  3663    };
  3664    const onSpawnBefore = {
  3665      type: "spawn.before",
  3666      action(_data, context) {
  3667        if (signal.aborted) {
  3668          context.kill(new GitPluginError(void 0, "abort", "Abort already signaled"));
  3669        }
  3670      }
  3671    };
  3672    return [onSpawnBefore, onSpawnAfter];
  3673  }
  3674  
  3675  // src/lib/plugins/block-unsafe-operations-plugin.ts
  3676  function isConfigSwitch(arg) {
  3677    return typeof arg === "string" && arg.trim().toLowerCase() === "-c";
  3678  }
  3679  function preventProtocolOverride(arg, next) {
  3680    if (!isConfigSwitch(arg)) {
  3681      return;
  3682    }
  3683    if (!/^\s*protocol(.[a-z]+)?.allow/.test(next)) {
  3684      return;
  3685    }
  3686    throw new GitPluginError(void 0, "unsafe", "Configuring protocol.allow is not permitted without enabling allowUnsafeExtProtocol");
  3687  }
  3688  function preventUploadPack(arg, method) {
  3689    if (/^\s*--(upload|receive)-pack/.test(arg)) {
  3690      throw new GitPluginError(void 0, "unsafe", `Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);
  3691    }
  3692    if (method === "clone" && /^\s*-u\b/.test(arg)) {
  3693      throw new GitPluginError(void 0, "unsafe", `Use of clone with option -u is not permitted without enabling allowUnsafePack`);
  3694    }
  3695    if (method === "push" && /^\s*--exec\b/.test(arg)) {
  3696      throw new GitPluginError(void 0, "unsafe", `Use of push with option --exec is not permitted without enabling allowUnsafePack`);
  3697    }
  3698  }
  3699  function blockUnsafeOperationsPlugin({
  3700    allowUnsafeProtocolOverride = false,
  3701    allowUnsafePack = false
  3702  } = {}) {
  3703    return {
  3704      type: "spawn.args",
  3705      action(args, context) {
  3706        args.forEach((current, index) => {
  3707          const next = index < args.length ? args[index + 1] : "";
  3708          allowUnsafeProtocolOverride || preventProtocolOverride(current, next);
  3709          allowUnsafePack || preventUploadPack(current, context.method);
  3710        });
  3711        return args;
  3712      }
  3713    };
  3714  }
  3715  
  3716  // src/lib/plugins/command-config-prefixing-plugin.ts
  3717  init_utils();
  3718  function commandConfigPrefixingPlugin(configuration) {
  3719    const prefix = prefixedArray(configuration, "-c");
  3720    return {
  3721      type: "spawn.args",
  3722      action(data) {
  3723        return [...prefix, ...data];
  3724      }
  3725    };
  3726  }
  3727  
  3728  // src/lib/plugins/completion-detection.plugin.ts
  3729  init_utils();
  3730  import { deferred } from "@kwsites/promise-deferred";
  3731  var never = deferred().promise;
  3732  function completionDetectionPlugin({
  3733    onClose = true,
  3734    onExit = 50
  3735  } = {}) {
  3736    function createEvents() {
  3737      let exitCode = -1;
  3738      const events = {
  3739        close: deferred(),
  3740        closeTimeout: deferred(),
  3741        exit: deferred(),
  3742        exitTimeout: deferred()
  3743      };
  3744      const result = Promise.race([
  3745        onClose === false ? never : events.closeTimeout.promise,
  3746        onExit === false ? never : events.exitTimeout.promise
  3747      ]);
  3748      configureTimeout(onClose, events.close, events.closeTimeout);
  3749      configureTimeout(onExit, events.exit, events.exitTimeout);
  3750      return {
  3751        close(code) {
  3752          exitCode = code;
  3753          events.close.done();
  3754        },
  3755        exit(code) {
  3756          exitCode = code;
  3757          events.exit.done();
  3758        },
  3759        get exitCode() {
  3760          return exitCode;
  3761        },
  3762        result
  3763      };
  3764    }
  3765    function configureTimeout(flag, event, timeout) {
  3766      if (flag === false) {
  3767        return;
  3768      }
  3769      (flag === true ? event.promise : event.promise.then(() => delay(flag))).then(timeout.done);
  3770    }
  3771    return {
  3772      type: "spawn.after",
  3773      action(_0, _1) {
  3774        return __async(this, arguments, function* (_data, { spawned, close }) {
  3775          var _a2, _b;
  3776          const events = createEvents();
  3777          let deferClose = true;
  3778          let quickClose = () => void (deferClose = false);
  3779          (_a2 = spawned.stdout) == null ? void 0 : _a2.on("data", quickClose);
  3780          (_b = spawned.stderr) == null ? void 0 : _b.on("data", quickClose);
  3781          spawned.on("error", quickClose);
  3782          spawned.on("close", (code) => events.close(code));
  3783          spawned.on("exit", (code) => events.exit(code));
  3784          try {
  3785            yield events.result;
  3786            if (deferClose) {
  3787              yield delay(50);
  3788            }
  3789            close(events.exitCode);
  3790          } catch (err) {
  3791            close(events.exitCode, err);
  3792          }
  3793        });
  3794      }
  3795    };
  3796  }
  3797  
  3798  // src/lib/plugins/error-detection.plugin.ts
  3799  init_git_error();
  3800  function isTaskError(result) {
  3801    return !!(result.exitCode && result.stdErr.length);
  3802  }
  3803  function getErrorMessage(result) {
  3804    return Buffer.concat([...result.stdOut, ...result.stdErr]);
  3805  }
  3806  function errorDetectionHandler(overwrite = false, isError = isTaskError, errorMessage = getErrorMessage) {
  3807    return (error, result) => {
  3808      if (!overwrite && error || !isError(result)) {
  3809        return error;
  3810      }
  3811      return errorMessage(result);
  3812    };
  3813  }
  3814  function errorDetectionPlugin(config) {
  3815    return {
  3816      type: "task.error",
  3817      action(data, context) {
  3818        const error = config(data.error, {
  3819          stdErr: context.stdErr,
  3820          stdOut: context.stdOut,
  3821          exitCode: context.exitCode
  3822        });
  3823        if (Buffer.isBuffer(error)) {
  3824          return { error: new GitError(void 0, error.toString("utf-8")) };
  3825        }
  3826        return {
  3827          error
  3828        };
  3829      }
  3830    };
  3831  }
  3832  
  3833  // src/lib/plugins/plugin-store.ts
  3834  init_utils();
  3835  var PluginStore = class {
  3836    constructor() {
  3837      this.plugins = /* @__PURE__ */ new Set();
  3838    }
  3839    add(plugin) {
  3840      const plugins = [];
  3841      asArray(plugin).forEach((plugin2) => plugin2 && this.plugins.add(append(plugins, plugin2)));
  3842      return () => {
  3843        plugins.forEach((plugin2) => this.plugins.delete(plugin2));
  3844      };
  3845    }
  3846    exec(type, data, context) {
  3847      let output = data;
  3848      const contextual = Object.freeze(Object.create(context));
  3849      for (const plugin of this.plugins) {
  3850        if (plugin.type === type) {
  3851          output = plugin.action(output, contextual);
  3852        }
  3853      }
  3854      return output;
  3855    }
  3856  };
  3857  
  3858  // src/lib/plugins/progress-monitor-plugin.ts
  3859  init_utils();
  3860  function progressMonitorPlugin(progress) {
  3861    const progressCommand = "--progress";
  3862    const progressMethods = ["checkout", "clone", "fetch", "pull", "push"];
  3863    const onProgress = {
  3864      type: "spawn.after",
  3865      action(_data, context) {
  3866        var _a2;
  3867        if (!context.commands.includes(progressCommand)) {
  3868          return;
  3869        }
  3870        (_a2 = context.spawned.stderr) == null ? void 0 : _a2.on("data", (chunk) => {
  3871          const message = /^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(chunk.toString("utf8"));
  3872          if (!message) {
  3873            return;
  3874          }
  3875          progress({
  3876            method: context.method,
  3877            stage: progressEventStage(message[1]),
  3878            progress: asNumber(message[2]),
  3879            processed: asNumber(message[3]),
  3880            total: asNumber(message[4])
  3881          });
  3882        });
  3883      }
  3884    };
  3885    const onArgs = {
  3886      type: "spawn.args",
  3887      action(args, context) {
  3888        if (!progressMethods.includes(context.method)) {
  3889          return args;
  3890        }
  3891        return including(args, progressCommand);
  3892      }
  3893    };
  3894    return [onArgs, onProgress];
  3895  }
  3896  function progressEventStage(input) {
  3897    return String(input.toLowerCase().split(" ", 1)) || "unknown";
  3898  }
  3899  
  3900  // src/lib/plugins/spawn-options-plugin.ts
  3901  init_utils();
  3902  function spawnOptionsPlugin(spawnOptions) {
  3903    const options = pick(spawnOptions, ["uid", "gid"]);
  3904    return {
  3905      type: "spawn.options",
  3906      action(data) {
  3907        return __spreadValues(__spreadValues({}, options), data);
  3908      }
  3909    };
  3910  }
  3911  
  3912  // src/lib/plugins/timout-plugin.ts
  3913  function timeoutPlugin({
  3914    block,
  3915    stdErr = true,
  3916    stdOut = true
  3917  }) {
  3918    if (block > 0) {
  3919      return {
  3920        type: "spawn.after",
  3921        action(_data, context) {
  3922          var _a2, _b;
  3923          let timeout;
  3924          function wait() {
  3925            timeout && clearTimeout(timeout);
  3926            timeout = setTimeout(kill, block);
  3927          }
  3928          function stop() {
  3929            var _a3, _b2;
  3930            (_a3 = context.spawned.stdout) == null ? void 0 : _a3.off("data", wait);
  3931            (_b2 = context.spawned.stderr) == null ? void 0 : _b2.off("data", wait);
  3932            context.spawned.off("exit", stop);
  3933            context.spawned.off("close", stop);
  3934            timeout && clearTimeout(timeout);
  3935          }
  3936          function kill() {
  3937            stop();
  3938            context.kill(new GitPluginError(void 0, "timeout", `block timeout reached`));
  3939          }
  3940          stdOut && ((_a2 = context.spawned.stdout) == null ? void 0 : _a2.on("data", wait));
  3941          stdErr && ((_b = context.spawned.stderr) == null ? void 0 : _b.on("data", wait));
  3942          context.spawned.on("exit", stop);
  3943          context.spawned.on("close", stop);
  3944          wait();
  3945        }
  3946      };
  3947    }
  3948  }
  3949  
  3950  // src/lib/plugins/suffix-paths.plugin.ts
  3951  init_pathspec();
  3952  function suffixPathsPlugin() {
  3953    return {
  3954      type: "spawn.args",
  3955      action(data) {
  3956        const prefix = [];
  3957        let suffix;
  3958        function append2(args) {
  3959          (suffix = suffix || []).push(...args);
  3960        }
  3961        for (let i = 0; i < data.length; i++) {
  3962          const param = data[i];
  3963          if (isPathSpec(param)) {
  3964            append2(toPaths(param));
  3965            continue;
  3966          }
  3967          if (param === "--") {
  3968            append2(data.slice(i + 1).flatMap((item) => isPathSpec(item) && toPaths(item) || item));
  3969            break;
  3970          }
  3971          prefix.push(param);
  3972        }
  3973        return !suffix ? prefix : [...prefix, "--", ...suffix.map(String)];
  3974      }
  3975    };
  3976  }
  3977  
  3978  // src/lib/git-factory.ts
  3979  init_utils();
  3980  var Git = require_git();
  3981  function gitInstanceFactory(baseDir, options) {
  3982    const plugins = new PluginStore();
  3983    const config = createInstanceConfig(baseDir && (typeof baseDir === "string" ? { baseDir } : baseDir) || {}, options);
  3984    if (!folderExists(config.baseDir)) {
  3985      throw new GitConstructError(config, `Cannot use simple-git on a directory that does not exist`);
  3986    }
  3987    if (Array.isArray(config.config)) {
  3988      plugins.add(commandConfigPrefixingPlugin(config.config));
  3989    }
  3990    plugins.add(blockUnsafeOperationsPlugin(config.unsafe));
  3991    plugins.add(suffixPathsPlugin());
  3992    plugins.add(completionDetectionPlugin(config.completion));
  3993    config.abort && plugins.add(abortPlugin(config.abort));
  3994    config.progress && plugins.add(progressMonitorPlugin(config.progress));
  3995    config.timeout && plugins.add(timeoutPlugin(config.timeout));
  3996    config.spawnOptions && plugins.add(spawnOptionsPlugin(config.spawnOptions));
  3997    plugins.add(errorDetectionPlugin(errorDetectionHandler(true)));
  3998    config.errors && plugins.add(errorDetectionPlugin(config.errors));
  3999    return new Git(config, plugins);
  4000  }
  4001  
  4002  // src/lib/runners/promise-wrapped.ts
  4003  init_git_response_error();
  4004  var functionNamesBuilderApi = ["customBinary", "env", "outputHandler", "silent"];
  4005  var functionNamesPromiseApi = [
  4006    "add",
  4007    "addAnnotatedTag",
  4008    "addConfig",
  4009    "addRemote",
  4010    "addTag",
  4011    "applyPatch",
  4012    "binaryCatFile",
  4013    "branch",
  4014    "branchLocal",
  4015    "catFile",
  4016    "checkIgnore",
  4017    "checkIsRepo",
  4018    "checkout",
  4019    "checkoutBranch",
  4020    "checkoutLatestTag",
  4021    "checkoutLocalBranch",
  4022    "clean",
  4023    "clone",
  4024    "commit",
  4025    "cwd",
  4026    "deleteLocalBranch",
  4027    "deleteLocalBranches",
  4028    "diff",
  4029    "diffSummary",
  4030    "exec",
  4031    "fetch",
  4032    "getRemotes",
  4033    "init",
  4034    "listConfig",
  4035    "listRemote",
  4036    "log",
  4037    "merge",
  4038    "mergeFromTo",
  4039    "mirror",
  4040    "mv",
  4041    "pull",
  4042    "push",
  4043    "pushTags",
  4044    "raw",
  4045    "rebase",
  4046    "remote",
  4047    "removeRemote",
  4048    "reset",
  4049    "revert",
  4050    "revparse",
  4051    "rm",
  4052    "rmKeepLocal",
  4053    "show",
  4054    "stash",
  4055    "stashList",
  4056    "status",
  4057    "subModule",
  4058    "submoduleAdd",
  4059    "submoduleInit",
  4060    "submoduleUpdate",
  4061    "tag",
  4062    "tags",
  4063    "updateServerInfo"
  4064  ];
  4065  function gitP(...args) {
  4066    let git;
  4067    let chain = Promise.resolve();
  4068    try {
  4069      git = gitInstanceFactory(...args);
  4070    } catch (e) {
  4071      chain = Promise.reject(e);
  4072    }
  4073    function builderReturn() {
  4074      return promiseApi;
  4075    }
  4076    function chainReturn() {
  4077      return chain;
  4078    }
  4079    const promiseApi = [...functionNamesBuilderApi, ...functionNamesPromiseApi].reduce((api, name) => {
  4080      const isAsync = functionNamesPromiseApi.includes(name);
  4081      const valid = isAsync ? asyncWrapper(name, git) : syncWrapper(name, git, api);
  4082      const alternative = isAsync ? chainReturn : builderReturn;
  4083      Object.defineProperty(api, name, {
  4084        enumerable: false,
  4085        configurable: false,
  4086        value: git ? valid : alternative
  4087      });
  4088      return api;
  4089    }, {});
  4090    return promiseApi;
  4091    function asyncWrapper(fn, git2) {
  4092      return function(...args2) {
  4093        if (typeof args2[args2.length] === "function") {
  4094          throw new TypeError("Promise interface requires that handlers are not supplied inline, trailing function not allowed in call to " + fn);
  4095        }
  4096        return chain.then(function() {
  4097          return new Promise(function(resolve, reject) {
  4098            const callback = (err, result) => {
  4099              if (err) {
  4100                return reject(toError(err));
  4101              }
  4102              resolve(result);
  4103            };
  4104            args2.push(callback);
  4105            git2[fn].apply(git2, args2);
  4106          });
  4107        });
  4108      };
  4109    }
  4110    function syncWrapper(fn, git2, api) {
  4111      return (...args2) => {
  4112        git2[fn](...args2);
  4113        return api;
  4114      };
  4115    }
  4116  }
  4117  function toError(error) {
  4118    if (error instanceof Error) {
  4119      return error;
  4120    }
  4121    if (typeof error === "string") {
  4122      return new Error(error);
  4123    }
  4124    return new GitResponseError(error);
  4125  }
  4126  
  4127  // src/esm.mjs
  4128  var simpleGit = gitInstanceFactory;
  4129  var esm_default = gitInstanceFactory;
  4130  export {
  4131    CheckRepoActions,
  4132    CleanOptions,
  4133    GitConfigScope,
  4134    GitConstructError,
  4135    GitError,
  4136    GitPluginError,
  4137    GitResponseError,
  4138    ResetMode,
  4139    TaskConfigurationError,
  4140    esm_default as default,
  4141    gitP,
  4142    grepQueryBuilder,
  4143    pathspec,
  4144    simpleGit
  4145  };
  4146  //# sourceMappingURL=index.js.map