shadow-claw 1.31.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.well-known/mcp/server-card.json +1 -1
- package/.well-known/mcp.json +1 -1
- package/dist/lib/components/index.js +21 -21
- package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/settings/shadow-claw-git.js +1 -1
- package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
- package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
- package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
- package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/shadow-claw-channels.js +1 -1
- package/dist/lib/components/shadow-claw-chat.js +1 -1
- package/dist/lib/components/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/shadow-claw-conversations.js +1 -1
- package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
- package/dist/lib/components/shadow-claw-files.js +1 -1
- package/dist/lib/components/shadow-claw-git.js +1 -1
- package/dist/lib/components/shadow-claw-llm.js +1 -1
- package/dist/lib/components/shadow-claw-networking.js +1 -1
- package/dist/lib/components/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/shadow-claw-pages.js +1 -1
- package/dist/lib/components/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/shadow-claw-settings.js +1 -1
- package/dist/lib/components/shadow-claw-storage.js +1 -1
- package/dist/lib/components/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/shadow-claw-tasks.js +1 -1
- package/dist/lib/components/shadow-claw-terminal.js +1 -1
- package/dist/lib/components/shadow-claw-tools.js +1 -1
- package/dist/lib/components/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw.js +1 -1
- package/dist/lib/{configurePeerJs-u7CYSquX.js → configurePeerJs-DD3G3Pms.js} +2 -2
- package/dist/lib/{configurePeerJs-u7CYSquX.js.map → configurePeerJs-DD3G3Pms.js.map} +1 -1
- package/dist/lib/{git-DAP_EV6R.js → git-Brr7JIbs.js} +25 -8
- package/dist/lib/{git-DAP_EV6R.js.map → git-Brr7JIbs.js.map} +1 -1
- package/dist/lib/index.js +21 -21
- package/dist/lib/{initControlPlane-DCK_SHeR.js → initControlPlane-3TUdhRBM.js} +7 -7
- package/dist/lib/{initControlPlane-DCK_SHeR.js.map → initControlPlane-3TUdhRBM.js.map} +1 -1
- package/dist/lib/{orchestrator-XygttQw2.js → orchestrator-DLnCmeTZ.js} +5 -5
- package/dist/lib/{orchestrator-XygttQw2.js.map → orchestrator-DLnCmeTZ.js.map} +1 -1
- package/dist/lib/{orchestrator-DNamnY-k.js → orchestrator-DW5l2bbW.js} +22 -4
- package/dist/lib/{orchestrator-DNamnY-k.js.map → orchestrator-DW5l2bbW.js.map} +1 -1
- package/dist/lib/{peerjs-BgkPSHKa.js → peerjs-BXlMuIQn.js} +3 -3
- package/dist/lib/{peerjs-BgkPSHKa.js.map → peerjs-BXlMuIQn.js.map} +1 -1
- package/dist/lib/{push-client-C09NQEk5.js → push-client-B419nn-i.js} +2 -2
- package/dist/lib/{push-client-C09NQEk5.js.map → push-client-B419nn-i.js.map} +1 -1
- package/dist/lib/{shadow-claw-vzcggiax.js → shadow-claw-DmMO4vVG.js} +4 -4
- package/dist/lib/{shadow-claw-vzcggiax.js.map → shadow-claw-DmMO4vVG.js.map} +1 -1
- package/dist/lib/{shadow-claw-channel-config-Cl3JvxIJ.js → shadow-claw-channel-config-BhxHf6wZ.js} +3 -3
- package/dist/lib/{shadow-claw-channel-config-Cl3JvxIJ.js.map → shadow-claw-channel-config-BhxHf6wZ.js.map} +1 -1
- package/dist/lib/{shadow-claw-channels-kv21lr_O.js → shadow-claw-channels-B5vzE9Z2.js} +2 -2
- package/dist/lib/{shadow-claw-channels-kv21lr_O.js.map → shadow-claw-channels-B5vzE9Z2.js.map} +1 -1
- package/dist/lib/{shadow-claw-chat-Cj1fHQIl.js → shadow-claw-chat-BsYnJ4-G.js} +3 -3
- package/dist/lib/{shadow-claw-chat-Cj1fHQIl.js.map → shadow-claw-chat-BsYnJ4-G.js.map} +1 -1
- package/dist/lib/{shadow-claw-control-plane-DySeKB36.js → shadow-claw-control-plane-DqcgQsun.js} +6 -6
- package/dist/lib/{shadow-claw-control-plane-DySeKB36.js.map → shadow-claw-control-plane-DqcgQsun.js.map} +1 -1
- package/dist/lib/{shadow-claw-conversations-DghueOOD.js → shadow-claw-conversations-B9Pn58g3.js} +2 -2
- package/dist/lib/{shadow-claw-conversations-DghueOOD.js.map → shadow-claw-conversations-B9Pn58g3.js.map} +1 -1
- package/dist/lib/{shadow-claw-file-viewer-C_ITv8T6.js → shadow-claw-file-viewer-DL6c4oPK.js} +2 -2
- package/dist/lib/{shadow-claw-file-viewer-C_ITv8T6.js.map → shadow-claw-file-viewer-DL6c4oPK.js.map} +1 -1
- package/dist/lib/{shadow-claw-files-CWBaYt9p.js → shadow-claw-files-C_ksPb8W.js} +2 -2
- package/dist/lib/{shadow-claw-files-CWBaYt9p.js.map → shadow-claw-files-C_ksPb8W.js.map} +1 -1
- package/dist/lib/{shadow-claw-git-XfPBpfXd.js → shadow-claw-git-jwsY7L1N.js} +3 -3
- package/dist/lib/{shadow-claw-git-XfPBpfXd.js.map → shadow-claw-git-jwsY7L1N.js.map} +1 -1
- package/dist/lib/{shadow-claw-llm-Gzx4ufL_.js → shadow-claw-llm-CEPJh1Jh.js} +2 -2
- package/dist/lib/{shadow-claw-llm-Gzx4ufL_.js.map → shadow-claw-llm-CEPJh1Jh.js.map} +1 -1
- package/dist/lib/{shadow-claw-networking-CYEbc5TR.js → shadow-claw-networking-Bi4yvc73.js} +2 -2
- package/dist/lib/{shadow-claw-networking-CYEbc5TR.js.map → shadow-claw-networking-Bi4yvc73.js.map} +1 -1
- package/dist/lib/{shadow-claw-notifications-DHvkTrgv.js → shadow-claw-notifications-C-JgGqQx.js} +2 -2
- package/dist/lib/{shadow-claw-notifications-DHvkTrgv.js.map → shadow-claw-notifications-C-JgGqQx.js.map} +1 -1
- package/dist/lib/{shadow-claw-pages-Bj3w3V6Y.js → shadow-claw-pages-OEOClgA8.js} +2 -2
- package/dist/lib/{shadow-claw-pages-Bj3w3V6Y.js.map → shadow-claw-pages-OEOClgA8.js.map} +1 -1
- package/dist/lib/{shadow-claw-peerjs-B3sx2xLA.js → shadow-claw-peerjs-DmC2CV-9.js} +3 -3
- package/dist/lib/{shadow-claw-peerjs-B3sx2xLA.js.map → shadow-claw-peerjs-DmC2CV-9.js.map} +1 -1
- package/dist/lib/{shadow-claw-settings-DK-0kp3A.js → shadow-claw-settings-xAtFog0T.js} +2 -2
- package/dist/lib/{shadow-claw-settings-DK-0kp3A.js.map → shadow-claw-settings-xAtFog0T.js.map} +1 -1
- package/dist/lib/{shadow-claw-storage-p9nVMQPF.js → shadow-claw-storage-B4UHl-po.js} +2 -2
- package/dist/lib/{shadow-claw-storage-p9nVMQPF.js.map → shadow-claw-storage-B4UHl-po.js.map} +1 -1
- package/dist/lib/{shadow-claw-task-server-BNKCWG2M.js → shadow-claw-task-server-B0eWzg57.js} +2 -2
- package/dist/lib/{shadow-claw-task-server-BNKCWG2M.js.map → shadow-claw-task-server-B0eWzg57.js.map} +1 -1
- package/dist/lib/{shadow-claw-tasks-Dbq9rUku.js → shadow-claw-tasks-HHU_8Gyg.js} +2 -2
- package/dist/lib/{shadow-claw-tasks-Dbq9rUku.js.map → shadow-claw-tasks-HHU_8Gyg.js.map} +1 -1
- package/dist/lib/{shadow-claw-terminal-Wk2qRWJ9.js → shadow-claw-terminal-CdC2G6Zz.js} +2 -2
- package/dist/lib/{shadow-claw-terminal-Wk2qRWJ9.js.map → shadow-claw-terminal-CdC2G6Zz.js.map} +1 -1
- package/dist/lib/{shadow-claw-tools-C9TEf2k7.js → shadow-claw-tools-2AICxVXA.js} +3 -3
- package/dist/lib/{shadow-claw-tools-C9TEf2k7.js.map → shadow-claw-tools-2AICxVXA.js.map} +1 -1
- package/dist/lib/{shadow-claw-webvm-VoKerWW8.js → shadow-claw-webvm-Cy-Ia2vs.js} +2 -2
- package/dist/lib/{shadow-claw-webvm-VoKerWW8.js.map → shadow-claw-webvm-Cy-Ia2vs.js.map} +1 -1
- package/dist/lib/subsystems/git/git.d.ts +8 -1
- package/dist/lib/subsystems/git/types.d.ts +7 -1
- package/dist/lib/{syncWebMcpRegistration-DEs4JjI_.js → syncWebMcpRegistration-CaAPPg2V.js} +2 -2
- package/dist/lib/{syncWebMcpRegistration-DEs4JjI_.js.map → syncWebMcpRegistration-CaAPPg2V.js.map} +1 -1
- package/dist/public/.well-known/mcp/server-card.json +1 -1
- package/dist/public/.well-known/mcp.json +1 -1
- package/dist/public/agent.worker.js +2 -2
- package/dist/public/{configurePeerJs-B68egTBd.js → configurePeerJs--JGpJVti.js} +1 -1
- package/dist/public/docs/example/article/index.html +1 -1
- package/dist/public/docs/publishing/index.html +1 -1
- package/dist/public/docs/skill-creator/index.html +1 -1
- package/dist/public/{e2e-bridge-DQ4Mb_eC.js → e2e-bridge-CbYqdMp-.js} +1 -1
- package/dist/public/{file-viewer-BqNHyqzy.js → file-viewer-vHJ5Zsgk.js} +1 -1
- package/dist/public/git-8F7wvoUB.js +100 -0
- package/dist/public/git-DgFF7xTW.js +100 -0
- package/dist/public/index.html +1 -1
- package/dist/public/index.js +1 -1
- package/dist/public/{initControlPlane-DG_LcLDy.js → initControlPlane-C5v0FtJE.js} +1 -1
- package/dist/public/main/index.html +1 -1
- package/dist/public/main/memory/index.html +1 -1
- package/dist/public/{orchestrator-DAJkyJmV.js → orchestrator-BeJfwtvz.js} +3 -3
- package/dist/public/{orchestrator-BXwxW4N2.js → orchestrator-DNr2HDI2.js} +1 -1
- package/dist/public/{peerjs-BaDbzfgl.js → peerjs-mG30TAJ_.js} +1 -1
- package/dist/public/{push-client-B1CCaldJ.js → push-client-C2zMT3Sf.js} +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/{shadow-claw-CpBmveOh.js → shadow-claw-Ble6l0Iw.js} +2 -2
- package/dist/public/{shadow-claw-channels-7Oew09u0.js → shadow-claw-channels-D_xfBoWp.js} +1 -1
- package/dist/public/{shadow-claw-chat-CskwjDzZ.js → shadow-claw-chat-D_Lbi5oH.js} +1 -1
- package/dist/public/{shadow-claw-control-plane-BqjEyhx7.js → shadow-claw-control-plane-CrnA5lM0.js} +2 -2
- package/dist/public/{shadow-claw-conversations-ClGgBPVY.js → shadow-claw-conversations-BN-hFmN1.js} +1 -1
- package/dist/public/{shadow-claw-file-viewer-rDepUwFJ.js → shadow-claw-file-viewer-BKEpzpbx.js} +1 -1
- package/dist/public/{shadow-claw-files-C0r05PYf.js → shadow-claw-files-DDZMk5AA.js} +1 -1
- package/dist/public/{shadow-claw-git-CXrECHKy.js → shadow-claw-git-CqOO97Re.js} +2 -2
- package/dist/public/{shadow-claw-llm-jeGVNciG.js → shadow-claw-llm-DoGxEHQL.js} +1 -1
- package/dist/public/{shadow-claw-networking--q6MgEAT.js → shadow-claw-networking-DJeCdb7e.js} +1 -1
- package/dist/public/{shadow-claw-notifications-CrFUF0fl.js → shadow-claw-notifications-hSKJeMXb.js} +1 -1
- package/dist/public/{shadow-claw-pages-_n1wVXAV.js → shadow-claw-pages-DTS98Zbi.js} +1 -1
- package/dist/public/{shadow-claw-settings-5yIfa3ie.js → shadow-claw-settings-5w0ce8SP.js} +2 -2
- package/dist/public/{shadow-claw-storage-PLX9EFGn.js → shadow-claw-storage-DqlVt27X.js} +1 -1
- package/dist/public/{shadow-claw-task-server-BMps7aSr.js → shadow-claw-task-server-ByZwKI6S.js} +1 -1
- package/dist/public/{shadow-claw-tasks-CHO1xvsu.js → shadow-claw-tasks-Dc4G4zBu.js} +1 -1
- package/dist/public/{shadow-claw-terminal-BJnSXRsb.js → shadow-claw-terminal-DvusP7wg.js} +1 -1
- package/dist/public/{shadow-claw-tools-BHfxRckC.js → shadow-claw-tools-BEsid8q-.js} +1 -1
- package/dist/public/{shadow-claw-webvm-CyI23mQT.js → shadow-claw-webvm-BWlIeK78.js} +1 -1
- package/dist/public/{syncWebMcpRegistration-R0tha3kP.js → syncWebMcpRegistration-CqVCB6m8.js} +1 -1
- package/package.json +1 -1
- package/src/storage/staticMainSite.ts +16 -2
- package/src/stores/orchestrator.test.ts +33 -0
- package/src/stores/orchestrator.ts +36 -0
- package/src/subsystems/git/git.test.ts +99 -0
- package/src/subsystems/git/git.ts +92 -12
- package/src/subsystems/git/types.ts +7 -0
- package/dist/public/git-BDaM5VT5.js +0 -100
- package/dist/public/git-D4n46G9B.js +0 -100
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r}from"./config-Bnwx4EfS.js";import{t as i}from"./browser-nBz_r6l4.js";import{t as a}from"./buffer-9oRIc-5Z.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./constants-BR3kgTKA.js";import{n as f,t as p}from"./crypto-browserify-U1v0eryt.js";var m=t(((t,n)=>{var r=e(i()),a=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(r.default===void 0||r.default.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||a.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||a.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||a.DEFAULT_MAX_EXECUTION_TIME,e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?this.maxPending=e.maxPending:this.maxPending=a.DEFAULT_MAX_PENDING};a.DEFAULT_TIMEOUT=0,a.DEFAULT_MAX_OCCUPATION_TIME=0,a.DEFAULT_MAX_EXECUTION_TIME=0,a.DEFAULT_MAX_PENDING=1e3,a.prototype.acquire=function(e,t,n,i){if(Array.isArray(e))return this._acquireBatch(e,t,n,i);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var a=null,o=null,s=null;typeof n!=`function`&&(i=n,n=null,s=new this.Promise(function(e,t){a=e,o=t})),i||={};var c=!1,l=null,u=null,d=null,f=this,p=function(t,r,i){u&&=(clearTimeout(u),null),d&&=(clearTimeout(d),null),t&&(f.queues[e]&&f.queues[e].length===0&&delete f.queues[e],f.domainReentrant&&delete f.domains[e]),c||=(s?r?o(r):a(i):typeof n==`function`&&n(r,i),!0),t&&f.queues[e]&&f.queues[e].length>0&&f.queues[e].shift()()},m=function(n){if(c)return p(n);l&&=(clearTimeout(l),null),f.domainReentrant&&n&&(f.domains[e]=r.default.domain);var a=i.maxExecutionTime||f.maxExecutionTime;if(a&&(d=setTimeout(function(){f.queues[e]&&p(n,Error(`Maximum execution time is exceeded `+e))},a)),t.length===1){var o=!1;try{t(function(e,t){o||(o=!0,p(n,e,t))})}catch(e){o||(o=!0,p(n,e))}}else f._promiseTry(function(){return t()}).then(function(e){p(n,void 0,e)},function(e){p(n,e)})};f.domainReentrant&&r.default.domain&&(m=r.default.domain.bind(m));var h=i.maxPending||f.maxPending;if(!f.queues[e])f.queues[e]=[],m(!0);else if(f.domainReentrant&&r.default.domain&&r.default.domain===f.domains[e])m(!1);else if(f.queues[e].length>=h)p(!1,Error(`Too many pending tasks in queue `+e));else{var g=function(){m(!0)};i.skipQueue?f.queues[e].unshift(g):f.queues[e].push(g);var _=i.timeout||f.timeout;_&&(l=setTimeout(function(){l=null,p(!1,Error(`async-lock timed out in queue `+e))},_))}var v=i.maxOccupationTime||f.maxOccupationTime;if(v&&(u=setTimeout(function(){f.queues[e]&&p(!1,Error(`Maximum occupation time is exceeded in queue `+e))},v)),s)return s},a.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},a.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},a.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},n.exports=a})),h=t(((e,t)=>{t.exports=m()})),g=t((e=>{
|
|
2
|
-
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
|
|
3
|
-
(function(t){typeof DO_NOT_EXPORT_CRC>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`1.2.2`;function t(){for(var e=0,t=Array(256),n=0;n!=256;++n)e=n,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,t[n]=e;return typeof Int32Array<`u`?new Int32Array(t):t}var n=t();function r(e){var t=0,n=0,r=0,i=typeof Int32Array<`u`?new Int32Array(4096):Array(4096);for(r=0;r!=256;++r)i[r]=e[r];for(r=0;r!=256;++r)for(n=e[r],t=256+r;t<4096;t+=256)n=i[t]=n>>>8^e[n&255];var a=[];for(r=1;r!=16;++r)a[r-1]=typeof Int32Array<`u`?i.subarray(r*256,r*256+256):i.slice(r*256,r*256+256);return a}var i=r(n),a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14];function b(e,t){for(var r=t^-1,i=0,a=e.length;i<a;)r=r>>>8^n[(r^e.charCodeAt(i++))&255];return~r}function x(e,t){for(var r=t^-1,i=e.length-15,b=0;b<i;)r=y[e[b++]^r&255]^v[e[b++]^r>>8&255]^_[e[b++]^r>>16&255]^g[e[b++]^r>>>24]^h[e[b++]]^m[e[b++]]^p[e[b++]]^f[e[b++]]^d[e[b++]]^u[e[b++]]^l[e[b++]]^c[e[b++]]^s[e[b++]]^o[e[b++]]^a[e[b++]]^n[e[b++]];for(i+=15;b<i;)r=r>>>8^n[(r^e[b++])&255];return~r}function S(e,t){for(var r=t^-1,i=0,a=e.length,o=0,s=0;i<a;)o=e.charCodeAt(i++),o<128?r=r>>>8^n[(r^o)&255]:o<2048?(r=r>>>8^n[(r^(192|o>>6&31))&255],r=r>>>8^n[(r^(128|o&63))&255]):o>=55296&&o<57344?(o=(o&1023)+64,s=e.charCodeAt(i++)&1023,r=r>>>8^n[(r^(240|o>>8&7))&255],r=r>>>8^n[(r^(128|o>>2&63))&255],r=r>>>8^n[(r^(128|s>>6&15|(o&3)<<4))&255],r=r>>>8^n[(r^(128|s&63))&255]):(r=r>>>8^n[(r^(224|o>>12&15))&255],r=r>>>8^n[(r^(128|o>>6&63))&255],r=r>>>8^n[(r^(128|o&63))&255]);return~r}e.table=n,e.bstr=b,e.buf=x,e.str=S})})),_=t((e=>{var t=o(),n=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch{n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{r=!1}for(var i=new t.Buf8(256),a=0;a<256;a++)i[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;i[254]=i[254]=1,e.string2buf=function(e){var n,r,i,a,o,s=e.length,c=0;for(a=0;a<s;a++)r=e.charCodeAt(a),(r&64512)==55296&&a+1<s&&(i=e.charCodeAt(a+1),(i&64512)==56320&&(r=65536+(r-55296<<10)+(i-56320),a++)),c+=r<128?1:r<2048?2:r<65536?3:4;for(n=new t.Buf8(c),o=0,a=0;o<c;a++)r=e.charCodeAt(a),(r&64512)==55296&&a+1<s&&(i=e.charCodeAt(a+1),(i&64512)==56320&&(r=65536+(r-55296<<10)+(i-56320),a++)),r<128?n[o++]=r:r<2048?(n[o++]=192|r>>>6,n[o++]=128|r&63):r<65536?(n[o++]=224|r>>>12,n[o++]=128|r>>>6&63,n[o++]=128|r&63):(n[o++]=240|r>>>18,n[o++]=128|r>>>12&63,n[o++]=128|r>>>6&63,n[o++]=128|r&63);return n};function s(e,i){if(i<65534&&(e.subarray&&r||!e.subarray&&n))return String.fromCharCode.apply(null,t.shrinkBuf(e,i));for(var a=``,o=0;o<i;o++)a+=String.fromCharCode(e[o]);return a}e.buf2binstring=function(e){return s(e,e.length)},e.binstring2buf=function(e){for(var n=new t.Buf8(e.length),r=0,i=n.length;r<i;r++)n[r]=e.charCodeAt(r);return n},e.buf2string=function(e,t){var n,r,a,o,c=t||e.length,l=Array(c*2);for(r=0,n=0;n<c;){if(a=e[n++],a<128){l[r++]=a;continue}if(o=i[a],o>4){l[r++]=65533,n+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&n<c;)a=a<<6|e[n++]&63,o--;if(o>1){l[r++]=65533;continue}a<65536?l[r++]=a:(a-=65536,l[r++]=55296|a>>10&1023,l[r++]=56320|a&1023)}return s(l,r)},e.utf8border=function(e,t){var n;for(t||=e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+i[e[n]]>t?n:t}})),v=t((e=>{var t=u(),n=o(),r=_(),i=s(),a=l(),c=Object.prototype.toString,d=0,f=4,p=0,m=1,h=2,g=-1,v=0,y=8;function b(e){if(!(this instanceof b))return new b(e);this.options=n.assign({level:g,method:y,chunkSize:16384,windowBits:15,memLevel:8,strategy:v,to:``},e||{});var o=this.options;o.raw&&o.windowBits>0?o.windowBits=-o.windowBits:o.gzip&&o.windowBits>0&&o.windowBits<16&&(o.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var s=t.deflateInit2(this.strm,o.level,o.method,o.windowBits,o.memLevel,o.strategy);if(s!==p)throw Error(i[s]);if(o.header&&t.deflateSetHeader(this.strm,o.header),o.dictionary){var l=typeof o.dictionary==`string`?r.string2buf(o.dictionary):c.call(o.dictionary)===`[object ArrayBuffer]`?new Uint8Array(o.dictionary):o.dictionary;if(s=t.deflateSetDictionary(this.strm,l),s!==p)throw Error(i[s]);this._dict_set=!0}}b.prototype.push=function(e,i){var a=this.strm,o=this.options.chunkSize,s,l;if(this.ended)return!1;l=i===~~i?i:i===!0?f:d,typeof e==`string`?a.input=r.string2buf(e):c.call(e)===`[object ArrayBuffer]`?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(a.avail_out===0&&(a.output=new n.Buf8(o),a.next_out=0,a.avail_out=o),s=t.deflate(a,l),s!==m&&s!==p)return this.onEnd(s),this.ended=!0,!1;(a.avail_out===0||a.avail_in===0&&(l===f||l===h))&&(this.options.to===`string`?this.onData(r.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||a.avail_out===0)&&s!==m);return l===f?(s=t.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===p):l===h?(this.onEnd(p),a.avail_out=0,!0):!0},b.prototype.onData=function(e){this.chunks.push(e)},b.prototype.onEnd=function(e){e===p&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function x(e,t){var n=new b(t);if(n.push(e,!0),n.err)throw n.msg||i[n.err];return n.result}function S(e,t){return t||={},t.raw=!0,x(e,t)}function C(e,t){return t||={},t.gzip=!0,x(e,t)}e.Deflate=b,e.deflate=x,e.deflateRaw=S,e.gzip=C})),y=t(((e,t)=>{function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}t.exports=n})),b=t((e=>{var t=c(),n=o(),r=_(),i=d(),a=s(),u=l(),f=y(),p=Object.prototype.toString;function m(e){if(!(this instanceof m))return new m(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:``},e||{});var o=this.options;o.raw&&o.windowBits>=0&&o.windowBits<16&&(o.windowBits=-o.windowBits,o.windowBits===0&&(o.windowBits=-15)),o.windowBits>=0&&o.windowBits<16&&!(e&&e.windowBits)&&(o.windowBits+=32),o.windowBits>15&&o.windowBits<48&&(o.windowBits&15||(o.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var s=t.inflateInit2(this.strm,o.windowBits);if(s!==i.Z_OK||(this.header=new f,t.inflateGetHeader(this.strm,this.header),o.dictionary&&(typeof o.dictionary==`string`?o.dictionary=r.string2buf(o.dictionary):p.call(o.dictionary)===`[object ArrayBuffer]`&&(o.dictionary=new Uint8Array(o.dictionary)),o.raw&&(s=t.inflateSetDictionary(this.strm,o.dictionary),s!==i.Z_OK))))throw Error(a[s])}m.prototype.push=function(e,a){var o=this.strm,s=this.options.chunkSize,c=this.options.dictionary,l,u,d,f,m,h=!1;if(this.ended)return!1;u=a===~~a?a:a===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof e==`string`?o.input=r.binstring2buf(e):p.call(e)===`[object ArrayBuffer]`?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(o.avail_out===0&&(o.output=new n.Buf8(s),o.next_out=0,o.avail_out=s),l=t.inflate(o,i.Z_NO_FLUSH),l===i.Z_NEED_DICT&&c&&(l=t.inflateSetDictionary(this.strm,c)),l===i.Z_BUF_ERROR&&h===!0&&(l=i.Z_OK,h=!1),l!==i.Z_STREAM_END&&l!==i.Z_OK)return this.onEnd(l),this.ended=!0,!1;o.next_out&&(o.avail_out===0||l===i.Z_STREAM_END||o.avail_in===0&&(u===i.Z_FINISH||u===i.Z_SYNC_FLUSH))&&(this.options.to===`string`?(d=r.utf8border(o.output,o.next_out),f=o.next_out-d,m=r.buf2string(o.output,d),o.next_out=f,o.avail_out=s-f,f&&n.arraySet(o.output,o.output,d,f,0),this.onData(m)):this.onData(n.shrinkBuf(o.output,o.next_out))),o.avail_in===0&&o.avail_out===0&&(h=!0)}while((o.avail_in>0||o.avail_out===0)&&l!==i.Z_STREAM_END);return l===i.Z_STREAM_END&&(u=i.Z_FINISH),u===i.Z_FINISH?(l=t.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,l===i.Z_OK):u===i.Z_SYNC_FLUSH?(this.onEnd(i.Z_OK),o.avail_out=0,!0):!0},m.prototype.onData=function(e){this.chunks.push(e)},m.prototype.onEnd=function(e){e===i.Z_OK&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function h(e,t){var n=new m(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}function g(e,t){return t||={},t.raw=!0,h(e,t)}e.Inflate=m,e.inflate=h,e.inflateRaw=g,e.ungzip=h})),x=t(((e,t)=>{var n=o().assign,r=v(),i=b(),a=d(),s={};n(s,r,i,a),t.exports=s})),S=t(((e,t)=>{let n=(e,t)=>function(...n){let r=t.promiseModule;return new r((r,i)=>{t.multiArgs?n.push((...e)=>{t.errorFirst?e[0]?i(e):(e.shift(),r(e)):r(e)}):t.errorFirst?n.push((e,t)=>{e?i(e):r(t)}):n.push(r),e.apply(this,n)})};t.exports=(e,t)=>{t=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},t);let r=typeof e;if(!(e!==null&&(r===`object`||r===`function`)))throw TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${e===null?`null`:r}\``);let i=e=>{let n=t=>typeof t==`string`?e===t:t.test(e);return t.include?t.include.some(n):!t.exclude.some(n)},a;a=r===`function`?function(...r){return t.excludeMain?e(...r):n(e,t).apply(this,r)}:Object.create(Object.getPrototypeOf(e));for(let r in e){let o=e[r];a[r]=typeof o==`function`&&i(r)?n(o,t):o}return a}})),C=t(((t,n)=>{var r=e(i());function a(e){return Array.isArray(e)?e:[e]}let o=/^\s+$/,s=/(?:[^\\]|^)\\$/,c=/^\\!/,l=/^\\#/,u=/\r?\n/g,d=/^\.*\/|^\.+$/,f=`node-ignore`;typeof Symbol<`u`&&(f=Symbol.for(`node-ignore`));let p=f,m=(e,t,n)=>Object.defineProperty(e,t,{value:n}),h=/([0-z])-([0-z])/g,g=()=>!1,_=e=>e.replace(h,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),v=e=>{let{length:t}=e;return e.slice(0,t-t%2)},y=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${v(r)}${i}`:i===`]`&&r.length%2==0?`[${_(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`]],b=Object.create(null),x=(e,t)=>{let n=b[e];return n||(n=y.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),b[e]=n),t?new RegExp(n,`i`):new RegExp(n)},S=e=>typeof e==`string`,C=e=>e&&S(e)&&!o.test(e)&&!s.test(e)&&e.indexOf(`#`)!==0,w=e=>e.split(u);var T=class{constructor(e,t,n,r){this.origin=e,this.pattern=t,this.negative=n,this.regex=r}};let ee=(e,t)=>{let n=e,r=!1;e.indexOf(`!`)===0&&(r=!0,e=e.substr(1)),e=e.replace(c,`!`).replace(l,`#`);let i=x(e,t);return new T(n,e,r,i)},E=(e,t)=>{throw new t(e)},D=(e,t,n)=>S(e)?e?!D.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),O=e=>d.test(e);D.isNotRelative=O,D.convert=e=>e;var k=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){m(this,p,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[p]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(C(e)){let t=ee(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,a(S(e)?w(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let n=!1,r=!1;return this._rules.forEach(i=>{let{negative:a}=i;r===a&&n!==r||a&&!n&&!r&&!t||i.regex.test(e)&&(n=!a,r=a)}),{ignored:n,unignored:r}}_test(e,t,n,r){let i=e&&D.convert(e);return D(i,e,this._allowRelativePaths?g:E),this._t(i,t,n,r)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`),r.pop(),!r.length)return t[e]=this._testOne(e,n);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return a(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let te=e=>new k(e);if(te.isPathValid=e=>D(e&&D.convert(e),e,g),te.default=te,n.exports=te,r.default!==void 0&&(r.default.env&&r.default.env.IGNORE_TEST_WIN32||r.default.platform===`win32`)){D.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;D.isNotRelative=t=>e.test(t)||O(t)}})),w=t(((e,t)=>{function n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function r(e,t,r){return t=t instanceof RegExp?t:new RegExp(n(t),`g`),e.replace(t,r)}t.exports={clean:function(e){if(typeof e!=`string`)throw Error(`Expected a string, received: `+e);return e=r(e,`./`,`/`),e=r(e,`..`,`.`),e=r(e,` `,`-`),e=r(e,/^[~^:?*\\\-]/g,``),e=r(e,/[~^:?*\\]/g,`-`),e=r(e,/[~^:?*\\\-]$/g,``),e=r(e,`@{`,`-`),e=r(e,/\.$/g,``),e=r(e,/\/$/g,``),e=r(e,/\.lock$/g,``),e}}})),T=t(((e,t)=>{t.exports=function(e,t){var n=e,r=t,i=n.length,a=r.length,o=!1,s=null,c=i+1,l=[],u=[],d=[],f=``,p=-1,m=0,h=1,g,_,v=function(){i>=a&&(g=n,_=i,n=r,r=g,i=a,a=_,o=!0,c=i+1)},y=function(e,t,n){return{x:e,y:t,k:n}},b=function(e,t){return{elem:e,t}},x=function(e,t,o){var s=t>o?l[e-1+c]:l[e+1+c],d,f=Math.max(t,o);for(d=f-e;d<i&&f<a&&n[d]===r[f];)++d,++f;return l[e+c]=u.length,u[u.length]=new y(d,f,s),f},S=function(e){var t=i=1,i,a=s=0,s,c;for(c=e.length-1;c>=0;--c)for(;a<e[c].x||s<e[c].y;)e[c].y-e[c].x>s-a?(o?d[d.length]=new b(r[s],p):d[d.length]=new b(r[s],h),++i,++s):e[c].y-e[c].x<s-a?(o?d[d.length]=new b(n[a],h):d[d.length]=new b(n[a],p),++t,++a):(d[d.length]=new b(n[a],m),f+=n[a],++t,++i,++a,++s)};return v(),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:function(){return s},getlcs:function(){return f},getses:function(){return d},compose:function(){var e=a-i,t=i+a+3,n={},r,o,d,f,p;for(f=0;f<t;++f)n[f]=-1,l[f]=-1;r=-1;do{for(++r,p=-r;p<=e-1;++p)n[p+c]=x(p,n[p-1+c]+1,n[p+1+c]);for(p=e+r;p>=e+1;--p)n[p+c]=x(p,n[p-1+c]+1,n[p+1+c]);n[e+c]=x(e,n[e-1+c]+1,n[e+1+c])}while(n[e+c]!==a);for(s=e+2*r,o=l[e+c],d=[];o!==-1;)d[d.length]=new y(u[o].x,u[o].y,null),o=u[o].k;S(d)}}}})),ee=t(((e,t)=>{var n=T();function r(e,t){var r=new n(e,t);r.compose();for(var i=r.getses(),a,o,s=e.length-1,c=t.length-1,l=i.length-1;l>=0;--l)i[l].t===r.SES_COMMON?(o?(o.chain={file1index:s,file2index:c,chain:null},o=o.chain):(a={file1index:s,file2index:c,chain:null},o=a),s--,c--):i[l].t===r.SES_DELETE?s--:i[l].t===r.SES_ADD&&c--;var u={file1index:-1,file2index:-1,chain:null};return o?(o.chain=u,a):u}function i(e,t){for(var n=[],i=e.length,a=t.length,o=r(e,t);o!==null;o=o.chain){var s=i-o.file1index-1,c=a-o.file2index-1;i=o.file1index,a=o.file2index,(s||c)&&n.push({file1:[i+1,s],file2:[a+1,c]})}return n.reverse(),n}function a(e,t,n){var r,a=i(t,e),o=i(t,n),s=[];function c(e,t){s.push([e.file1[0],t,e.file1[1],e.file2[0],e.file2[1]])}for(r=0;r<a.length;r++)c(a[r],0);for(r=0;r<o.length;r++)c(o[r],2);s.sort(function(e,t){return e[0]-t[0]});var l=[],u=0;function d(e){e>u&&(l.push([1,u,e-u]),u=e)}for(var f=0;f<s.length;f++){for(var p=f,m=s[f],h=m[0],g=h+m[2];f<s.length-1;){var _=s[f+1],v=_[0];if(v>g)break;g=Math.max(g,v+_[2]),f++}if(d(h),p==f)m[4]>0&&l.push([m[1],m[3],m[4]]);else{var y={0:[e.length,-1,t.length,-1],2:[n.length,-1,t.length,-1]};for(r=p;r<=f;r++){m=s[r];var b=y[m[1]],x=m[0],S=x+m[2],C=m[3],w=C+m[4];b[0]=Math.min(C,b[0]),b[1]=Math.max(w,b[1]),b[2]=Math.min(x,b[2]),b[3]=Math.max(S,b[3])}var T=y[0][0]+(h-y[0][2]),ee=y[0][1]+(g-y[0][3]),E=y[2][0]+(h-y[2][2]),D=y[2][1]+(g-y[2][3]);l.push([-1,T,ee-T,h,g-h,E,D-E])}u=g}return d(t.length),l}function o(e,t,n){var r=[],i=[e,t,n],o=a(e,t,n),s=[];function c(){s.length&&r.push({ok:s}),s=[]}function l(e){for(var t=0;t<e.length;t++)s.push(e[t])}function u(t){if(t[2]!=t[6])return!0;for(var r=t[1],i=t[5],a=0;a<t[2];a++)if(e[a+r]!=n[a+i])return!0;return!1}for(var d=0;d<o.length;d++){var f=o[d],p=f[0];p==-1?u(f)?(c(),r.push({conflict:{a:e.slice(f[1],f[1]+f[2]),aIndex:f[1],o:t.slice(f[3],f[3]+f[4]),oIndex:f[3],b:n.slice(f[5],f[5]+f[6]),bIndex:f[5]}})):l(i[0].slice(f[1],f[1]+f[2])):l(i[p].slice(f[1],f[1]+f[2]))}return c(),r}t.exports=o})),E=e(t((t=>{var n=e(i()),r=a();Object.defineProperty(t,"__esModule",{value:!0});function o(e){return e&&typeof e==`object`&&`default`in e?e.default:e}var s=o(h()),c=o(f()),l=o(g()),u=o(x()),d=p(),m=o(S()),_=o(C()),v=o(w()),y=o(ee()),b=class e extends Error{constructor(e){super(e),this.caller=``}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){let n=new e(t.message);return n.code=t.code,n.data=t.data,n.caller=t.caller,n.stack=t.stack,n}get isIsomorphicGitError(){return!0}},T=class e extends b{constructor(t){super(`Modifying the index is not possible because you have unmerged files: ${t.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=e.code,this.data={filepaths:t}}};T.code=`UnmergedPathsError`;var E=class e extends b{constructor(t){super(`An internal error caused this command to fail.\n\nIf you're not a developer, report the bug to the developers of the application you're using. If this is a bug in isomorphic-git then you should create a proper bug yourselves. The bug should include a minimal reproduction and details about the version and environment.\n\nPlease file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=e.code,this.data={message:t}}};E.code=`InternalError`;var D=class e extends b{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=e.code,this.data={filepath:t}}};D.code=`UnsafeFilepathError`;var O=class{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){let t=this.buffer.slice(this._start,this._start+e);return this._start+=e,t}toString(e,t){let n=this.buffer.toString(e,this._start,this._start+t);return this._start+=t,n}write(e,t,n){let r=this.buffer.write(e,this._start,t,n);return this._start+=t,r}copy(e,t,n){let r=e.copy(this.buffer,this._start,t,n);return this._start+=r,r}readUInt8(){let e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){let t=this.buffer.writeUInt8(e,this._start);return this._start+=1,t}readUInt16BE(){let e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){let t=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,t}readUInt32BE(){let e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){let t=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,t}};function k(e,t){return-(e<t)||+(e>t)}function te(e,t){return k(e.path,t.path)}function A(e){let t=e>0?e>>12:0;t!==4&&t!==8&&t!==10&&t!==14&&(t=8);let n=e&511;return n=n&73?493:420,t!==8&&(n=0),(t<<12)+n}let j=2**32;function M(e,t,n,r){if(e!==void 0&&t!==void 0)return[e,t];n===void 0&&(n=r.valueOf());let i=Math.floor(n/1e3);return[i,(n-i*1e3)*1e6]}function ne(e){let[t,n]=M(e.ctimeSeconds,e.ctimeNanoseconds,e.ctimeMs,e.ctime),[r,i]=M(e.mtimeSeconds,e.mtimeNanoseconds,e.mtimeMs,e.mtime);return{ctimeSeconds:t%j,ctimeNanoseconds:n%j,mtimeSeconds:r%j,mtimeNanoseconds:i%j,dev:e.dev%j,ino:e.ino%j,mode:A(e.mode%j),uid:e.uid%j,gid:e.gid%j,size:e.size>-1?e.size%j:0}}function re(e){let t=``;for(let n of new Uint8Array(e))n<16&&(t+=`0`),t+=n.toString(16);return t}let ie=null;async function N(e){return ie===null&&(ie=await se()),ie?oe(e):ae(e)}function ae(e){return new c().update(e).digest(`hex`)}async function oe(e){return re(await crypto.subtle.digest(`SHA-1`,e))}async function se(){try{return await oe(new Uint8Array([]))===`da39a3ee5e6b4b0d3255bfef95601890afd80709`}catch{}return!1}function ce(e){return{assumeValid:!!(e&32768),extended:!!(e&16384),stage:(e&12288)>>12,nameLength:e&4095}}function le(e){let t=e.flags;return t.extended=!1,t.nameLength=Math.min(r.Buffer.from(e.path).length,4095),(t.assumeValid?32768:0)+(t.extended?16384:0)+((t.stage&3)<<12)+(t.nameLength&4095)}var P=class e{constructor(e,t){this._dirty=!1,this._unmergedPaths=t||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let t=this._entries.get(e.path);t||=(this._entries.set(e.path,e),e),t.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(t){if(r.Buffer.isBuffer(t))return e.fromBuffer(t);if(t===null)return new e(null);throw new E(`invalid type passed to GitIndex.from`)}static async fromBuffer(t){if(t.length===0)throw new E(`Index file is empty (.git/index)`);let n=new e,r=new O(t),i=r.toString(`utf8`,4);if(i!==`DIRC`)throw new E(`Invalid dircache magic file number: ${i}`);let a=await N(t.slice(0,-20)),o=t.slice(-20).toString(`hex`);if(o!==a)throw new E(`Invalid checksum in GitIndex buffer: expected ${o} but saw ${a}`);let s=r.readUInt32BE();if(s!==2)throw new E(`Unsupported dircache version: ${s}`);let c=r.readUInt32BE(),l=0;for(;!r.eof()&&l<c;){let e={};e.ctimeSeconds=r.readUInt32BE(),e.ctimeNanoseconds=r.readUInt32BE(),e.mtimeSeconds=r.readUInt32BE(),e.mtimeNanoseconds=r.readUInt32BE(),e.dev=r.readUInt32BE(),e.ino=r.readUInt32BE(),e.mode=r.readUInt32BE(),e.uid=r.readUInt32BE(),e.gid=r.readUInt32BE(),e.size=r.readUInt32BE(),e.oid=r.slice(20).toString(`hex`),e.flags=ce(r.readUInt16BE());let i=t.indexOf(0,r.tell()+1)-r.tell();if(i<1)throw new E(`Got a path length of: ${i}`);if(e.path=r.toString(`utf8`,i),e.path.includes(`..\\`)||e.path.includes(`../`))throw new D(e.path);let a=8-(r.tell()-12)%8;for(a===0&&(a=8);a--;){let t=r.readUInt8();if(t!==0)throw new E(`Expected 1-8 null characters but got '${t}' after ${e.path}`);if(r.eof())throw new E(`Unexpected end of file`)}e.stages=[],n._addEntry(e),l++}return n}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(te)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(e=>e.stages.length>1?e.stages.filter(e=>e):e)}*[Symbol.iterator](){for(let e of this.entries)yield e}insert({filepath:e,stats:t,oid:n,stage:i=0}){t||={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0},t=ne(t);let a=r.Buffer.from(e),o={ctimeSeconds:t.ctimeSeconds,ctimeNanoseconds:t.ctimeNanoseconds,mtimeSeconds:t.mtimeSeconds,mtimeNanoseconds:t.mtimeNanoseconds,dev:t.dev,ino:t.ino,mode:t.mode||33188,uid:t.uid,gid:t.gid,size:t.size,path:e,oid:n,flags:{assumeValid:!1,extended:!1,stage:i,nameLength:a.length<4095?a.length:4095},stages:[]};this._addEntry(o),this._dirty=!0}delete({filepath:e}){if(this._entries.has(e))this._entries.delete(e);else for(let t of this._entries.keys())t.startsWith(e+`/`)&&this._entries.delete(t);this._unmergedPaths.has(e)&&this._unmergedPaths.delete(e),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:e}){return this._entries.has(e)}render(){return this.entries.map(e=>`${e.mode.toString(8)} ${e.oid} ${e.path}`).join(`
|
|
4
|
-
`)}static async _entryToBuffer(e){let t=r.Buffer.from(e.path),n=Math.ceil((62+t.length+1)/8)*8,i=r.Buffer.alloc(n),a=new O(i),o=ne(e);return a.writeUInt32BE(o.ctimeSeconds),a.writeUInt32BE(o.ctimeNanoseconds),a.writeUInt32BE(o.mtimeSeconds),a.writeUInt32BE(o.mtimeNanoseconds),a.writeUInt32BE(o.dev),a.writeUInt32BE(o.ino),a.writeUInt32BE(o.mode),a.writeUInt32BE(o.uid),a.writeUInt32BE(o.gid),a.writeUInt32BE(o.size),a.write(e.oid,20,`hex`),a.writeUInt16BE(le(e)),a.write(e.path,t.length,`utf8`),i}async toObject(){let t=r.Buffer.alloc(12),n=new O(t);n.write(`DIRC`,4,`utf8`),n.writeUInt32BE(2),n.writeUInt32BE(this.entriesFlat.length);let i=[];for(let t of this.entries)if(i.push(e._entryToBuffer(t)),t.stages.length>1)for(let n of t.stages)n&&n!==t&&i.push(e._entryToBuffer(n));i=await Promise.all(i);let a=r.Buffer.concat(i),o=r.Buffer.concat([t,a]),s=await N(o);return r.Buffer.concat([o,r.Buffer.from(s,`hex`)])}};function F(e,t,n=!0,r=!0){let i=ne(e),a=ne(t);return n&&i.mode!==a.mode||i.mtimeSeconds!==a.mtimeSeconds||i.ctimeSeconds!==a.ctimeSeconds||i.uid!==a.uid||i.gid!==a.gid||r&&i.ino!==a.ino||i.size!==a.size}let ue=null,I=Symbol(`IndexCache`);function de(){return{map:new Map,stats:new Map}}async function fe(e,t,n){let[r,i]=await Promise.all([e.lstat(t),e.read(t)]),a=await P.from(i);n.map.set(t,a),n.stats.set(t,r)}async function L(e,t,n){let r=n.stats.get(t);if(r===void 0)return!0;if(r===null)return!1;let i=await e.lstat(t);return i!==null&&F(r,i)}var R=class{static async acquire({fs:e,gitdir:t,cache:n,allowUnmerged:r=!0},i){n[I]||(n[I]=de());let a=`${t}/index`;ue===null&&(ue=new s({maxPending:1/0}));let o,c=[];return await ue.acquire(a,async()=>{let t=n[I];await L(e,a,t)&&await fe(e,a,t);let s=t.map.get(a);if(c=s.unmergedPaths,c.length&&!r)throw new T(c);if(o=await i(s),s._dirty){let n=await s.toObject();await e.write(a,n),t.stats.set(a,await e.lstat(a)),s._dirty=!1}}),o}};function pe(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>-1&&(e=e.slice(t+1)),e}function z(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t===-1?`.`:t===0?`/`:e.slice(0,t)}function me(e){let t=new Map,n=function(e){if(!t.has(e)){let r={type:`tree`,fullpath:e,basename:pe(e),metadata:{},children:[]};t.set(e,r),r.parent=n(z(e)),r.parent&&r.parent!==r&&r.parent.children.push(r)}return t.get(e)},r=function(e,r){if(!t.has(e)){let i={type:`blob`,fullpath:e,basename:pe(e),metadata:r,parent:n(z(e)),children:[]};i.parent&&i.parent.children.push(i),t.set(e,i)}return t.get(e)};n(`.`);for(let t of e)r(t.path,t);return t}function he(e){switch(e){case 16384:return`tree`;case 33188:return`blob`;case 33261:return`blob`;case 40960:return`blob`;case 57344:return`commit`}throw new E(`Unexpected GitTree entry mode: ${e.toString(8)}`)}var ge=class{constructor({fs:e,gitdir:t,cache:n}){this.treePromise=R.acquire({fs:e,gitdir:t,cache:n},async function(e){return me(e.entries)});let r=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return r.type(this)}async mode(){return r.mode(this)}async stat(){return r.stat(this)}async content(){return r.content(this)}async oid(){return r.oid(this)}}}async readdir(e){let t=e._fullpath,n=(await this.treePromise).get(t);if(!n||n.type===`blob`)return null;if(n.type!==`tree`)throw Error(`ENOTDIR: not a directory, scandir '${t}'`);let r=n.children.map(e=>e.fullpath);return r.sort(k),r}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let t=(await this.treePromise).get(e._fullpath);if(!t)throw Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let n=t.type===`tree`?{}:ne(t.metadata);e._type=t.type===`tree`?`tree`:he(n.mode),e._mode=n.mode,t.type===`tree`?e._stat=void 0:e._stat=n}return e._stat}async content(e){}async oid(e){return e._oid===!1&&(e._oid=(await this.treePromise).get(e._fullpath).metadata.oid),e._oid}};let _e=Symbol(`GitWalkSymbol`);function ve(){let e=Object.create(null);return Object.defineProperty(e,_e,{value:function({fs:e,gitdir:t,cache:n}){return new ge({fs:e,gitdir:t,cache:n})}}),Object.freeze(e),e}var B=class e extends b{constructor(t){super(`Could not find ${t}.`),this.code=this.name=e.code,this.data={what:t}}};B.code=`NotFoundError`;var V=class e extends b{constructor(t,n,r,i){super(`Object ${t} ${i?`at ${i}`:``}was anticipated to be a ${r} but it is a ${n}.`),this.code=this.name=e.code,this.data={oid:t,actual:n,expected:r,filepath:i}}};V.code=`ObjectTypeError`;var ye=class e extends b{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=e.code,this.data={value:t}}};ye.code=`InvalidOidError`;var be=class e extends b{constructor(t){super(`Could not find a fetch refspec for remote "${t}". Make sure the config file has an entry like the following:
|
|
5
|
-
[remote "${t}"]
|
|
6
|
-
\tfetch = +refs/heads/*:refs/remotes/origin/*
|
|
7
|
-
`),this.code=this.name=e.code,this.data={remote:t}}};be.code=`NoRefspecError`;var xe=class e{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let t=null;this.parsedConfig=e.trim().split(`
|
|
8
|
-
`).map(e=>{if(/^\s*#/.test(e))return{line:e,comment:!0};let n=e.indexOf(` `);if(e.startsWith(`^`)){let n=e.slice(1);return this.refs.set(t+`^{}`,n),{line:e,ref:t,peeled:n}}else{let r=e.slice(0,n);return t=e.slice(n+1),this.refs.set(t,r),{line:e,ref:t,oid:r}}})}return this}static from(t){return new e(t)}delete(e){this.parsedConfig=this.parsedConfig.filter(t=>t.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(`
|
|
9
|
-
`)+`
|
|
10
|
-
`}},Se=class e{constructor({remotePath:e,localPath:t,force:n,matchPrefix:r}){Object.assign(this,{remotePath:e,localPath:t,force:n,matchPrefix:r})}static from(t){let[n,r,i,a,o]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=n===`+`,c=i===`*`;if(c!==(o===`*`))throw new E(`Invalid refspec`);return new e({remotePath:r,localPath:a,force:s,matchPrefix:c})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,``)}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,``)}else if(e===this.localPath)return this.remotePath;return null}},Ce=class e{constructor(e=[]){this.rules=e}static from(t){let n=[];for(let e of t)n.push(Se.from(e));return new e(n)}add(e){let t=Se.from(e);this.rules.push(t)}translate(e){let t=[];for(let n of this.rules)for(let r of e){let e=n.translate(r);e&&t.push([r,e])}return t}translateOne(e){let t=null;for(let n of this.rules){let r=n.translate(e);r&&(t=r)}return t}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,``))}};function we(e,t){let n=e.replace(/\^\{\}$/,``),r=t.replace(/\^\{\}$/,``),i=-(n<r)||+(n>r);return i===0?e.endsWith(`^{}`)?1:-1:i}
|
|
11
|
-
/*!
|
|
12
|
-
* This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
|
|
13
|
-
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
14
|
-
* Copyright (c) James Prevett and other ZenFS contributors.
|
|
15
|
-
*/
|
|
16
|
-
function Te(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n.at(-1)!==`.`||n.at(-2)!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function Ee(e){if(!e.length)return`.`;let t=e[0]===`/`,n=e.at(-1)===`/`;return e=Te(e,!t),e.length?(n&&(e+=`/`),t?`/${e}`:e):t?`/`:n?`./`:`.`}function H(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];r.length>0&&(t===void 0?t=r:t+=`/`+r)}return t===void 0?`.`:Ee(t)}let De=e=>{if(typeof e==`number`)return e;e=e.toLowerCase();let t=parseInt(e);return e.endsWith(`k`)&&(t*=1024),e.endsWith(`m`)&&(t*=1024*1024),e.endsWith(`g`)&&(t*=1024*1024*1024),t},Oe=e=>{if(typeof e==`boolean`)return e;if(e=e.trim().toLowerCase(),e===`true`||e===`yes`||e===`on`)return!0;if(e===`false`||e===`no`||e===`off`)return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${e}`)},ke={core:{filemode:Oe,bare:Oe,logallrefupdates:Oe,symlinks:Oe,ignorecase:Oe,bigFileThreshold:De}},Ae=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,je=/^[A-Za-z0-9-.]+$/,Me=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,Ne=/^[A-Za-z][A-Za-z-]*$/,Pe=/^(.*?)( *[#;].*)$/,Fe=e=>{let t=Ae.exec(e);if(t!=null){let[e,n]=t.slice(1);return[e,n]}return null},Ie=e=>{let t=Me.exec(e);if(t!=null){let[e,n=`true`]=t.slice(1),r=Le(n);return[e,ze(r)]}return null},Le=e=>{let t=Pe.exec(e);if(t==null)return e;let[n,r]=t.slice(1);return Re(n)&&Re(r)?`${n}${r}`:n},Re=e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!=0,ze=e=>e.split(``).reduce((e,t,n,r)=>{let i=t===`"`&&r[n-1]!==`\\`,a=t===`\\`&&r[n+1]===`"`;return i||a?e:e+t},``),Be=e=>e==null?null:e.toLowerCase(),Ve=(e,t,n)=>[Be(e),t,Be(n)].filter(e=>e!=null).join(`.`),He=e=>{let t=e.split(`.`),n=t.shift(),r=t.pop(),i=t.length?t.join(`.`):void 0;return{section:n,subsection:i,name:r,path:Ve(n,i,r),sectionPath:Ve(n,i,null),isSection:!!n}},Ue=(e,t)=>e.reduce((e,n,r)=>t(n)?r:e,-1);var We=class e{constructor(e){let t=null,n=null;this.parsedConfig=e?e.split(`
|
|
17
|
-
`).map(e=>{let r=null,i=null,a=e.trim(),o=Fe(a),s=o!=null;if(s)[t,n]=o;else{let e=Ie(a);e!=null&&([r,i]=e)}let c=Ve(t,n,r);return{line:e,isSection:s,section:t,subsection:n,name:r,value:i,path:c}}):[]}static from(t){return new e(t)}async get(e,t=!1){let n=He(e).path,r=this.parsedConfig.filter(e=>e.path===n).map(({section:e,name:t,value:n})=>{let r=ke[e]&&ke[e][t];return r?r(n):n});return t?r:r.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(t=>t.isSection&&t.section===e).map(e=>e.subsection)}async deleteSection(e,t){this.parsedConfig=this.parsedConfig.filter(n=>!(n.section===e&&n.subsection===t))}async append(e,t){return this.set(e,t,!0)}async set(e,t,n=!1){let{section:r,subsection:i,name:a,path:o,sectionPath:s,isSection:c}=He(e),l=Ue(this.parsedConfig,e=>e.path===o);if(t==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let e=this.parsedConfig[l],r=Object.assign({},e,{name:a,value:t,modified:!0});n?this.parsedConfig.splice(l+1,0,r):this.parsedConfig[l]=r}else{let e=this.parsedConfig.findIndex(e=>e.path===s),n={section:r,subsection:i,name:a,value:t,modified:!0,path:o};if(je.test(r)&&Ne.test(a))if(e>=0)this.parsedConfig.splice(e+1,0,n);else{let e={isSection:c,section:r,subsection:i,modified:!0,path:s};this.parsedConfig.push(e,n)}}}toString(){return this.parsedConfig.map(({line:e,section:t,subsection:n,name:r,value:i,modified:a=!1})=>a?r!=null&&i!=null?typeof i==`string`&&/[#;]/.test(i)?`\t${r} = "${i}"`:`\t${r} = ${i}`:n==null?`[${t}]`:`[${t} "${n}"]`:e).join(`
|
|
18
|
-
`)}},U=class{static async get({fs:e,gitdir:t}){let n=await e.read(`${t}/config`,{encoding:`utf8`});return We.from(n)}static async save({fs:e,gitdir:t,config:n}){await e.write(`${t}/config`,n.toString(),{encoding:`utf8`})}};let Ge=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],Ke=[`config`,`description`,`index`,`shallow`,`commondir`],qe;async function Je(e,t){return qe===void 0&&(qe=new s),qe.acquire(e,t)}var W=class e{static async updateRemoteRefs({fs:t,gitdir:n,remote:r,refs:i,symrefs:a,tags:o,refspecs:s=void 0,prune:c=!1,pruneTags:l=!1}){for(let e of i.values())if(!e.match(/[0-9a-f]{40}/))throw new ye(e);let u=await U.get({fs:t,gitdir:n});if(!s){if(s=await u.getall(`remote.${r}.fetch`),s.length===0)throw new be(r);s.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let d=Ce.from(s),f=new Map;if(l){let r=await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`});await e.deleteRefs({fs:t,gitdir:n,refs:r.map(e=>`refs/tags/${e}`)})}if(o){for(let r of i.keys())if(r.startsWith(`refs/tags`)&&!r.endsWith(`^{}`)&&!await e.exists({fs:t,gitdir:n,ref:r})){let e=i.get(r);f.set(r,e)}}let p=d.translate([...i.keys()]);for(let[e,t]of p){let n=i.get(e);f.set(t,n)}let m=d.translate([...a.keys()]);for(let[e,t]of m){let n=a.get(e),r=d.translateOne(n);r&&f.set(t,`ref: ${r}`)}let h=[];if(c){for(let r of d.localNamespaces()){let i=(await e.listRefs({fs:t,gitdir:n,filepath:r})).map(e=>`${r}/${e}`);for(let e of i)f.has(e)||h.push(e)}h.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:h})}for(let[e,r]of f)await Je(e,async()=>t.write(H(n,e),`${r.trim()}\n`,`utf8`));return{pruned:h}}static async writeRef({fs:e,gitdir:t,ref:n,value:r}){if(!r.match(/[0-9a-f]{40}/))throw new ye(r);await Je(n,async()=>e.write(H(t,n),`${r.trim()}\n`,`utf8`))}static async writeSymbolicRef({fs:e,gitdir:t,ref:n,value:r}){await Je(n,async()=>e.write(H(t,n),`ref: ${r.trim()}\n`,`utf8`))}static async deleteRef({fs:t,gitdir:n,ref:r}){return e.deleteRefs({fs:t,gitdir:n,refs:[r]})}static async deleteRefs({fs:e,gitdir:t,refs:n}){await Promise.all(n.map(n=>e.rm(H(t,n))));let r=await Je(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`})),i=xe.from(r),a=i.refs.size;for(let e of n)i.refs.has(e)&&i.delete(e);i.refs.size<a&&(r=i.toString(),await Je(`packed-refs`,async()=>e.write(`${t}/packed-refs`,r,{encoding:`utf8`})))}static async resolve({fs:t,gitdir:n,ref:r,depth:i=void 0}){if(i!==void 0&&(i--,i===-1))return r;if(r.startsWith(`ref: `))return r=r.slice(5),e.resolve({fs:t,gitdir:n,ref:r,depth:i});if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let a=await e.packedRefs({fs:t,gitdir:n}),o=Ge(r).filter(e=>!Ke.includes(e));for(let r of o){let o=await Je(r,async()=>await t.read(`${n}/${r}`,{encoding:`utf8`})||a.get(r));if(o)return e.resolve({fs:t,gitdir:n,ref:o.trim(),depth:i})}throw new B(r)}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch{return!1}}static async expand({fs:t,gitdir:n,ref:r}){if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let i=await e.packedRefs({fs:t,gitdir:n}),a=Ge(r);for(let e of a)if(await Je(e,async()=>t.exists(`${n}/${e}`))||i.has(e))return e;throw new B(r)}static async expandAgainstMap({ref:e,map:t}){let n=Ge(e);for(let e of n)if(await t.has(e))return e;throw new B(e)}static resolveAgainstMap({ref:t,fullref:n=t,depth:r=void 0,map:i}){if(r!==void 0&&(r--,r===-1))return{fullref:n,oid:t};if(t.startsWith(`ref: `))return t=t.slice(5),e.resolveAgainstMap({ref:t,fullref:n,depth:r,map:i});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:n,oid:t};let a=Ge(t);for(let t of a){let n=i.get(t);if(n)return e.resolveAgainstMap({ref:n.trim(),fullref:t,depth:r,map:i})}throw new B(t)}static async packedRefs({fs:e,gitdir:t}){let n=await Je(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`}));return xe.from(n).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=e.packedRefs({fs:t,gitdir:n}),a=null;try{a=await t.readdirDeep(`${n}/${r}`),a=a.map(e=>e.replace(`${n}/${r}/`,``))}catch{a=[]}for(let e of(await i).keys())e.startsWith(r)&&(e=e.replace(r+`/`,``),a.includes(e)||a.push(e));return a.sort(we),a}static async listBranches({fs:t,gitdir:n,remote:r}){return r?e.listRefs({fs:t,gitdir:n,filepath:`refs/remotes/${r}`}):e.listRefs({fs:t,gitdir:n,filepath:`refs/heads`})}static async listTags({fs:t,gitdir:n}){return(await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`})).filter(e=>!e.endsWith(`^{}`))}};function Ye(e,t){return k(Xe(e),Xe(t))}function Xe(e){return e.mode===`040000`?e.path+`/`:e.path}function Ze(e){switch(e){case`040000`:return`tree`;case`100644`:return`blob`;case`100755`:return`blob`;case`120000`:return`blob`;case`160000`:return`commit`}throw new E(`Unexpected GitTree entry mode: ${e}`)}function Qe(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(32,n);if(r===-1)throw new E(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next space character.`);let i=e.indexOf(0,n);if(i===-1)throw new E(`GitTree: Error parsing buffer at byte location ${n}: Could not find the next null character.`);let a=e.slice(n,r).toString(`utf8`);a===`40000`&&(a=`040000`);let o=Ze(a),s=e.slice(r+1,i).toString(`utf8`);if(s.includes(`\\`)||s.includes(`/`))throw new D(s);let c=e.slice(i+1,i+21).toString(`hex`);n=i+21,t.push({mode:a,path:s,oid:c,type:o})}return t}function $e(e){if(typeof e==`number`&&(e=e.toString(8)),e.match(/^0?4.*/))return`040000`;if(e.match(/^1006.*/))return`100644`;if(e.match(/^1007.*/))return`100755`;if(e.match(/^120.*/))return`120000`;if(e.match(/^160.*/))return`160000`;throw new E(`Could not understand file mode: ${e}`)}function et(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=$e(e.mode),e.type||=Ze(e.mode),e}var G=class e{constructor(e){if(r.Buffer.isBuffer(e))this._entries=Qe(e);else if(Array.isArray(e))this._entries=e.map(et);else throw new E(`invalid type passed to GitTree constructor`);this._entries.sort(te)}static from(t){return new e(t)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
|
|
19
|
-
`)}toObject(){let e=[...this._entries];return e.sort(Ye),r.Buffer.concat(e.map(e=>{let t=r.Buffer.from(e.mode.replace(/^0/,``)),n=r.Buffer.from(` `),i=r.Buffer.from(e.path,`utf8`),a=r.Buffer.from([0]),o=r.Buffer.from(e.oid,`hex`);return r.Buffer.concat([t,n,i,a,o])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},tt=class{static wrap({type:e,object:t}){let n=`${e} ${t.length}\x00`,r=n.length,i=r+t.length,a=new Uint8Array(i);for(let e=0;e<r;e++)a[e]=n.charCodeAt(e);return a.set(t,r),a}static unwrap(e){let t=e.indexOf(32),n=e.indexOf(0),i=e.slice(0,t).toString(`utf8`),a=e.slice(t+1,n).toString(`utf8`),o=e.length-(n+1);if(parseInt(a)!==o)throw new E(`Length mismatch: expected ${a} bytes but got ${o} instead.`);return{type:i,object:r.Buffer.from(e.slice(n+1))}}};async function nt({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`,i=await e.read(`${t}/${r}`);return i?{object:i,format:`deflated`,source:r}:null}function rt(e,t){let n=new O(e),i=it(n);if(i!==t.byteLength)throw new E(`applyDelta expected source buffer to be ${i} bytes but the provided buffer was ${t.length} bytes`);let a=it(n),o,s=ot(n,t);if(s.byteLength===a)o=s;else{o=r.Buffer.alloc(a);let e=new O(o);for(e.copy(s);!n.eof();)e.copy(ot(n,t));let i=e.tell();if(a!==i)throw new E(`applyDelta expected target buffer to be ${a} bytes but the resulting buffer was ${i} bytes`)}return o}function it(e){let t=0,n=0,r=null;do r=e.readUInt8(),t|=(r&127)<<n,n+=7;while(r&128);return t}function at(e,t,n){let r=0,i=0;for(;n--;)t&1&&(r|=e.readUInt8()<<i),t>>=1,i+=8;return r}function ot(e,t){let n=e.readUInt8();if(n&128){let r=at(e,n&15,4),i=at(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}else return e.slice(n)}function st(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function ct(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:st(e)}var lt=class{constructor(e){if(r.Buffer===void 0)throw Error(`Missing Buffer dependency`);this.stream=ct(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:t}=await this.stream.next();return e&&(this._ended=!0,!t)?r.Buffer.alloc(0):(t&&=r.Buffer.from(t),t)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let t=[this.buffer];for(;this.cursor+e>ut(t);){let e=await this._next();if(this._ended)break;t.push(e)}this.buffer=r.Buffer.concat(t)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function ut(e){return e.reduce((e,t)=>e+t.length,0)}async function dt(e,t){let n=new lt(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new E(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new E(`Invalid packfile version: ${i}`);let a=await n.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!n.eof()&&a--;){let e=n.tell(),{type:r,length:i,ofs:o,reference:s}=await ft(n),c=new u.Inflate;for(;!c.result;){let l=await n.chunk();if(!l)break;if(c.push(l,!1),c.err)throw new E(`Pako error: ${c.msg}`);if(c.result){if(c.result.length!==i)throw new E(`Inflated object size is different from that stated in packfile.`);await n.undo(),await n.read(l.length-c.strm.avail_in);let u=n.tell();await t({data:c.result,type:r,num:a,offset:e,end:u,reference:s,ofs:o})}}}}async function ft(e){let t=await e.byte(),n=t>>4&7,i=t&15;if(t&128){let n=4;do t=await e.byte(),i|=(t&127)<<n,n+=7;while(t&128)}let a,o;if(n===6){let n=0;a=0;let i=[];do t=await e.byte(),a|=(t&127)<<n,n+=7,i.push(t);while(t&128);o=r.Buffer.from(i)}return n===7&&(o=await e.read(20)),{type:n,length:i,ofs:a,reference:o}}let pt=!1;async function mt(e){return pt===null&&(pt=gt()),pt?ht(e):u.inflate(e)}async function ht(e){let t=new DecompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function gt(){try{if(new DecompressionStream(`deflate`))return!0}catch{}return!1}function _t(e){let t=[],n=0,r=0;do{n=e.readUInt8();let i=n&127;t.push(i),r=n&128}while(r);return t.reduce((e,t)=>e+1<<7|t,-1)}function vt(e,t){let n=t,r=4,i=null;do i=e.readUInt8(),n|=(i&127)<<r,r+=7;while(i&128);return n}var yt=class e{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:n}){let r=new O(t);if(r.slice(4).toString(`hex`)!==`ff744f63`)return;let i=r.readUInt32BE();if(i!==2)throw new E(`Unable to read version ${i} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2048*1024*1024)throw new E(`To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.`);r.seek(r.tell()+1020);let a=r.readUInt32BE(),o=[];for(let e=0;e<a;e++)o[e]=r.slice(20).toString(`hex`);r.seek(r.tell()+4*a);let s=new Map;for(let e=0;e<a;e++)s.set(o[e],r.readUInt32BE());let c=r.slice(20).toString(`hex`);return new e({hashes:o,crcs:{},offsets:s,packfileSha:c,getExternalRefDelta:n})}static async fromPack({pack:t,getExternalRefDelta:n,onProgress:r}){let i={1:`commit`,2:`tree`,3:`blob`,4:`tag`,6:`ofs-delta`,7:`ref-delta`},a={},o=t.slice(-20).toString(`hex`),s=[],c={},u=new Map,d=null,f=null;await dt([t],async({data:e,type:t,reference:n,offset:o,num:s})=>{d===null&&(d=s);let c=Math.floor((d-s)*100/d);c!==f&&r&&await r({phase:`Receiving objects`,loaded:d-s,total:d}),f=c,t=i[t],([`commit`,`tree`,`blob`,`tag`].includes(t)||t===`ofs-delta`||t===`ref-delta`)&&(a[o]={type:t,offset:o})});let p=Object.keys(a).map(Number);for(let[e,n]of p.entries()){let r=e+1===p.length?t.byteLength-20:p[e+1],i=a[n],o=l.buf(t.slice(n,r))>>>0;i.end=r,i.crc=o}let m=new e({pack:Promise.resolve(t),packfileSha:o,crcs:c,hashes:s,offsets:u,getExternalRefDelta:n});f=null;let h=0,g=[0,0,0,0,0,0,0,0,0,0,0,0];for(let e in a){e=Number(e);let t=Math.floor(h*100/d);t!==f&&r&&await r({phase:`Resolving deltas`,loaded:h,total:d}),h++,f=t;let n=a[e];if(!n.oid)try{m.readDepth=0,m.externalReadDepth=0;let{type:t,object:r}=await m.readSlice({start:e});g[m.readDepth]+=1;let i=await N(tt.wrap({type:t,object:r}));n.oid=i,s.push(i),u.set(i,e),c[i]=n.crc}catch{continue}}return s.sort(),m}async toBuffer(){let e=[],t=(t,n)=>{e.push(r.Buffer.from(t,n))};t(`ff744f63`,`hex`),t(`00000002`,`hex`);let n=new O(r.Buffer.alloc(256*4));for(let e=0;e<256;e++){let t=0;for(let n of this.hashes)parseInt(n.slice(0,2),16)<=e&&t++;n.writeUInt32BE(t)}e.push(n.buffer);for(let e of this.hashes)t(e,`hex`);let i=new O(r.Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)i.writeUInt32BE(this.crcs[e]);e.push(i.buffer);let a=new O(r.Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)a.writeUInt32BE(this.offsets.get(e));e.push(a.buffer),t(this.packfileSha,`hex`);let o=r.Buffer.concat(e),s=await N(o),c=r.Buffer.alloc(20);return c.write(s,`hex`),r.Buffer.concat([o,c])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new E(`Could not read object ${e} from packfile`)}let t=this.offsets.get(e);return this.readSlice({start:t})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let t={16:`commit`,32:`tree`,48:`blob`,64:`tag`,96:`ofs_delta`,112:`ref_delta`},n=await this.pack;if(!n)throw new E(`Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.`);let i=n.slice(e),a=new O(i),o=a.readUInt8(),s=o&112,c=t[s];if(c===void 0)throw new E(`Unrecognized type: 0b`+s.toString(2));let l=o&15,u=l;o&128&&(u=vt(a,l));let d=null,f=null;if(c===`ofs_delta`){let t=e-_t(a);({object:d,type:c}=await this.readSlice({start:t}))}if(c===`ref_delta`){let e=a.slice(20).toString(`hex`);({object:d,type:c}=await this.read({oid:e}))}let p=i.slice(a.tell());if(f=r.Buffer.from(await mt(p)),f.byteLength!==u)throw new E(`Packfile told us object would have length ${u} but it had length ${f.byteLength}`);return d&&(f=r.Buffer.from(rt(f,d))),this.readDepth>3&&(this.offsetCache[e]={type:c,object:f}),{type:c,format:`content`,object:f}}};let bt=Symbol(`PackfileCache`);async function xt({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return yt.fromIdx({idx:a,getExternalRefDelta:n})}function St({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[bt]||(t[bt]=new Map);let o=t[bt].get(n);return o||(o=xt({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[bt].set(n,o)),o}let Ct=8*1024*1024;async function wt(e,{start:t=0,end:n=e.length}={}){let r=d.createHash(`sha1`);for(let i=t;i<n;i+=Ct)r.update(e.subarray(i,Math.min(i+Ct,n)));return r.digest(`hex`)}async function Tt({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`,getExternalRefDelta:a}){let o=await e.readdir(H(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let i of o){let o=`${n}/objects/pack/${i}`,s=await St({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new E(s.error);if(s.offsets.has(r)){let t=o.replace(/idx$/,`pack`);s.pack||=e.read(t);let n=await s.pack;if(!n)throw s.pack=null,new E(`Could not read packfile at ${t}. The file may be missing, corrupted, or too large to read into memory.`);if(!s._checksumVerified){let e=s.packfileSha,t=n.subarray(-20),r=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(r!==e)throw new E(`Packfile trailer mismatch: expected ${e}, got ${r}. The packfile may be corrupted.`);let i=await wt(n,{start:0,end:n.length-20});if(i!==e)throw new E(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`);s._checksumVerified=!0}let c=await s.read({oid:r,getExternalRefDelta:a});return c.format=`content`,c.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,c}}return null}async function K({fs:e,cache:t,gitdir:n,oid:i,format:a=`content`}){let o=r=>K({fs:e,cache:t,gitdir:n,oid:r}),s;if(i===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(s={format:`wrapped`,object:r.Buffer.from(`tree 0\0`)}),s||=await nt({fs:e,gitdir:n,oid:i}),!s){if(s=await Tt({fs:e,cache:t,gitdir:n,oid:i,getExternalRefDelta:o}),!s)throw new B(i);return s}if(a===`deflated`||(s.format===`deflated`&&(s.object=r.Buffer.from(await mt(s.object)),s.format=`wrapped`),a===`wrapped`))return s;let c=await N(s.object);if(c!==i)throw new E(`SHA check failed! Expected ${i}, computed ${c}`);let{object:l,type:u}=tt.unwrap(s.object);if(s.type=u,s.object=l,s.format=`content`,a===`content`)return s;throw new E(`invalid requested format "${a}"`)}var Et=class e extends b{constructor(t,n,r=!0){super(`Failed to create ${t} at ${n} because it already exists.${r?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:``}`),this.code=this.name=e.code,this.data={noun:t,where:n,canForce:r}}};Et.code=`AlreadyExistsError`;var Dt=class e extends b{constructor(t,n,r){super(`Found multiple ${t} matching "${n}" (${r.join(`, `)}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=e.code,this.data={nouns:t,short:n,matches:r}}};Dt.code=`AmbiguousError`;var Ot=class e extends b{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};Ot.code=`CheckoutConflictError`;var kt=class e extends b{constructor(t,n){super(`Cannot cherry-pick merge commit ${t}. Merge commits have ${n} parents and require specifying which parent to use as the base.`),this.code=this.name=e.code,this.data={oid:t,parentCount:n}}};kt.code=`CherryPickMergeCommitError`;var At=class e extends b{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};At.code=`CherryPickRootCommitError`;var jt=class e extends b{constructor(t,n){super(`Failed to checkout "${t}" because commit ${n} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=e.code,this.data={ref:t,oid:n}}};jt.code=`CommitNotFetchedError`;var Mt=class e extends b{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};Mt.code=`EmptyServerResponseError`;var Nt=class e extends b{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};Nt.code=`FastForwardError`;var Pt=class e extends b{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};Pt.code=`GitPushError`;var Ft=class e extends b{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};Ft.code=`HttpError`;var It=class e extends b{constructor(t){let n=`invalid filepath`;t===`leading-slash`||t===`trailing-slash`?n=`"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`:t===`directory`&&(n=`"filepath" should not be a directory.`),super(n),this.code=this.name=e.code,this.data={reason:t}}};It.code=`InvalidFilepathError`;var Lt=class e extends b{constructor(t,n){super(`"${t}" would be an invalid git reference. (Hint: a valid alternative would be "${n}".)`),this.code=this.name=e.code,this.data={ref:t,suggestion:n}}};Lt.code=`InvalidRefNameError`;var Rt=class e extends b{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};Rt.code=`MaxDepthError`;var zt=class e extends b{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};zt.code=`MergeNotSupportedError`;var Bt=class e extends b{constructor(t,n,r,i){super(`Automatic merge failed with one or more merge conflicts in the following files: ${t.toString()}. Fix conflicts then commit the result.`),this.code=this.name=e.code,this.data={filepaths:t,bothModified:n,deleteByUs:r,deleteByTheirs:i}}};Bt.code=`MergeConflictError`;var q=class e extends b{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=e.code,this.data={role:t}}};q.code=`MissingNameError`;var Vt=class e extends b{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};Vt.code=`MissingParameterError`;var Ht=class e extends b{constructor(t){super(`There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more`),this.code=this.name=e.code,this.data={errors:t},this.errors=t}};Ht.code=`MultipleGitError`;var Ut=class e extends b{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};Ut.code=`ParseError`;var Wt=class e extends b{constructor(t){let n=``;t===`not-fast-forward`?n=` because it was not a simple fast-forward`:t===`tag-exists`&&(n=` because tag already exists`),super(`Push rejected${n}. Use "force: true" to override.`),this.code=this.name=e.code,this.data={reason:t}}};Wt.code=`PushRejectedError`;var Gt=class e extends b{constructor(t,n){super(`Remote does not support the "${t}" so the "${n}" parameter cannot be used.`),this.code=this.name=e.code,this.data={capability:t,parameter:n}}};Gt.code=`RemoteCapabilityError`;var Kt=class e extends b{constructor(t,n){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=e.code,this.data={preview:t,response:n}}};Kt.code=`SmartHttpError`;var qt=class e extends b{constructor(t,n,r){super(`Git remote "${t}" uses an unrecognized transport protocol: "${n}"`),this.code=this.name=e.code,this.data={url:t,transport:n,suggestion:r}}};qt.code=`UnknownTransportError`;var Jt=class e extends b{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};Jt.code=`UrlParseError`;var Yt=class e extends b{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};Yt.code=`UserCanceledError`;var Xt=class e extends b{constructor(t){super(`Could not merge index: Entry for '${t}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=e.code,this.data={filepath:t}}};Xt.code=`IndexResetError`;var Zt=class e extends b{constructor(t){super(`"${t}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=e.code,this.data={ref:t}}};Zt.code=`NoCommitError`;var Qt=Object.freeze({__proto__:null,AlreadyExistsError:Et,AmbiguousError:Dt,CheckoutConflictError:Ot,CherryPickMergeCommitError:kt,CherryPickRootCommitError:At,CommitNotFetchedError:jt,EmptyServerResponseError:Mt,FastForwardError:Nt,GitPushError:Pt,HttpError:Ft,InternalError:E,InvalidFilepathError:It,InvalidOidError:ye,InvalidRefNameError:Lt,MaxDepthError:Rt,MergeNotSupportedError:zt,MergeConflictError:Bt,MissingNameError:q,MissingParameterError:Vt,MultipleGitError:Ht,NoRefspecError:be,NotFoundError:B,ObjectTypeError:V,ParseError:Ut,PushRejectedError:Wt,RemoteCapabilityError:Gt,SmartHttpError:Kt,UnknownTransportError:qt,UnsafeFilepathError:D,UrlParseError:Jt,UserCanceledError:Yt,UnmergedPathsError:T,IndexResetError:Xt,NoCommitError:Zt});function $t({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=en(r),`${e} <${t}> ${n} ${r}`}function en(e){let t=tn(nn(e));e=Math.abs(e);let n=Math.floor(e/60);e-=n*60;let r=String(n),i=String(e);return r.length<2&&(r=`0`+r),i.length<2&&(i=`0`+i),(t===-1?`-`:`+`)+r+i}function tn(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function nn(e){return e===0?e:-e}function rn(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+`
|
|
20
|
-
`,e}function an(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:on(i)}}function on(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t===`+`?1:-1)*(Number(n)*60+Number(r)),sn(r)}function sn(e){return e===0?e:-e}var cn=class e{constructor(t){if(typeof t==`string`)this._tag=t;else if(r.Buffer.isBuffer(t))this._tag=t.toString(`utf8`);else if(typeof t==`object`)this._tag=e.render(t);else throw new E(`invalid type passed to GitAnnotatedTag constructor`)}static from(t){return new e(t)}static render(e){return`object ${e.object}
|
|
21
|
-
type ${e.type}
|
|
22
|
-
tag ${e.tag}
|
|
23
|
-
tagger ${$t(e.tagger)}
|
|
24
|
-
|
|
25
|
-
${e.message}
|
|
26
|
-
${e.gpgsig?e.gpgsig:``}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
|
|
27
|
-
|
|
28
|
-
`))}message(){let e=this.withoutSignature();return e.slice(e.indexOf(`
|
|
29
|
-
|
|
30
|
-
`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let e=this.justHeaders().split(`
|
|
31
|
-
`),t=[];for(let n of e)n[0]===` `?t[t.length-1]+=`
|
|
32
|
-
`+n.slice(1):t.push(n);let n={};for(let e of t){let t=e.slice(0,e.indexOf(` `)),r=e.slice(e.indexOf(` `)+1);Array.isArray(n[t])?n[t].push(r):n[t]=r}return n.tagger&&=an(n.tagger),n.committer&&=an(n.committer),n}withoutSignature(){let e=rn(this._tag);return e.indexOf(`
|
|
33
|
-
-----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(`
|
|
34
|
-
-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
|
|
35
|
-
-----BEGIN PGP SIGNATURE-----`)!==-1)return rn(this._tag.slice(this._tag.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._tag.indexOf(`-----END PGP SIGNATURE-----`)+27))}payload(){return this.withoutSignature()+`
|
|
36
|
-
`}toObject(){return r.Buffer.from(this._tag,`utf8`)}static async sign(t,n,r){let i=t.payload(),{signature:a}=await n({payload:i,secretKey:r});a=rn(a);let o=i+a;return e.from(o)}};function ln(e){return e.trim().split(`
|
|
37
|
-
`).map(e=>` `+e).join(`
|
|
38
|
-
`)+`
|
|
39
|
-
`}function un(e){return e.split(`
|
|
40
|
-
`).map(e=>e.replace(/^ /,``)).join(`
|
|
41
|
-
`)}var dn=class e{constructor(t){if(typeof t==`string`)this._commit=t;else if(r.Buffer.isBuffer(t))this._commit=t.toString(`utf8`);else if(typeof t==`object`)this._commit=e.render(t);else throw new E(`invalid type passed to GitCommit constructor`)}static fromPayloadSignature({payload:t,signature:n}){let r=e.justHeaders(t),i=e.justMessage(t),a=rn(r+`
|
|
42
|
-
gpgsig`+ln(n)+`
|
|
43
|
-
`+i);return new e(a)}static from(t){return new e(t)}toObject(){return r.Buffer.from(this._commit,`utf8`)}headers(){return this.parseHeaders()}message(){return e.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return rn(e.slice(e.indexOf(`
|
|
44
|
-
|
|
45
|
-
`)+2))}static justHeaders(e){return e.slice(0,e.indexOf(`
|
|
46
|
-
|
|
47
|
-
`))}parseHeaders(){let t=e.justHeaders(this._commit).split(`
|
|
48
|
-
`),n=[];for(let e of t)e[0]===` `?n[n.length-1]+=`
|
|
49
|
-
`+e.slice(1):n.push(e);let r={parent:[]};for(let e of n){let t=e.slice(0,e.indexOf(` `)),n=e.slice(e.indexOf(` `)+1);Array.isArray(r[t])?r[t].push(n):r[t]=n}return r.author&&=an(r.author),r.committer&&=an(r.committer),r}static renderHeaders(e){let t=``;if(e.tree?t+=`tree ${e.tree}\n`:t+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
50
|
-
`,e.parent){if(e.parent.length===void 0)throw new E(`commit 'parent' property should be an array`);for(let n of e.parent)t+=`parent ${n}\n`}let n=e.author;t+=`author ${$t(n)}\n`;let r=e.committer||e.author;return t+=`committer ${$t(r)}\n`,e.gpgsig&&(t+=`gpgsig`+ln(e.gpgsig)),t}static render(t){return e.renderHeaders(t)+`
|
|
51
|
-
`+rn(t.message)}render(){return this._commit}withoutSignature(){let e=rn(this._commit);if(e.indexOf(`
|
|
52
|
-
gpgsig`)===-1)return e;let t=e.slice(0,e.indexOf(`
|
|
53
|
-
gpgsig`)),n=e.slice(e.indexOf(`-----END PGP SIGNATURE-----
|
|
54
|
-
`)+28);return rn(t+`
|
|
55
|
-
`+n)}isolateSignature(){return un(this._commit.slice(this._commit.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._commit.indexOf(`-----END PGP SIGNATURE-----`)+27))}static async sign(t,n,r){let i=t.withoutSignature(),a=e.justMessage(t._commit),{signature:o}=await n({payload:i,secretKey:r});o=rn(o);let s=e.justHeaders(t._commit)+`
|
|
56
|
-
gpgsig`+ln(o)+`
|
|
57
|
-
`+a;return e.from(s)}};async function fn({fs:e,cache:t,gitdir:n,oid:r}){if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)return{tree:G.from([]),oid:r};let{type:i,object:a}=await K({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=cn.from(a).parse().object,fn({fs:e,cache:t,gitdir:n,oid:r});if(i===`commit`)return r=dn.from(a).parse().tree,fn({fs:e,cache:t,gitdir:n,oid:r});if(i!==`tree`)throw new V(r,i,`tree`);return{tree:G.from(a),oid:r}}var pn=class{constructor({fs:e,gitdir:t,ref:n,cache:r}){this.fs=e,this.cache=r,this.gitdir=t,this.mapPromise=(async()=>{let r=new Map,i;try{i=await W.resolve({fs:e,gitdir:t,ref:n})}catch(e){e instanceof B&&(i=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)}let a=await fn({fs:e,cache:this.cache,gitdir:t,oid:i});return a.type=`tree`,a.mode=`40000`,r.set(`.`,a),r})();let i=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(e){let t=e._fullpath,{fs:n,cache:r,gitdir:i}=this,a=await this.mapPromise,o=a.get(t);if(!o)throw Error(`No obj for ${t}`);let s=o.oid;if(!s)throw Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!==`tree`)return null;let{type:c,object:l}=await K({fs:n,cache:r,gitdir:i,oid:s});if(c!==o.type)throw new V(s,c,o.type);let u=G.from(l);for(let e of u)a.set(H(t,e.path),e);return u.entries().map(e=>H(t,e.path))}async type(e){if(e._type===!1){let{type:t}=(await this.mapPromise).get(e._fullpath);e._type=t}return e._type}async mode(e){if(e._mode===!1){let{mode:t}=(await this.mapPromise).get(e._fullpath);e._mode=A(parseInt(t,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let t=await this.mapPromise,{fs:n,cache:r,gitdir:i}=this,a=t.get(e._fullpath).oid,{type:o,object:s}=await K({fs:n,cache:r,gitdir:i,oid:a});o===`blob`?e._content=new Uint8Array(s):e._content=void 0}return e._content}async oid(e){return e._oid===!1&&(e._oid=(await this.mapPromise).get(e._fullpath).oid),e._oid}};function J({ref:e=`HEAD`}={}){let t=Object.create(null);return Object.defineProperty(t,_e,{value:function({fs:t,gitdir:n,cache:r}){return new pn({fs:t,gitdir:n,ref:e,cache:r})}}),Object.freeze(t),t}var mn=class{constructor({fs:e,dir:t,gitdir:n,cache:r}){this.fs=e,this.cache=r,this.dir=t,this.gitdir=n,this.config=null;let i=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(e){let t=e._fullpath,{fs:n,dir:r}=this,i=await n.readdir(H(r,t));return i===null?null:i.map(e=>H(t,e))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:t,dir:n}=this,r=await t.lstat(`${n}/${e._fullpath}`);if(!r)throw Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let i=r.isDirectory()?`tree`:`blob`;i===`blob`&&!r.isFile()&&!r.isSymbolicLink()&&(i=`special`),e._type=i,r=ne(r),e._mode=r.mode,r.size===-1&&e._actualSize&&(r.size=e._actualSize),e._stat=r}return e._stat}async content(e){if(e._content===!1){let{fs:t,dir:n,gitdir:r}=this;if(await e.type()===`tree`)e._content=void 0;else{let i;if(await e.mode()>>12==10)i=await t.readlink(`${n}/${e._fullpath}`);else{let a=await(await this._getGitConfig(t,r)).get(`core.autocrlf`);i=await t.read(`${n}/${e._fullpath}`,{autocrlf:a})}e._actualSize=i.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(i)}}return e._content}async oid(e){if(e._oid===!1){let t=this,{fs:r,gitdir:i,cache:a}=this,o;await R.acquire({fs:r,gitdir:i,cache:a},async function(a){let s=a.entriesMap.get(e._fullpath),c=await e.stat(),l=await(await t._getGitConfig(r,i)).get(`core.filemode`),u=n.default===void 0||n.default.platform!==`win32`;if(!s||F(c,s,l,u)){let t=await e.content();t===void 0?o=void 0:(o=await N(tt.wrap({type:`blob`,object:t})),s&&o===s.oid&&(!l||c.mode===s.mode)&&F(c,s,l,u)&&a.insert({filepath:e._fullpath,stats:c,oid:o}))}else o=s.oid}),e._oid=o}return e._oid}async _getGitConfig(e,t){return this.config||=await U.get({fs:e,gitdir:t}),this.config}};function hn(){let e=Object.create(null);return Object.defineProperty(e,_e,{value:function({fs:e,dir:t,gitdir:n,cache:r}){return new mn({fs:e,dir:t,gitdir:n,cache:r})}}),Object.freeze(e),e}function gn(e,t){let n=t-e;return Array.from({length:n},(t,n)=>e+n)}let _n=Array.prototype.flat===void 0?e=>e.reduce((e,t)=>e.concat(t),[]):e=>e.flat();var vn=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null||e<this.value)&&(this.value=e)}reset(){this.value=null}};function*yn(e){let t=new vn,n,r=[],i=e.length;for(let n=0;n<i;n++)r[n]=e[n].next().value,r[n]!==void 0&&t.consider(r[n]);if(t.value!==null)for(;;){let a=[];n=t.value,t.reset();for(let o=0;o<i;o++)r[o]!==void 0&&r[o]===n?(a[o]=r[o],r[o]=e[o].next().value):a[o]=null,r[o]!==void 0&&t.consider(r[o]);if(yield a,t.value===null)return}}async function bn({fs:e,cache:t,dir:n,gitdir:r,trees:i,map:a=async(e,t)=>t,reduce:o=async(e,t)=>{let n=_n(t);return e!==void 0&&n.unshift(e),n},iterate:s=(e,t)=>Promise.all([...t].map(e))}){let c=i.map(i=>i[_e]({fs:e,dir:n,gitdir:r,cache:t})),l=Array(c.length).fill(`.`),u=gn(0,c.length),d=async e=>(u.forEach(t=>{let n=e[t];e[t]=n&&new c[t].ConstructEntry(n)}),{entries:e,children:yn((await Promise.all(u.map(t=>{let n=e[t];return n?c[t].readdir(n):[]}))).map(e=>(e===null?[]:e)[Symbol.iterator]()))}),f=async e=>{let{entries:t,children:n}=await d(e),r=t.find(e=>e&&e._fullpath)._fullpath,i=await a(r,t);if(i!==null){let e=await s(f,n);return e=e.filter(e=>e!==void 0),o(i,e)}};return f(l)}async function xn(e,t){let n=await e.readdir(t);n==null?await e.rm(t):n.length?await Promise.all(n.map(n=>{let r=H(t,n);return e.lstat(r).then(t=>{if(t)return t.isDirectory()?xn(e,r):e.rm(r)})})).then(()=>e.rmdir(t)):await e.rmdir(t)}function Sn(e){return Cn(e)&&wn(e.then)&&wn(e.catch)}function Cn(e){return e&&typeof e==`object`}function wn(e){return typeof e==`function`}function Tn(e){return Sn((e=>{try{return e.readFile().catch(e=>e)}catch(e){return e}})(e))}let En=[`readFile`,`writeFile`,`mkdir`,`rmdir`,`unlink`,`stat`,`lstat`,`readdir`,`readlink`,`symlink`];function Dn(e,t){if(Tn(t))for(let n of En)e[`_${n}`]=t[n].bind(t);else for(let n of En)e[`_${n}`]=m(t[n].bind(t));Tn(t)?(t.cp&&(e._cp=t.cp.bind(t)),t.rm?e._rm=t.rm.bind(t):t.rmdir.length>1?e._rm=t.rmdir.bind(t):e._rm=xn.bind(null,e)):(t.cp&&(e._cp=m(t.cp.bind(t))),t.rm?e._rm=m(t.rm.bind(t)):t.rmdir.length>2?e._rm=m(t.rmdir.bind(t)):e._rm=xn.bind(null,e))}var Y=class{constructor(e){if(e._original_unwrapped_fs!==void 0)return e;let t=Object.getOwnPropertyDescriptor(e,`promises`);t&&t.enumerable?Dn(this,e.promises):Dn(this,e),this._original_unwrapped_fs=e}async exists(e,t={}){try{return await this._stat(e),!0}catch(e){if(e.code===`ENOENT`||e.code===`ENOTDIR`||(e.code||``).includes(`ENS`))return!1;throw console.log(`Unhandled error in "FileSystem.exists()" function`,e),e}}async read(e,t={}){try{let n=await this._readFile(e,t);if(t.autocrlf===`true`)try{n=new TextDecoder(`utf8`,{fatal:!0}).decode(n),n=n.replace(/\r\n/g,`
|
|
58
|
-
`),n=new TextEncoder().encode(n)}catch{}return typeof n!=`string`&&(n=r.Buffer.from(n)),n}catch{return null}}async write(e,t,n={}){try{await this._writeFile(e,t,n)}catch{await this.mkdir(z(e)),await this._writeFile(e,t,n)}}async mkdir(e,t=!1){try{await this._mkdir(e)}catch(n){if(n===null||n.code===`EEXIST`)return;if(t)throw n;if(n.code===`ENOENT`){let t=z(e);if(t===`.`||t===`/`||t===e)throw n;await this.mkdir(t),await this.mkdir(e,!0)}}}async rm(e){try{await this._unlink(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async rmdir(e,t){try{t&&t.recursive?await this._rm(e,t):await this._rmdir(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async readdir(e){try{let t=await this._readdir(e);return t.sort(k),t}catch(e){return e.code===`ENOTDIR`?null:[]}}async readdirDeep(e){let t=await this._readdir(e);return(await Promise.all(t.map(async t=>{let n=e+`/`+t;return(await this._stat(n)).isDirectory()?this.readdirDeep(n):n}))).reduce((e,t)=>e.concat(t),[])}async lstat(e){try{return await this._lstat(e)}catch(e){if(e.code===`ENOENT`||(e.code||``).includes(`ENS`))return null;throw e}}async readlink(e,t={encoding:`buffer`}){try{let n=await this._readlink(e,t);return r.Buffer.isBuffer(n)?n:r.Buffer.from(n)}catch(e){if(e.code===`ENOENT`||(e.code||``).includes(`ENS`))return null;throw e}}async writelink(e,t){return this._symlink(t.toString(`utf8`),e)}};function X(e,t){if(t===void 0)throw new Vt(e)}function On(e){return e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)}async function Z({fsp:e,dotgit:t}){X(`fsp`,e),X(`dotgit`,t);let n=await e._stat(t).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return n.isDirectory()?t:n.isFile()?e._readFile(t,`utf8`).then(e=>e.trimRight().substr(8)).then(e=>On(e)?e:H(z(t),e)):t}async function kn(e,t){return!e&&!t?!1:e&&!t||!e&&t?!0:!(await e.type()===`tree`&&await t.type()===`tree`||await e.type()===await t.type()&&await e.mode()===await t.mode()&&await e.oid()===await t.oid())}async function An({fs:e,dir:t,gitdir:n=H(t,`.git`),commit:r=`HEAD`,cache:i={}}){try{X(`fs`,e),X(`dir`,t),X(`gitdir`,n);let a=new Y(e),o=[J({ref:r}),hn(),ve()],s=[],c=await Z({fsp:a,dotgit:n});await R.acquire({fs:a,gitdir:c,cache:i},async function(e){s=e.unmergedPaths});let l=await bn({fs:a,cache:i,dir:t,gitdir:c,trees:o,map:async function(e,[t,n,r]){let i=!await kn(n,r),a=s.includes(e),o=!await kn(r,t);if(i||a)return t?{path:e,mode:await t.mode(),oid:await t.oid(),type:await t.type(),content:await t.content()}:void 0;if(o)return!1;throw new Xt(e)}});await R.acquire({fs:a,gitdir:c,cache:i},async function(e){for(let n of l)if(n!==!1){if(!n){await a.rmdir(`${t}/${n.path}`,{recursive:!0}),e.delete({filepath:n.path});continue}if(n.type===`blob`){let r=new TextDecoder().decode(n.content);await a.write(`${t}/${n.path}`,r,{mode:n.mode}),e.insert({filepath:n.path,oid:n.oid,stage:0})}}})}catch(e){throw e.caller=`git.abortMerge`,e}}var jn=class{static async isIgnored({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r}){if(pe(r)===`.git`)return!0;if(r===`.`)return!1;let i=``,a=H(n,`info`,`exclude`);await e.exists(a)&&(i=await e.read(a,`utf8`));let o=[{gitignore:H(t,`.gitignore`),filepath:r}],s=r.split(`/`).filter(Boolean);for(let e=1;e<s.length;e++){let n=s.slice(0,e).join(`/`),r=s.slice(e).join(`/`);o.push({gitignore:H(t,n,`.gitignore`),filepath:r})}let c=!1;for(let t of o){let n;try{n=await e.read(t.gitignore,`utf8`)}catch(e){if(e.code===`NOENT`)continue}let r=_().add(i);r.add(n);let a=z(t.filepath);if(a!==`.`&&r.ignores(a))return!0;c=c?!r.test(t.filepath).unignored:r.test(t.filepath).ignored}return c}};async function Mn({fs:e,gitdir:t,object:n,format:r,oid:i}){if(r!==`deflated`)throw new E(`GitObjectStoreLoose expects objects to write to be in deflated format`);let a=`${t}/${`objects/${i.slice(0,2)}/${i.slice(2)}`}`;await e.exists(a)||await e.write(a,n)}let Nn=null;async function Pn(e){return Nn===null&&(Nn=In()),Nn?Fn(e):u.deflate(e)}async function Fn(e){let t=new CompressionStream(`deflate`),n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function In(){try{return new CompressionStream(`deflate`).writable.close(),new Blob([]).stream().cancel(),!0}catch{return!1}}async function Q({fs:e,gitdir:t,type:n,object:i,format:a=`content`,oid:o=void 0,dryRun:s=!1}){return a!==`deflated`&&(a!==`wrapped`&&(i=tt.wrap({type:n,object:i})),o=await N(i),i=r.Buffer.from(await Pn(i))),s||await Mn({fs:e,gitdir:t,object:i,format:`deflated`,oid:o}),o}function Ln(e){let t;for(;~(t=e.indexOf(92));)e[t]=47;return e}async function Rn({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r,cache:i={},force:a=!1,parallel:o=!0}){try{X(`fs`,e),X(`dir`,t),X(`gitdir`,n),X(`filepath`,r);let s=new Y(e),c=await Z({fsp:s,dotgit:n});await R.acquire({fs:s,gitdir:c,cache:i},async e=>{let n=await(await U.get({fs:s,gitdir:c})).get(`core.autocrlf`);return zn({dir:t,gitdir:c,fs:s,filepath:r,index:e,force:a,parallel:o,autocrlf:n})})}catch(e){throw e.caller=`git.add`,e}}async function zn({dir:e,gitdir:t,fs:n,filepath:r,index:i,force:a,parallel:o,autocrlf:s}){r=Array.isArray(r)?r:[r];let c=r.map(async r=>{if(!a&&await jn.isIgnored({fs:n,dir:e,gitdir:t,filepath:r}))return;let c=await n.lstat(H(e,r));if(!c)throw new B(r);if(c.isDirectory()){let c=await n.readdir(H(e,r));if(o){let l=c.map(c=>zn({dir:e,gitdir:t,fs:n,filepath:[H(r,c)],index:i,force:a,parallel:o,autocrlf:s}));await Promise.all(l)}else for(let l of c)await zn({dir:e,gitdir:t,fs:n,filepath:[H(r,l)],index:i,force:a,parallel:o,autocrlf:s})}else{let a=c.isSymbolicLink()?await n.readlink(H(e,r)).then(Ln):await n.read(H(e,r),{autocrlf:s});if(a===null)throw new B(r);let o=await Q({fs:n,gitdir:t,type:`blob`,object:a});i.insert({filepath:r,stats:c,oid:o})}}),l=await Promise.allSettled(c),u=l.filter(e=>e.status===`rejected`).map(e=>e.reason);if(u.length>1)throw new Ht(u);if(u.length===1)throw u[0];return l.filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}async function Bn({fs:e,gitdir:t,path:n}){return(await U.get({fs:e,gitdir:t})).get(n)}function Vn(e,...t){for(let n of t)if(n)for(let t of Object.keys(n)){let r=n[t];r!==void 0&&(e[t]=r)}return e}async function Hn({fs:e,gitdir:t,author:n,commit:r}){let i=Math.floor(Date.now()/1e3),a=Vn({},{name:await Bn({fs:e,gitdir:t,path:`user.name`}),email:await Bn({fs:e,gitdir:t,path:`user.email`})||``,timestamp:i,timezoneOffset:new Date(i*1e3).getTimezoneOffset()},r?r.author:void 0,n);if(a.name!==void 0)return a}async function Un({fs:e,gitdir:t,author:n,committer:r,commit:i}){let a=Math.floor(Date.now()/1e3),o=Vn({},{name:await Bn({fs:e,gitdir:t,path:`user.name`}),email:await Bn({fs:e,gitdir:t,path:`user.email`})||``,timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},i?i.committer:void 0,n,r);if(o.name!==void 0)return o}async function Wn({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await K({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=cn.from(a).parse().object,Wn({fs:e,cache:t,gitdir:n,oid:r});if(i!==`commit`)throw new V(r,i,`commit`);return{commit:dn.from(a),oid:r}}async function Gn({fs:e,cache:t,gitdir:n,oid:r}){let{commit:i,oid:a}=await Wn({fs:e,cache:t,gitdir:n,oid:r});return{oid:a,commit:i.parse(),payload:i.withoutSignature()}}async function Kn({fs:e,cache:t,onSign:n,gitdir:r,message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,ref:d,parent:f,tree:p}){let m=!1,h=!1;d||=(h=!(await e.read(`${r}/HEAD`,{encoding:`utf8`})).startsWith(`ref:`),await W.resolve({fs:e,gitdir:r,ref:`HEAD`,depth:2}));let g,_;try{g=await W.resolve({fs:e,gitdir:r,ref:d}),_=await Gn({fs:e,gitdir:r,oid:g,cache:{}})}catch{m=!0}if(c&&m)throw new Zt(d);let v=c?await Hn({fs:e,gitdir:r,author:a,commit:_.commit}):await Hn({fs:e,gitdir:r,author:a});if(!v)throw new q(`author`);let y=c?await Un({fs:e,gitdir:r,author:v,committer:o,commit:_.commit}):await Un({fs:e,gitdir:r,author:v,committer:o});if(!y)throw new q(`committer`);return R.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async function(t){let a=me(t.entries).get(`.`);if(p||=await qn({fs:e,gitdir:r,inode:a,dryRun:l}),f=f?await Promise.all(f.map(t=>W.resolve({fs:e,gitdir:r,ref:t}))):c?_.commit.parent:g?[g]:[],!i)if(c)i=_.commit.message;else throw new Vt(`message`);let o=dn.from({tree:p,parent:f,author:v,committer:y,message:i});s&&(o=await dn.sign(o,n,s));let m=await Q({fs:e,gitdir:r,type:`commit`,object:o.toObject(),dryRun:l});return!u&&!l&&await W.writeRef({fs:e,gitdir:r,ref:h?`HEAD`:d,value:m}),m})}async function qn({fs:e,gitdir:t,inode:n,dryRun:r}){let i=n.children;for(let n of i)n.type===`tree`&&(n.metadata.mode=`040000`,n.metadata.oid=await qn({fs:e,gitdir:t,inode:n,dryRun:r}));let a=i.map(e=>({mode:e.metadata.mode,path:e.basename,oid:e.metadata.oid,type:e.type}));return await Q({fs:e,gitdir:t,type:`tree`,object:G.from(a).toObject(),dryRun:r})}async function Jn({fs:e,cache:t,gitdir:n,oid:r,filepath:i}){if(i.startsWith(`/`))throw new It(`leading-slash`);if(i.endsWith(`/`))throw new It(`trailing-slash`);let a=r,o=await fn({fs:e,cache:t,gitdir:n,oid:r}),s=o.tree;return r=i===``?o.oid:await Yn({fs:e,cache:t,gitdir:n,tree:s,pathArray:i.split(`/`),oid:a,filepath:i}),r}async function Yn({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o}){let s=i.shift();for(let c of r)if(c.path===s){if(i.length===0)return c.oid;{let{type:s,object:l}=await K({fs:e,cache:t,gitdir:n,oid:c.oid});if(s!==`tree`)throw new V(a,s,`tree`,o);return r=G.from(l),Yn({fs:e,cache:t,gitdir:n,tree:r,pathArray:i,oid:a,filepath:o})}}throw new B(`file or directory found at "${a}:${o}"`)}async function Xn({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){i!==void 0&&(r=await Jn({fs:e,cache:t,gitdir:n,oid:r,filepath:i}));let{tree:a,oid:o}=await fn({fs:e,cache:t,gitdir:n,oid:r});return{oid:o,tree:a.entries()}}async function Zn({fs:e,gitdir:t,tree:n}){return await Q({fs:e,gitdir:t,type:`tree`,object:G.from(n).toObject(),format:`content`})}async function Qn({fs:e,cache:t,onSign:n,gitdir:i,ref:a,oid:o,note:s,force:c,author:l,committer:u,signingKey:d}){let f;try{f=await W.resolve({gitdir:i,fs:e,ref:a})}catch(e){if(!(e instanceof B))throw e}let p=(await Xn({fs:e,cache:t,gitdir:i,oid:f||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;if(c)p=p.filter(e=>e.path!==o);else for(let e of p)if(e.path===o)throw new Et(`note`,o);typeof s==`string`&&(s=r.Buffer.from(s,`utf8`));let m=await Q({fs:e,gitdir:i,type:`blob`,object:s,format:`content`});return p.push({mode:`100644`,path:o,oid:m,type:`blob`}),await Kn({fs:e,cache:t,onSign:n,gitdir:i,ref:a,tree:await Zn({fs:e,gitdir:i,tree:p}),parent:f&&[f],message:`Note added by 'isomorphic-git addNote'
|
|
59
|
-
`,author:l,committer:u,signingKey:d})}async function $n({fs:e,onSign:t,dir:n,gitdir:r=H(n,`.git`),ref:i=`refs/notes/commits`,oid:a,note:o,force:s,author:c,committer:l,signingKey:u,cache:d={}}){try{X(`fs`,e),X(`gitdir`,r),X(`oid`,a),X(`note`,o),u&&X(`onSign`,t);let n=new Y(e),f=await Hn({fs:n,gitdir:r,author:c});if(!f)throw new q(`author`);let p=await Un({fs:n,gitdir:r,author:f,committer:l});if(!p)throw new q(`committer`);return await Qn({fs:n,cache:d,onSign:t,gitdir:await Z({fsp:n,dotgit:r}),ref:i,oid:a,note:o,force:s,author:f,committer:p,signingKey:u})}catch(e){throw e.caller=`git.addNote`,e}}let er=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function tr(e,t){if(typeof e!=`string`)throw TypeError(`Reference name must be a string`);return!er.test(e)&&(!!t||e.includes(`/`))}async function nr({fs:e,gitdir:t,remote:n,url:r,force:i}){if(!tr(n,!0))throw new Lt(n,v.clean(n));let a=await U.get({fs:e,gitdir:t});if(!i&&(await a.getSubsections(`remote`)).includes(n)&&r!==await a.get(`remote.${n}.url`))throw new Et(`remote`,n);await a.set(`remote.${n}.url`,r),await a.set(`remote.${n}.fetch`,`+refs/heads/*:refs/remotes/${n}/*`),await U.save({fs:e,gitdir:t,config:a})}async function rr({fs:e,dir:t,gitdir:n=H(t,`.git`),remote:r,url:i,force:a=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`remote`,r),X(`url`,i);let t=new Y(e);return await nr({fs:t,gitdir:await Z({fsp:t,dotgit:n}),remote:r,url:i,force:a})}catch(e){throw e.caller=`git.addRemote`,e}}async function ir({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1}){if(i=i.startsWith(`refs/tags/`)?i:`refs/tags/${i}`,!u&&await W.exists({fs:e,gitdir:r,ref:i}))throw new Et(`tag`,i);let d=await W.resolve({fs:e,gitdir:r,ref:c||`HEAD`}),{type:f}=await K({fs:e,cache:t,gitdir:r,oid:d}),p=cn.from({object:d,type:f,tag:i.replace(`refs/tags/`,``),tagger:a,message:o,gpgsig:s});l&&(p=await cn.sign(p,n,l));let m=await Q({fs:e,gitdir:r,type:`tag`,object:p.toObject()});await W.writeRef({fs:e,gitdir:r,ref:i,value:m})}async function ar({fs:e,onSign:t,dir:n,gitdir:r=H(n,`.git`),ref:i,tagger:a,message:o=i,gpgsig:s,object:c,signingKey:l,force:u=!1,cache:d={}}){try{X(`fs`,e),X(`gitdir`,r),X(`ref`,i),l&&X(`onSign`,t);let n=new Y(e),f=await Z({fsp:n,dotgit:r}),p=await Hn({fs:n,gitdir:f,author:a});if(!p)throw new q(`tagger`);return await ir({fs:n,cache:d,onSign:t,gitdir:f,ref:i,tagger:p,message:o,gpgsig:s,object:c,signingKey:l,force:u})}catch(e){throw e.caller=`git.annotatedTag`,e}}async function or({fs:e,gitdir:t,ref:n,object:r,checkout:i=!1,force:a=!1}){if(!tr(n,!0))throw new Lt(n,v.clean(n));let o=`refs/heads/${n}`;if(!a&&await W.exists({fs:e,gitdir:t,ref:o}))throw new Et(`branch`,n,!1);let s;try{s=await W.resolve({fs:e,gitdir:t,ref:r||`HEAD`})}catch{}s&&await W.writeRef({fs:e,gitdir:t,ref:o,value:s}),i&&await W.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function sr({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,object:i,checkout:a=!1,force:o=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let t=new Y(e);return await or({fs:t,gitdir:await Z({fsp:t,dotgit:n}),ref:r,object:i,checkout:a,force:o})}catch(e){throw e.caller=`git.branch`,e}}let cr=(e,t)=>e===`.`||t==null||t.length===0||t===`.`?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t);async function lr({fs:e,cache:t,onProgress:n,onPostCheckout:r,dir:i,gitdir:a,remote:o,ref:s,filepaths:c,noCheckout:l,noUpdateHead:u,dryRun:d,force:f,track:p=!0,nonBlocking:m=!1,batchSize:h=100}){let g;if(r)try{g=await W.resolve({fs:e,gitdir:a,ref:`HEAD`})}catch{g=`0000000000000000000000000000000000000000`}let _;try{_=await W.resolve({fs:e,gitdir:a,ref:s})}catch(t){if(s===`HEAD`)throw t;let n=`${o}/${s}`;if(_=await W.resolve({fs:e,gitdir:a,ref:n}),p){let t=await U.get({fs:e,gitdir:a});await t.set(`branch.${s}.remote`,o),await t.set(`branch.${s}.merge`,`refs/heads/${s}`),await U.save({fs:e,gitdir:a,config:t})}await W.writeRef({fs:e,gitdir:a,ref:`refs/heads/${s}`,value:_})}if(!l){let o;try{o=await ur({fs:e,cache:t,onProgress:n,dir:i,gitdir:a,ref:s,force:f,filepaths:c})}catch(e){throw e instanceof B&&e.data.what===_?new jt(s,_):e}let l=o.filter(([e])=>e===`conflict`).map(([e,t])=>t);if(l.length>0)throw new Ot(l);let u=o.filter(([e])=>e===`error`).map(([e,t])=>t);if(u.length>0)throw new E(u.join(`, `));if(d){r&&await r({previousHead:g,newHead:_,type:c!=null&&c.length>0?`file`:`branch`});return}let p=0,v=o.length;if(await R.acquire({fs:e,gitdir:a,cache:t},async function(t){await Promise.all(o.filter(([e])=>e===`delete`||e===`delete-index`).map(async function([r,a]){let o=`${i}/${a}`;r===`delete`&&await e.rm(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:v})}))}),await R.acquire({fs:e,gitdir:a,cache:t},async function(t){for(let[r,a]of o)if(r===`rmdir`||r===`rmdir-index`){let o=`${i}/${a}`;try{r===`rmdir`&&await e.rmdir(o),t.delete({filepath:a}),n&&await n({phase:`Updating workdir`,loaded:++p,total:v})}catch(e){if(e.code===`ENOTEMPTY`)console.log(`Did not delete ${a} because directory is not empty`);else throw e}}}),await Promise.all(o.filter(([e])=>e===`mkdir`||e===`mkdir-index`).map(async function([t,r]){let a=`${i}/${r}`;await e.mkdir(a),n&&await n({phase:`Updating workdir`,loaded:++p,total:v})})),m){let r=await pr(`Update Working Dir`,o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(([n,r,o,s,c])=>()=>fr({fs:e,cache:t,gitdir:a,dir:i},[n,r,o,s,c])),n,h);await R.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(e){await pr(`Update Index`,r.map(([t,n,r])=>()=>dr({index:e,fullpath:t,oid:n,stats:r})),n,h)})}else await R.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(r){let s=await Promise.allSettled(o.filter(([e])=>e===`create`||e===`create-index`||e===`update`||e===`mkdir-index`).map(async function([o,s,c,l,u]){let d=`${i}/${s}`;if(o!==`create-index`&&o!==`mkdir-index`){let{object:n}=await K({fs:e,cache:t,gitdir:a,oid:c});if(u&&await e.rm(d),l===33188)await e.write(d,n);else if(l===33261)await e.write(d,n,{mode:511});else if(l===40960)await e.writelink(d,n);else throw new E(`Invalid mode 0o${l.toString(8)} detected in blob ${c}`)}let f=await e.lstat(d);l===33261&&(f.mode=493),o===`mkdir-index`&&(f.mode=57344),r.insert({filepath:s,stats:f,oid:c}),n&&await n({phase:`Updating workdir`,loaded:++p,total:v})})),c=[];for(let e of s)e.status===`rejected`&&(c.push(e.reason),console.error(`[isomorphic-git checkout] task rejected:`,e.reason?.stack??e.reason));if(c.length>0)throw new Ht(c)});r&&await r({previousHead:g,newHead:_,type:c!=null&&c.length>0?`file`:`branch`})}if(!u){let t=await W.expand({fs:e,gitdir:a,ref:s});t.startsWith(`refs/heads`)?await W.writeSymbolicRef({fs:e,gitdir:a,ref:`HEAD`,value:t}):await W.writeRef({fs:e,gitdir:a,ref:`HEAD`,value:_})}}async function ur({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,ref:a,force:o,filepaths:s}){let c=0;return bn({fs:e,cache:t,dir:r,gitdir:i,trees:[J({ref:a}),hn(),ve()],map:async function(e,[t,r,i]){if(e!==`.`){if(s&&!s.some(t=>cr(e,t)))return null;switch(n&&await n({phase:`Analyzing workdir`,loaded:++c}),[!!i,!!t,!!r].map(Number).join(``)){case`000`:return;case`001`:return o&&s&&s.includes(e)?[`delete`,e]:void 0;case`010`:switch(await t.type()){case`tree`:return[`mkdir`,e];case`blob`:return[`create`,e,await t.oid(),await t.mode()];case`commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`new entry Unhandled type ${await t.type()}`]}case`011`:switch(`${await t.type()}-${await r.type()}`){case`tree-tree`:return;case`tree-blob`:case`blob-tree`:return[`conflict`,e];case`blob-blob`:return await t.oid()===await r.oid()?await t.mode()===await r.mode()?[`create-index`,e,await t.oid(),await t.mode()]:o?[`update`,e,await t.oid(),await t.mode(),!0]:[`conflict`,e]:o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e];case`commit-tree`:return;case`commit-blob`:return[`conflict`,e];default:return[`error`,`new entry Unhandled type ${t.type}`]}case`100`:return[`delete-index`,e];case`101`:switch(await i.type()){case`tree`:return[`rmdir-index`,e];case`blob`:return await i.oid()===await r.oid()||o?[`delete`,e]:[`conflict`,e];case`commit`:return[`rmdir-index`,e];default:return[`error`,`delete entry Unhandled type ${await i.type()}`]}case`110`:case`111`:switch(`${await i.type()}-${await t.type()}`){case`tree-tree`:return;case`blob-blob`:if(await i.oid()===await t.oid()&&await i.mode()===await t.mode()&&!o)return;if(r){if(await r.oid()!==await i.oid()&&await r.oid()!==await t.oid())return o?[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await r.mode()]:[`conflict`,e]}else if(o)return[`update`,e,await t.oid(),await t.mode(),await t.mode()!==await i.mode()];return await t.mode()===await i.mode()?await t.oid()===await i.oid()?void 0:[`update`,e,await t.oid(),await t.mode(),!1]:[`update`,e,await t.oid(),await t.mode(),!0];case`tree-blob`:return[`update-dir-to-blob`,e,await t.oid()];case`blob-tree`:return[`update-blob-to-tree`,e];case`commit-commit`:return[`mkdir-index`,e,await t.oid(),await t.mode()];default:return[`error`,`update entry Unhandled type ${await i.type()}-${await t.type()}`]}}}},reduce:async function(e,t){return t=_n(t),e?e&&e[0]===`rmdir`?(t.push(e),t):(t.unshift(e),t):t}})}async function dr({index:e,fullpath:t,stats:n,oid:r}){try{e.insert({filepath:t,stats:n,oid:r})}catch(e){console.warn(`Error inserting ${t} into index:`,e)}}async function fr({fs:e,cache:t,gitdir:n,dir:r},[i,a,o,s,c]){let l=`${r}/${a}`;if(i!==`create-index`&&i!==`mkdir-index`){let{object:r}=await K({fs:e,cache:t,gitdir:n,oid:o});if(c&&await e.rm(l),s===33188)await e.write(l,r);else if(s===33261)await e.write(l,r,{mode:511});else if(s===40960)await e.writelink(l,r);else throw new E(`Invalid mode 0o${s.toString(8)} detected in blob ${o}`)}let u=await e.lstat(l);return s===33261&&(u.mode=493),i===`mkdir-index`&&(u.mode=57344),[a,o,u]}async function pr(e,t,n,r){let i=[],a=[];for(let o=0;o<t.length;o+=r){let s=t.slice(o,o+r).map(e=>e());(await Promise.allSettled(s)).forEach(t=>{t.status===`fulfilled`?i.push(t.value):(a.push(t.reason),console.error(`[isomorphic-git ${e}] task rejected:`,t.reason?.stack??t.reason))}),n&&await n({phase:`Updating workdir`,loaded:o+s.length,total:t.length})}if(a.length>0)throw new Ht(a);return i}async function mr({fs:e,onProgress:t,onPostCheckout:n,dir:r,gitdir:i=H(r,`.git`),remote:a=`origin`,ref:o,filepaths:s,noCheckout:c=!1,noUpdateHead:l=o===void 0,dryRun:u=!1,force:d=!1,track:f=!0,cache:p={},nonBlocking:m=!1,batchSize:h=100}){try{X(`fs`,e),X(`dir`,r),X(`gitdir`,i);let g=o||`HEAD`,_=new Y(e);return await lr({fs:_,cache:p,onProgress:t,onPostCheckout:n,dir:r,gitdir:await Z({fsp:_,dotgit:i}),remote:a,ref:g,filepaths:s,noCheckout:c,noUpdateHead:l,dryRun:u,force:d,track:f,nonBlocking:m,batchSize:h})}catch(e){throw e.caller=`git.checkout`,e}}let hr=/^.*(\r?\n|$)/gm;function gr({branches:e,contents:t}){let n=e[1],r=e[2],i=t[0],a=t[1],o=t[2],s=y(a.match(hr),i.match(hr),o.match(hr)),c=``,l=!0;for(let e of s)e.ok&&(c+=e.ok.join(``)),e.conflict&&(l=!1,c+=`${`<`.repeat(7)} ${n}\n`,c+=e.conflict.a.join(``),c+=`${`=`.repeat(7)}\n`,c+=e.conflict.b.join(``),c+=`${`>`.repeat(7)} ${r}\n`);return{cleanMerge:l,mergedText:c}}async function _r({fs:e,cache:t,dir:n,gitdir:r=H(n,`.git`),index:i,ourOid:a,baseOid:o,theirOid:s,ourName:c=`ours`,baseName:l=`base`,theirName:u=`theirs`,dryRun:d=!1,abortOnConflict:f=!0,mergeDriver:p}){let m=J({ref:a}),h=J({ref:o}),g=J({ref:s}),_=[],v=[],y=[],b=[],x=await bn({fs:e,cache:t,dir:n,gitdir:r,trees:[m,h,g],map:async function(t,[n,a,o]){let s=pe(t);switch(`${await kn(n,a)}-${await kn(o,a)}`){case`false-false`:return{mode:await a.mode(),path:s,oid:await a.oid(),type:await a.type()};case`false-true`:return!o&&await n.type()===`tree`?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:o?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:void 0;case`true-false`:return!n&&await o.type()===`tree`?{mode:await o.mode(),path:s,oid:await o.oid(),type:await o.type()}:n?{mode:await n.mode(),path:s,oid:await n.oid(),type:await n.type()}:void 0;case`true-true`:if(n&&o&&await n.type()===`tree`&&await o.type()===`tree`)return{mode:await n.mode(),path:s,oid:await n.oid(),type:`tree`};if(n&&o&&await n.type()===`blob`&&await o.type()===`blob`)return vr({fs:e,gitdir:r,path:s,ours:n,base:a,theirs:o,ourName:c,baseName:l,theirName:u,mergeDriver:p}).then(async e=>{if(e.cleanMerge)f||i.insert({filepath:t,oid:e.mergeResult.oid,stage:0});else if(_.push(t),v.push(t),!f){let e=``;a&&await a.type()===`blob`&&(e=await a.oid());let r=await n.oid(),s=await o.oid();i.delete({filepath:t}),e&&i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2}),i.insert({filepath:t,oid:s,stage:3})}return e.mergeResult});if(a&&!n&&o&&await a.type()===`blob`&&await o.type()===`blob`){if(_.push(t),y.push(t),!f){let e=await a.oid(),n=await o.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:n,stage:3})}return{mode:await o.mode(),oid:await o.oid(),type:`blob`,path:s}}if(a&&n&&!o&&await a.type()===`blob`&&await n.type()===`blob`){if(_.push(t),b.push(t),!f){let e=await a.oid(),r=await n.oid();i.delete({filepath:t}),i.insert({filepath:t,oid:e,stage:1}),i.insert({filepath:t,oid:r,stage:2})}return{mode:await n.mode(),oid:await n.oid(),type:`blob`,path:s}}if(a&&!n&&!o&&(await a.type()===`blob`||await a.type()===`tree`))return;throw new zt}},reduce:_.length!==0&&(!n||f)?void 0:async(t,n)=>{let i=n.filter(Boolean);if(t&&!(t&&t.type===`tree`&&i.length===0&&t.path!==`.`))return(i.length>0||t.path===`.`&&i.length===0)&&(t.oid=await Q({fs:e,gitdir:r,type:`tree`,object:new G(i).toObject(),dryRun:d})),t}});return _.length===0?x.oid:(n&&!f&&await bn({fs:e,cache:t,dir:n,gitdir:r,trees:[J({ref:x.oid})],map:async function(t,[r]){let i=`${n}/${t}`;if(await r.type()===`blob`){let t=await r.mode(),n=new TextDecoder().decode(await r.content());await e.write(i,n,{mode:t})}return!0}}),new Bt(_,v,y,b))}async function vr({fs:e,gitdir:t,path:n,ours:i,base:a,theirs:o,ourName:s,theirName:c,baseName:l,dryRun:u,mergeDriver:d=gr}){let f=`blob`,p=`100755`,m=``,h=``;a&&await a.type()===`blob`&&(p=await a.mode(),m=await a.oid(),h=r.Buffer.from(await a.content()).toString(`utf8`));let g=p===await i.mode()?await o.mode():await i.mode();if(await i.oid()===await o.oid())return{cleanMerge:!0,mergeResult:{mode:g,path:n,oid:await i.oid(),type:f}};if(await i.oid()===m)return{cleanMerge:!0,mergeResult:{mode:g,path:n,oid:await o.oid(),type:f}};if(await o.oid()===m)return{cleanMerge:!0,mergeResult:{mode:g,path:n,oid:await i.oid(),type:f}};let _=r.Buffer.from(await i.content()).toString(`utf8`),v=r.Buffer.from(await o.content()).toString(`utf8`),{mergedText:y,cleanMerge:b}=await d({branches:[l,s,c],contents:[h,_,v],path:n});return{cleanMerge:b,mergeResult:{mode:g,path:n,oid:await Q({fs:e,gitdir:t,type:`blob`,object:r.Buffer.from(y,`utf8`),dryRun:u}),type:f}}}let yr={stage:ve,workdir:hn},br;async function xr(e,t){return br===void 0&&(br=new s),br.acquire(e,t)}async function Sr(e,t,n,r,i=null){let a=H(n,r),o=await e.lstat(a);if(!o)throw new B(a);if(o.isDirectory())throw new E(`${a}: file expected, but found directory`);let s=i?await nt({fs:e,gitdir:t,oid:i}):void 0,c=s?i:void 0;return s||await xr({fs:e,gitdir:t,currentFilepath:a},async()=>{let n=o.isSymbolicLink()?await e.readlink(a).then(Ln):await e.read(a);if(n===null)throw new B(a);c=await Q({fs:e,gitdir:t,type:`blob`,object:n})}),c}async function Cr({fs:e,dir:t,gitdir:n,entries:r}){async function i(r){return r.type===`tree`?r.oid||(r.oid=await Zn({fs:e,gitdir:n,tree:await Promise.all(r.children.map(i))}),r.mode=16384):r.type===`blob`&&(r.oid=await Sr(e,n,t,r.path,r.oid),r.mode=33188),r.path=r.path.split(`/`).pop(),r}return Promise.all(r.map(i))}async function wr({fs:e,dir:t,gitdir:n,treePair:r}){let i=r[1]===`stage`,a=r.map(e=>typeof e==`string`?yr[e]():e),o=[],s=await bn({fs:e,cache:{},dir:t,gitdir:n,trees:a,map:async(r,[i,a])=>{if(!(r===`.`||await jn.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))&&a)return(!i||await i.oid()!==await a.oid()&&await a.oid()!==void 0)&&o.push([i,a]),{mode:await a.mode(),path:r,oid:await a.oid(),type:await a.type()}},reduce:async(e,t)=>(t=t.filter(Boolean),e?(e.children=t,e):t.length>0?t:void 0),iterate:async(n,r)=>{let a=[];for(let n of r){let[r,s]=n;i?s&&(await e.exists(`${t}/${s.toString()}`)?a.push(n):o.push([null,s])):r&&(s?a.push(n):o.push([r,null]))}return a.length?Promise.all(a.map(n)):[]}});return o.length===0||s.length===0?null:Zn({fs:e,gitdir:n,tree:(await Cr({fs:e,dir:t,gitdir:n,entries:s})).filter(Boolean).map(e=>({mode:e.mode,path:e.path,oid:e.oid,type:e.type}))})}async function Tr({fs:e,dir:t,gitdir:n,stashCommit:r,parentCommit:i,wasStaged:a}){let o=[],s=[],c=await bn({fs:e,cache:{},dir:t,gitdir:n,trees:[J({ref:i}),J({ref:r})],map:async(r,[i,c])=>{if(r===`.`||await jn.isIgnored({fs:e,dir:t,gitdir:n,filepath:r}))return;let l=c?await c.type():await i.type();if(l!==`tree`&&l!==`blob`)return;if(!c&&i){let e=l===`tree`?`rmdir`:`rm`;return l===`tree`&&o.push(r),l===`blob`&&a&&s.push({filepath:r,oid:await i.oid()}),{method:e,filepath:r}}let u=await c.oid();if(!i||await i.oid()!==u)return l===`tree`?{method:`mkdir`,filepath:r}:(a&&s.push({filepath:r,oid:u,stats:await e.lstat(H(t,r))}),{method:`write`,filepath:r,oid:u})}});await xr({fs:e,gitdir:n,dirRemoved:o,ops:c},async()=>{for(let r of c){let i=H(t,r.filepath);switch(r.method){case`rmdir`:await e.rmdir(i);break;case`mkdir`:await e.mkdir(i);break;case`rm`:await e.rm(i);break;case`write`:if(!o.some(e=>i.startsWith(e))){let{object:t}=await K({fs:e,cache:{},gitdir:n,oid:r.oid});await e.exists(i)&&await e.rm(i),await e.write(i,t)}break}}}),await R.acquire({fs:e,gitdir:n,cache:{}},async e=>{s.forEach(({filepath:t,stats:n,oid:r})=>{e.insert({filepath:t,stats:n,oid:r})})})}async function Er({fs:e,cache:t,dir:n,gitdir:r,oid:i,dryRun:a=!1,noUpdateBranch:o=!1,abortOnConflict:s=!0,committer:c,mergeDriver:l}){let{commit:u,oid:d}=await Gn({fs:e,cache:t,gitdir:r,oid:i});if(u.parent.length>1)throw new kt(d,u.parent.length);if(u.parent.length===0)throw new At(d);let f=await W.resolve({fs:e,gitdir:r,ref:`HEAD`}),{commit:p}=await Gn({fs:e,cache:t,gitdir:r,oid:f}),m=u.parent[0],{commit:h}=await Gn({fs:e,cache:t,gitdir:r,oid:m}),g=await R.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async i=>_r({fs:e,cache:t,dir:n,gitdir:r,index:i,ourOid:p.tree,baseOid:h.tree,theirOid:u.tree,ourName:`HEAD`,baseName:`parent of ${d.slice(0,7)}`,theirName:d.slice(0,7),dryRun:a,abortOnConflict:s,mergeDriver:l}));if(g instanceof Bt)throw g;let _=await Kn({fs:e,cache:t,gitdir:r,message:u.message,tree:g,parent:[f],author:u.author,committer:c,dryRun:a,noUpdateBranch:o});return n&&!a&&!o&&await Tr({fs:e,dir:n,gitdir:r,stashCommit:_,parentCommit:f,wasStaged:!0}),_}async function Dr({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,cache:i={},committer:a,dryRun:o=!1,noUpdateBranch:s=!1,abortOnConflict:c=!0,mergeDriver:l}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let u=new Y(e),d=await Z({fsp:u,dotgit:n}),{commit:f}=await Gn({fs:u,cache:i,gitdir:d,oid:r});if(f.parent&&f.parent.length>1)return await Er({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:void 0,mergeDriver:l});let p=await Un({fs:u,gitdir:d,committer:a});if(!p)throw new q(`committer`);return await Er({fs:u,cache:i,dir:t,gitdir:d,oid:r,dryRun:o,noUpdateBranch:s,abortOnConflict:c,committer:p,mergeDriver:l})}catch(e){throw e.caller=`git.cherryPick`,e}}let Or=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function kr(e){let t=Or.exec(e);return t?t[1]===`remotes/`&&e.endsWith(`/HEAD`)?t[2].slice(0,-5):t[2]:e}async function Ar({fs:e,gitdir:t,fullname:n=!1,test:r=!1}){let i=await W.resolve({fs:e,gitdir:t,ref:`HEAD`,depth:2});if(r)try{await W.resolve({fs:e,gitdir:t,ref:i})}catch{return}if(i.startsWith(`refs/`))return n?i:kr(i)}function jr(e){return e=e.replace(/^git@([^:]+):/,`https://$1/`),e=e.replace(/^ssh:\/\//,`https://`),e}function Mr({username:e=``,password:t=``}){return`Basic ${r.Buffer.from(`${e}:${t}`).toString(`base64`)}`}async function Nr(e,t){let n=ct(e);for(;;){let{value:e,done:r}=await n.next();if(e&&await t(e),r)break}n.return&&n.return()}async function Pr(e){let t=0,n=[];await Nr(e,e=>{n.push(e),t+=e.byteLength});let r=new Uint8Array(t),i=0;for(let e of n)r.set(e,i),i+=e.byteLength;return r}function Fr(e){let t=e.match(/^https?:\/\/([^/]+)@/);if(t==null)return{url:e,auth:{}};t=t[1];let[n,r]=t.split(`:`);return e=e.replace(`${t}@`,``),{url:e,auth:{username:n,password:r}}}function Ir(e,t){let n=t.toString(16);return`0`.repeat(e-n.length)+n}var $=class{static flush(){return r.Buffer.from(`0000`,`utf8`)}static delim(){return r.Buffer.from(`0001`,`utf8`)}static encode(e){typeof e==`string`&&(e=r.Buffer.from(e));let t=Ir(4,e.length+4);return r.Buffer.concat([r.Buffer.from(t,`utf8`),e])}static streamReader(e){let t=new lt(e);return async function(){try{let e=await t.read(4);return e==null?!0:(e=parseInt(e.toString(`utf8`),16),e===0||e===1?null:await t.read(e-4)??!0)}catch(t){return e.error=t,!0}}}};async function Lr(e){let t={},n;for(;n=await e(),n!==!0;){if(n===null)continue;n=n.toString(`utf8`).replace(/\n$/,``);let e=n.indexOf(`=`);if(e>-1){let r=n.slice(0,e);t[r]=n.slice(e+1)}else t[n]=!0}return{protocolVersion:2,capabilities2:t}}async function Rr(e,{service:t}){let n=new Set,r=new Map,i=new Map,a=$.streamReader(e),o=await a();for(;o===null;)o=await a();if(o===!0)throw new Mt;if(o.includes(`version 2`))return Lr(a);if(o.toString(`utf8`).replace(/\n$/,``)!==`# service=${t}`)throw new Ut(`# service=${t}\\n`,o.toString(`utf8`));let s=await a();for(;s===null;)s=await a();if(s===!0)return{capabilities:n,refs:r,symrefs:i};if(s=s.toString(`utf8`),s.includes(`version 2`))return Lr(a);let[c,l]=zr(s,`\0`,`\\x00`);if(l.split(` `).map(e=>n.add(e)),c!==`0000000000000000000000000000000000000000 capabilities^{}`){let[e,t]=zr(c,` `,` `);for(r.set(t,e);;){let e=await a();if(e===!0)break;if(e!==null){let[t,n]=zr(e.toString(`utf8`),` `,` `);r.set(n,t)}}}for(let e of n)if(e.startsWith(`symref=`)){let t=e.match(/symref=([^:]+):(.*)/);t.length===3&&i.set(t[1],t[2])}return{protocolVersion:1,capabilities:n,refs:r,symrefs:i}}function zr(e,t,n){let r=e.trim().split(t);if(r.length!==2)throw new Ut(`Two strings separated by '${n}'`,e.toString(`utf8`));return r}let Br=(e,t)=>e.endsWith(`?`)?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,``)}`,Vr=(e,t)=>{(t.username||t.password)&&(e.Authorization=Mr(t)),t.headers&&Object.assign(e,t.headers)},Hr=async e=>{try{let t=r.Buffer.from(await Pr(e.body)),n=t.toString(`utf8`);return{preview:n.length<256?n:n.slice(0,256)+`...`,response:n,data:t}}catch{return{}}};var Ur=class{static async capabilities(){return[`discover`,`connect`]}static async discover({http:e,onProgress:t,onAuth:n,onAuthSuccess:r,onAuthFailure:i,corsProxy:a,service:o,url:s,headers:c,protocolVersion:l}){let{url:u,auth:d}=Fr(s),f=a?Br(a,u):u;(d.username||d.password)&&(c.Authorization=Mr(d)),l===2&&(c[`Git-Protocol`]=`version=2`);let p,m,h=!1;do if(p=await e.request({onProgress:t,method:`GET`,url:`${f}/info/refs?service=${o}`,headers:c}),m=!1,p.statusCode===401||p.statusCode===203){let e=h?i:n;if(e){if(d=await e(u,{...d,headers:{...c}}),d&&d.cancel)throw new Yt;d&&(Vr(c,d),h=!0,m=!0)}}else p.statusCode===200&&h&&r&&await r(u,d);while(m);if(p.statusCode!==200){let{response:e}=await Hr(p);throw new Ft(p.statusCode,p.statusMessage,e)}if(p.headers[`content-type`]===`application/x-${o}-advertisement`){let e=await Rr(p.body,{service:o});return e.auth=d,e}else{let{preview:e,response:t,data:n}=await Hr(p);try{let e=await Rr([n],{service:o});return e.auth=d,e}catch{throw new Kt(e,t)}}}static async connect({http:e,onProgress:t,corsProxy:n,service:r,url:i,auth:a,body:o,headers:s}){let c=Fr(i);c&&(i=c.url),n&&(i=Br(n,i)),s[`content-type`]=`application/x-${r}-request`,s.accept=`application/x-${r}-result`,Vr(s,a);let l=await e.request({onProgress:t,method:`POST`,url:`${i}/${r}`,body:o,headers:s});if(l.statusCode!==200){let{response:e}=Hr(l);throw new Ft(l.statusCode,l.statusMessage,e)}return l}},Wr=class{static getRemoteHelperFor({url:e}){let t=new Map;t.set(`http`,Ur),t.set(`https`,Ur);let n=Gr({url:e});if(!n)throw new Jt(e);if(t.has(n.transport))return t.get(n.transport);throw new qt(e,n.transport,n.transport===`ssh`?jr(e):void 0)}};function Gr({url:e}){if(e.startsWith(`git@`))return{transport:`ssh`,address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]===`://`)return{transport:t[1],address:t[0]};if(t[2]===`::`)return{transport:t[1],address:t[3]}}}let Kr=null;var qr=class{static async read({fs:e,gitdir:t}){Kr===null&&(Kr=new s);let n=H(t,`shallow`),r=new Set;return await Kr.acquire(n,async function(){let t=await e.read(n,{encoding:`utf8`});if(t===null||t.trim()===``)return r;t.trim().split(`
|
|
60
|
-
`).map(e=>r.add(e))}),r}static async write({fs:e,gitdir:t,oids:n}){Kr===null&&(Kr=new s);let r=H(t,`shallow`);if(n.size>0){let t=[...n].join(`
|
|
61
|
-
`)+`
|
|
62
|
-
`;await Kr.acquire(r,async function(){await e.write(r,t,{encoding:`utf8`})})}else await Kr.acquire(r,async function(){await e.rm(r)})}};async function Jr({fs:e,gitdir:t,oid:n}){let r=`objects/${n.slice(0,2)}/${n.slice(2)}`;return e.exists(`${t}/${r}`)}async function Yr({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=await e.readdir(H(n,`objects/pack`));a=a.filter(e=>e.endsWith(`.idx`));for(let o of a){let a=await St({fs:e,cache:t,filename:`${n}/objects/pack/${o}`,getExternalRefDelta:i});if(a.error)throw new E(a.error);if(a.offsets.has(r))return!0}return!1}async function Xr({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>K({fs:e,cache:t,gitdir:n,oid:r}),o=await Jr({fs:e,gitdir:n,oid:r});return o||=await Yr({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),o}function Zr(e){return e.slice(0,12).toString(`hex`)===`5041434b0000000200000000`}function Qr(e,t){let n=e.map(e=>e.split(`=`,1)[0]);return t.filter(e=>{let t=e.split(`=`,1)[0];return n.includes(t)})}let $r={name:`isomorphic-git`,version:`1.37.6`,agent:`git/isomorphic-git@1.37.6`};var ei=class{constructor(){this._queue=[]}write(e){if(this._ended)throw Error(`You cannot write to a FIFO that has already been ended!`);if(this._waiting){let t=this._waiting;this._waiting=null,t({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){let e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error(`You cannot call read until the previous call to read has returned!`);return new Promise(e=>{this._waiting=e})}};function ti(e){let t=e.indexOf(`\r`),n=e.indexOf(`
|
|
63
|
-
`);return t===-1&&n===-1?-1:t===-1?n+1:n===-1?t+1:n===t+1?n+1:Math.min(t,n)+1}function ni(e){let t=new ei,n=``;return(async()=>{await Nr(e,e=>{for(e=e.toString(`utf8`),n+=e;;){let e=ti(n);if(e===-1)break;t.write(n.slice(0,e)),n=n.slice(e)}}),n.length>0&&t.write(n),t.end()})(),t}var ri=class{static demux(e){let t=$.streamReader(e),n=new ei,r=new ei,i=new ei,a=async function(){let o=await t();if(o===null)return a();if(o===!0){n.end(),i.end(),e.error?r.destroy(e.error):r.end();return}switch(o[0]){case 1:r.write(o.slice(1));break;case 2:i.write(o.slice(1));break;case 3:{let e=o.slice(1);i.write(e),n.end(),i.end(),r.destroy(Error(e.toString(`utf8`)));return}default:n.write(o)}a()};return a(),{packetlines:n,packfile:r,progress:i}}};async function ii(e){let{packetlines:t,packfile:n,progress:r}=ri.demux(e),i=[],a=[],o=[],s=!1,c=!1;return new Promise((l,u)=>{Nr(t,t=>{let d=t.toString(`utf8`).trim();if(d.startsWith(`shallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new ye(e)),i.push(e)}else if(d.startsWith(`unshallow`)){let e=d.slice(-41).trim();e.length!==40&&u(new ye(e)),a.push(e)}else if(d.startsWith(`ACK`)){let[,e,t]=d.split(` `);o.push({oid:e,status:t}),t||(c=!0)}else d.startsWith(`NAK`)?(s=!0,c=!0):(c=!0,s=!0);c&&(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))}).finally(()=>{c||(e.error?u(e.error):l({shallows:i,unshallows:a,acks:o,nak:s,packfile:n,progress:r}))})})}function ai({capabilities:e=[],wants:t=[],haves:n=[],shallows:r=[],depth:i=null,since:a=null,exclude:o=[]}){let s=[];t=[...new Set(t)];let c=` ${e.join(` `)}`;for(let e of t)s.push($.encode(`want ${e}${c}\n`)),c=``;for(let e of r)s.push($.encode(`shallow ${e}\n`));i!==null&&s.push($.encode(`deepen ${i}\n`)),a!==null&&s.push($.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}\n`));for(let e of o)s.push($.encode(`deepen-not ${e}\n`));s.push($.flush());for(let e of n)s.push($.encode(`have ${e}\n`));return s.push($.encode(`done
|
|
64
|
-
`)),s}async function oi({fs:e,cache:t,http:n,onProgress:i,onMessage:a,onAuth:o,onAuthSuccess:s,onAuthFailure:c,gitdir:l,ref:u,remoteRef:d,remote:f,url:p,corsProxy:m,depth:h=null,since:g=null,exclude:_=[],relative:v=!1,tags:y=!1,singleBranch:b=!1,headers:x={},prune:S=!1,pruneTags:C=!1}){let w=u||await Ar({fs:e,gitdir:l,test:!0}),T=await U.get({fs:e,gitdir:l}),ee=f||w&&await T.get(`branch.${w}.remote`)||`origin`,E=p||await T.get(`remote.${ee}.url`);if(E===void 0)throw new Vt(`remote OR url`);let D=d||w&&await T.get(`branch.${w}.merge`)||u||`HEAD`;m===void 0&&(m=await T.get(`http.corsProxy`));let O=Wr.getRemoteHelperFor({url:E}),k=await O.discover({http:n,onAuth:o,onAuthSuccess:s,onAuthFailure:c,corsProxy:m,service:`git-upload-pack`,url:E,headers:x,protocolVersion:1}),te=k.auth,A=k.refs;if(A.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(h!==null&&!k.capabilities.has(`shallow`))throw new Gt(`shallow`,`depth`);if(g!==null&&!k.capabilities.has(`deepen-since`))throw new Gt(`deepen-since`,`since`);if(_.length>0&&!k.capabilities.has(`deepen-not`))throw new Gt(`deepen-not`,`exclude`);if(v===!0&&!k.capabilities.has(`deepen-relative`))throw new Gt(`deepen-relative`,`relative`);let{oid:j,fullref:M}=W.resolveAgainstMap({ref:D,map:A});for(let e of A.keys())e===M||e===`HEAD`||e.startsWith(`refs/heads/`)||y&&e.startsWith(`refs/tags/`)||A.delete(e);let ne=Qr([...k.capabilities],[`multi_ack_detailed`,`no-done`,`side-band-64k`,`ofs-delta`,`agent=${$r.agent}`]);v&&ne.push(`deepen-relative`);let re=b?[j]:A.values(),ie=b?[w]:await W.listRefs({fs:e,gitdir:l,filepath:`refs`}),N=[];for(let n of ie)try{n=await W.expand({fs:e,gitdir:l,ref:n});let r=await W.resolve({fs:e,gitdir:l,ref:n});await Xr({fs:e,cache:t,gitdir:l,oid:r})&&N.push(r)}catch{}N=[...new Set(N)];let ae=await qr.read({fs:e,gitdir:l}),oe=k.capabilities.has(`shallow`)?[...ae]:[],se=ai({capabilities:ne,wants:re,haves:N,shallows:oe,depth:h,since:g,exclude:_}),ce=r.Buffer.from(await Pr(se)),le=await O.connect({http:n,onProgress:i,corsProxy:m,service:`git-upload-pack`,url:E,auth:te,body:[ce],headers:x}),P=await ii(le.body);le.headers&&(P.headers=le.headers);for(let n of P.shallows)if(!ae.has(n))try{let{object:r}=await K({fs:e,cache:t,gitdir:l,oid:n}),i=new dn(r),a=await Promise.all(i.headers().parent.map(n=>Xr({fs:e,cache:t,gitdir:l,oid:n})));a.length===0||a.every(e=>e)||ae.add(n)}catch{ae.add(n)}for(let e of P.unshallows)ae.delete(e);if(await qr.write({fs:e,gitdir:l,oids:ae}),b){let t=new Map([[M,j]]),n=new Map,r=10,i=M;for(;r--;){let e=k.symrefs.get(i);if(e===void 0)break;n.set(i,e),i=e}let a=A.get(i);a&&t.set(i,a);let{pruned:o}=await W.updateRemoteRefs({fs:e,gitdir:l,remote:ee,refs:t,symrefs:n,tags:y,prune:S});S&&(P.pruned=o)}else{let{pruned:t}=await W.updateRemoteRefs({fs:e,gitdir:l,remote:ee,refs:A,symrefs:k.symrefs,tags:y,prune:S,pruneTags:C});S&&(P.pruned=t)}if(P.HEAD=k.symrefs.get(`HEAD`),P.HEAD===void 0){let{oid:e}=W.resolveAgainstMap({ref:`HEAD`,map:A});for(let[t,n]of A.entries())if(t!==`HEAD`&&n===e){P.HEAD=t;break}}P.FETCH_HEAD={oid:j,description:`${M.startsWith(`refs/tags`)?`tag`:`branch`} '${kr(M)}' of ${E}`},(i||a)&&Nr(ni(P.progress),async e=>{if(a&&await a(e),i){let t=e.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);t&&await i({phase:t[1].trim(),loaded:parseInt(t[2],10),total:parseInt(t[3],10)})}});let F=r.Buffer.from(await Pr(P.packfile));if(le.body.error)throw le.body.error;let ue=F.slice(-20).toString(`hex`),I={defaultBranch:P.HEAD,fetchHead:P.FETCH_HEAD.oid,fetchHeadDescription:P.FETCH_HEAD.description};if(P.headers&&(I.headers=P.headers),S&&(I.pruned=P.pruned),ue!==``&&!Zr(F)){I.packfile=`objects/pack/pack-${ue}.pack`;let n=H(l,I.packfile);await e.write(n,F);let r=await yt.fromPack({pack:F,getExternalRefDelta:n=>K({fs:e,cache:t,gitdir:l,oid:n}),onProgress:i});await e.write(n.replace(/\.pack$/,`.idx`),await r.toBuffer())}return I}async function si({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:H(n,`.git`),defaultBranch:i=`master`}){if(await e.exists(r+`/config`))return;let a=[`hooks`,`info`,`objects/info`,`objects/pack`,`refs/heads`,`refs/tags`];a=a.map(e=>r+`/`+e);for(let t of a)await e.mkdir(t);await e.write(r+`/config`,`[core]
|
|
65
|
-
repositoryformatversion = 0
|
|
66
|
-
filemode = false
|
|
67
|
-
\tbare = ${t}\n`+(t?``:` logallrefupdates = true
|
|
68
|
-
`)+` symlinks = false
|
|
69
|
-
ignorecase = true
|
|
70
|
-
`),await e.write(r+`/HEAD`,`ref: refs/heads/${i}\n`)}async function ci({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPostCheckout:c,dir:l,gitdir:u,url:d,corsProxy:f,ref:p,remote:m,depth:h,since:g,exclude:_,relative:v,singleBranch:y,noCheckout:b,noTags:x,headers:S,nonBlocking:C,batchSize:w=100}){try{if(await si({fs:e,gitdir:u}),await nr({fs:e,gitdir:u,remote:m,url:d,force:!1}),f){let t=await U.get({fs:e,gitdir:u});await t.set(`http.corsProxy`,f),await U.save({fs:e,gitdir:u,config:t})}let{defaultBranch:T,fetchHead:ee}=await oi({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:u,ref:p,remote:m,corsProxy:f,depth:h,since:g,exclude:_,relative:v,singleBranch:y,headers:S,tags:!x});if(ee===null)return;p||=T,p=p.replace(`refs/heads/`,``),await lr({fs:e,cache:t,onProgress:r,onPostCheckout:c,dir:l,gitdir:u,ref:p,remote:m,noCheckout:b,nonBlocking:C,batchSize:w})}catch(t){throw await e.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>void 0),t}}async function li({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:l=H(c,`.git`),url:u,corsProxy:d=void 0,ref:f=void 0,remote:p=`origin`,depth:m=void 0,since:h=void 0,exclude:g=[],relative:_=!1,singleBranch:v=!1,noCheckout:y=!1,noTags:b=!1,headers:x={},cache:S={},nonBlocking:C=!1,batchSize:w=100}){try{X(`fs`,e),X(`http`,t),X(`gitdir`,l),y||X(`dir`,c),X(`url`,u);let T=new Y(e);return await ci({fs:T,cache:S,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:s,dir:c,gitdir:await Z({fsp:T,dotgit:l}),url:u,corsProxy:d,ref:f,remote:p,depth:m,since:h,exclude:g,relative:_,singleBranch:v,noCheckout:y,noTags:b,headers:x,nonBlocking:C,batchSize:w})}catch(e){throw e.caller=`git.clone`,e}}async function ui({fs:e,onSign:t,dir:n,gitdir:r=H(n,`.git`),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:l=!1,noUpdateBranch:u=!1,ref:d,parent:f,tree:p,cache:m={}}){try{X(`fs`,e),c||X(`message`,i),s&&X(`onSign`,t);let n=new Y(e);return await Kn({fs:n,cache:m,onSign:t,gitdir:await Z({fsp:n,dotgit:r}),message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:l,noUpdateBranch:u,ref:d,parent:f,tree:p})}catch(e){throw e.caller=`git.commit`,e}}async function di({fs:e,dir:t,gitdir:n=H(t,`.git`),fullname:r=!1,test:i=!1}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e);return await Ar({fs:t,gitdir:await Z({fsp:t,dotgit:n}),fullname:r,test:i})}catch(e){throw e.caller=`git.currentBranch`,e}}async function fi({fs:e,gitdir:t,ref:n}){if(n=n.startsWith(`refs/heads/`)?n:`refs/heads/${n}`,!await W.exists({fs:e,gitdir:t,ref:n}))throw new B(n);let r=await W.expand({fs:e,gitdir:t,ref:n});if(r===await Ar({fs:e,gitdir:t,fullname:!0})){let n=await W.resolve({fs:e,gitdir:t,ref:r});await W.writeRef({fs:e,gitdir:t,ref:`HEAD`,value:n})}await W.deleteRef({fs:e,gitdir:t,ref:r});let i=kr(n),a=await U.get({fs:e,gitdir:t});await a.deleteSection(`branch`,i),await U.save({fs:e,gitdir:t,config:a})}async function pi({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r}){try{X(`fs`,e),X(`ref`,r);let t=new Y(e);return await fi({fs:t,gitdir:await Z({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteBranch`,e}}async function mi({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r}){try{X(`fs`,e),X(`ref`,r);let t=new Y(e),i=await Z({fsp:t,dotgit:n});await W.deleteRef({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.deleteRef`,e}}async function hi({fs:e,gitdir:t,remote:n}){let r=await U.get({fs:e,gitdir:t});await r.deleteSection(`remote`,n),await U.save({fs:e,gitdir:t,config:r})}async function gi({fs:e,dir:t,gitdir:n=H(t,`.git`),remote:r}){try{X(`fs`,e),X(`remote`,r);let t=new Y(e);return await hi({fs:t,gitdir:await Z({fsp:t,dotgit:n}),remote:r})}catch(e){throw e.caller=`git.deleteRemote`,e}}async function _i({fs:e,gitdir:t,ref:n}){n=n.startsWith(`refs/tags/`)?n:`refs/tags/${n}`,await W.deleteRef({fs:e,gitdir:t,ref:n})}async function vi({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r}){try{X(`fs`,e),X(`ref`,r);let t=new Y(e);return await _i({fs:t,gitdir:await Z({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.deleteTag`,e}}async function yi({fs:e,gitdir:t,oid:n}){let r=n.slice(0,2);return(await e.readdir(`${t}/objects/${r}`)).map(e=>`${r}${e}`).filter(e=>e.startsWith(n))}async function bi({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i}){let a=[],o=await e.readdir(H(n,`objects/pack`));o=o.filter(e=>e.endsWith(`.idx`));for(let s of o){let o=await St({fs:e,cache:t,filename:`${n}/objects/pack/${s}`,getExternalRefDelta:i});if(o.error)throw new E(o.error);for(let e of o.offsets.keys())e.startsWith(r)&&a.push(e)}return a}async function xi({fs:e,cache:t,gitdir:n,oid:r}){let i=r=>K({fs:e,cache:t,gitdir:n,oid:r}),a=await yi({fs:e,gitdir:n,oid:r}),o=await bi({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:i});for(let e of o)a.indexOf(e)===-1&&a.push(e);if(a.length===1)return a[0];throw a.length>1?new Dt(`oids`,r,a):new B(`an object matching "${r}"`)}async function Si({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e);return await xi({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.expandOid`,e}}async function Ci({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let t=new Y(e),i=await Z({fsp:t,dotgit:n});return await W.expand({fs:t,gitdir:i,ref:r})}catch(e){throw e.caller=`git.expandRef`,e}}async function wi({fs:e,cache:t,gitdir:n,oids:r}){let i={},a=r.length,o=r.map((e,t)=>({index:t,oid:e}));for(;o.length;){let r=new Set;for(let{oid:e,index:t}of o)i[e]||(i[e]=new Set),i[e].add(t),i[e].size===a&&r.add(e);if(r.size>0)return[...r];let s=new Map;for(let{oid:r,index:a}of o)try{let{object:o}=await K({fs:e,cache:t,gitdir:n,oid:r}),{parent:c}=dn.from(o).parseHeaders();for(let e of c)(!i[e]||!i[e].has(a))&&s.set(e+`:`+a,{oid:e,index:a})}catch{}o=Array.from(s.values())}return[]}async function Ti({fs:e,cache:t,dir:n,gitdir:r,ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,onSign:h,mergeDriver:g,allowUnrelatedHistories:_=!1}){i===void 0&&(i=await Ar({fs:e,gitdir:r,fullname:!0})),i=await W.expand({fs:e,gitdir:r,ref:i}),a=await W.expand({fs:e,gitdir:r,ref:a});let v=await W.resolve({fs:e,gitdir:r,ref:i}),y=await W.resolve({fs:e,gitdir:r,ref:a}),b=await wi({fs:e,cache:t,gitdir:r,oids:[v,y]});if(b.length!==1)if(b.length===0&&_)b.push(`4b825dc642cb6eb9a060e54bf8d69288fbee4904`);else throw new zt;let x=b[0];if(x===y)return{oid:v,alreadyMerged:!0};if(o&&x===v)return!c&&!l&&await W.writeRef({fs:e,gitdir:r,ref:i,value:y}),{oid:y,fastForward:!0};{if(s)throw new Nt;let o=await R.acquire({fs:e,gitdir:r,cache:t,allowUnmerged:!1},async o=>_r({fs:e,cache:t,dir:n,gitdir:r,index:o,ourOid:v,theirOid:y,baseOid:x,ourName:kr(i),baseName:`base`,theirName:kr(a),dryRun:c,abortOnConflict:u,mergeDriver:g}));if(o instanceof Bt)throw o;return d||=`Merge branch '${kr(a)}' into ${kr(i)}`,{oid:await Kn({fs:e,cache:t,gitdir:r,message:d,ref:i,tree:o,parent:[v,y],author:f,committer:p,signingKey:m,onSign:h,dryRun:c,noUpdateBranch:l}),tree:o,mergeCommit:!0}}}async function Ei({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,dir:c,gitdir:l,ref:u,url:d,remote:f,remoteRef:p,prune:m,pruneTags:h,fastForward:g,fastForwardOnly:_,corsProxy:v,singleBranch:y,headers:b,author:x,committer:S,signingKey:C}){try{if(!u){let t=await Ar({fs:e,gitdir:l});if(!t)throw new Vt(`ref`);u=t}let{fetchHead:w,fetchHeadDescription:T}=await oi({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,gitdir:l,corsProxy:v,ref:u,url:d,remote:f,remoteRef:p,singleBranch:y,headers:b,prune:m,pruneTags:h});await Ti({fs:e,cache:t,gitdir:l,ours:u,theirs:w,fastForward:g,fastForwardOnly:_,message:`Merge ${T}`,author:x,committer:S,signingKey:C,dryRun:!1,noUpdateBranch:!1}),await lr({fs:e,cache:t,onProgress:r,dir:c,gitdir:l,ref:u,remote:f,noCheckout:!1})}catch(e){throw e.caller=`git.pull`,e}}async function Di({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=H(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,corsProxy:p,singleBranch:m,headers:h={},cache:g={}}){try{X(`fs`,e),X(`http`,t),X(`gitdir`,c);let _={name:``,email:``,timestamp:Date.now(),timezoneOffset:0},v=new Y(e);return await Ei({fs:v,cache:g,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:await Z({fsp:v,dotgit:c}),ref:l,url:u,remote:d,remoteRef:f,fastForwardOnly:!0,corsProxy:p,singleBranch:m,headers:h,author:_,committer:_})}catch(e){throw e.caller=`git.fastForward`,e}}async function Oi({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=H(s,`.git`),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m=null,since:h=null,exclude:g=[],relative:_=!1,tags:v=!1,singleBranch:y=!1,headers:b={},prune:x=!1,pruneTags:S=!1,cache:C={}}){try{X(`fs`,e),X(`http`,t),X(`gitdir`,c);let s=new Y(e);return await oi({fs:s,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,gitdir:await Z({fsp:s,dotgit:c}),ref:l,remote:u,remoteRef:d,url:f,corsProxy:p,depth:m,since:h,exclude:g,relative:_,tags:v,singleBranch:y,headers:b,prune:x,pruneTags:S})}catch(e){throw e.caller=`git.fetch`,e}}async function ki({fs:e,dir:t,gitdir:n=H(t,`.git`),oids:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oids`,r);let t=new Y(e);return await wi({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),oids:r})}catch(e){throw e.caller=`git.findMergeBase`,e}}async function Ai({fs:e,filepath:t}){if(await e.exists(H(t,`.git`)))return t;{let n=z(t);if(n===t)throw new B(`git root for ${t}`);return Ai({fs:e,filepath:n})}}async function ji({fs:e,filepath:t}){try{return X(`fs`,e),X(`filepath`,t),await Ai({fs:new Y(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function Mi({fs:e,dir:t,gitdir:n=H(t,`.git`),path:r}){try{X(`fs`,e),X(`gitdir`,n),X(`path`,r);let t=new Y(e);return await Bn({fs:t,gitdir:await Z({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfig`,e}}async function Ni({fs:e,gitdir:t,path:n}){return(await U.get({fs:e,gitdir:t})).getall(n)}async function Pi({fs:e,dir:t,gitdir:n=H(t,`.git`),path:r}){try{X(`fs`,e),X(`gitdir`,n),X(`path`,r);let t=new Y(e);return await Ni({fs:t,gitdir:await Z({fsp:t,dotgit:n}),path:r})}catch(e){throw e.caller=`git.getConfigAll`,e}}async function Fi({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1}){try{X(`http`,e),X(`url`,a);let c=await Wr.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:1}),l={capabilities:[...c.capabilities]};for(let[e,t]of c.refs){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}for(let[e,t]of c.symrefs){let n=e.split(`/`),r=n.pop(),i=l;for(let e of n)i[e]=i[e]||{},i=i[e];i[r]=t}return l}catch(e){throw e.caller=`git.getRemoteInfo`,e}}function Ii(e,t,n,r){let i=[];for(let[a,o]of e.refs){if(t&&!a.startsWith(t))continue;if(a.endsWith(`^{}`)){if(r){let e=a.replace(`^{}`,``),t=i[i.length-1],n=t.ref===e?t:i.find(t=>t.ref===e);if(n===void 0)throw Error(`I did not expect this to happen`);n.peeled=o}continue}let s={ref:a,oid:o};n&&e.symrefs.has(a)&&(s.target=e.symrefs.get(a)),i.push(s)}return i}async function Li({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2}){try{X(`http`,e),X(`url`,a);let l=await Wr.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(l.protocolVersion===2)return{protocolVersion:l.protocolVersion,capabilities:l.capabilities2};let u={};for(let e of l.capabilities){let[t,n]=e.split(`=`);n?u[t]=n:u[t]=!0}return{protocolVersion:1,capabilities:u,refs:Ii(l,void 0,!0,!0)}}catch(e){throw e.caller=`git.getRemoteInfo2`,e}}async function Ri({type:e,object:t,format:n=`content`,oid:r=void 0}){return n!==`deflated`&&(n!==`wrapped`&&(t=tt.wrap({type:e,object:t})),r=await N(t)),{oid:r,object:t}}async function zi({object:e}){try{X(`object`,e),typeof e==`string`?e=r.Buffer.from(e,`utf8`):e instanceof Uint8Array||(e=new Uint8Array(e));let t=`blob`,{oid:n,object:i}=await Ri({type:t,format:`content`,object:e});return{oid:n,type:t,object:i,format:`wrapped`}}catch(e){throw e.caller=`git.hashBlob`,e}}async function Bi({fs:e,cache:t,onProgress:n,dir:r,gitdir:i,filepath:a}){try{a=H(r,a);let o=await e.read(a),s=await yt.fromPack({pack:o,getExternalRefDelta:n=>K({fs:e,cache:t,gitdir:i,oid:n}),onProgress:n});return await e.write(a.replace(/\.pack$/,`.idx`),await s.toBuffer()),{oids:[...s.hashes]}}catch(e){throw e.caller=`git.indexPack`,e}}async function Vi({fs:e,onProgress:t,dir:n,gitdir:r=H(n,`.git`),filepath:i,cache:a={}}){try{X(`fs`,e),X(`dir`,n),X(`gitdir`,n),X(`filepath`,i);let o=new Y(e);return await Bi({fs:o,cache:a,onProgress:t,dir:n,gitdir:await Z({fsp:o,dotgit:r}),filepath:i})}catch(e){throw e.caller=`git.indexPack`,e}}async function Hi({fs:e,bare:t=!1,dir:n,gitdir:r=t?n:H(n,`.git`),defaultBranch:i=`master`}){try{X(`fs`,e),X(`gitdir`,r),t||X(`dir`,n);let a=new Y(e);return await si({fs:a,bare:t,dir:n,gitdir:await Z({fsp:a,dotgit:r}),defaultBranch:i})}catch(e){throw e.caller=`git.init`,e}}async function Ui({fs:e,cache:t,gitdir:n,oid:r,ancestor:i,depth:a}){let o=await qr.read({fs:e,gitdir:n});if(!r)throw new Vt(`oid`);if(!i)throw new Vt(`ancestor`);if(r===i)return!1;let s=[r],c=new Set,l=0;for(;s.length;){if(l++===a)throw new Rt(a);let r=s.shift(),{type:u,object:d}=await K({fs:e,cache:t,gitdir:n,oid:r});if(u!==`commit`)throw new V(r,u,`commit`);let f=dn.from(d).parse();for(let e of f.parent)if(e===i)return!0;if(!o.has(r))for(let e of f.parent)c.has(e)||(s.push(e),c.add(e))}return!1}async function Wi({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,ancestor:i,depth:a=-1,cache:o={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r),X(`ancestor`,i);let t=new Y(e);return await Ui({fs:t,cache:o,gitdir:await Z({fsp:t,dotgit:n}),oid:r,ancestor:i,depth:a})}catch(e){throw e.caller=`git.isDescendent`,e}}async function Gi({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r}){try{X(`fs`,e),X(`dir`,t),X(`gitdir`,n),X(`filepath`,r);let i=new Y(e),a=await Z({fsp:i,dotgit:n});return jn.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}async function Ki({fs:e,dir:t,gitdir:n=H(t,`.git`),remote:r}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e),i=await Z({fsp:t,dotgit:n});return W.listBranches({fs:t,gitdir:i,remote:r})}catch(e){throw e.caller=`git.listBranches`,e}}async function qi({fs:e,gitdir:t,ref:n,cache:r}){if(n){let i=await W.resolve({gitdir:t,fs:e,ref:n}),a=[];return await Ji({fs:e,cache:r,gitdir:t,oid:i,filenames:a,prefix:``}),a}else return R.acquire({fs:e,gitdir:t,cache:r},async function(e){return e.entries.map(e=>e.path)})}async function Ji({fs:e,cache:t,gitdir:n,oid:r,filenames:i,prefix:a}){let{tree:o}=await Xn({fs:e,cache:t,gitdir:n,oid:r});for(let r of o)r.type===`tree`?await Ji({fs:e,cache:t,gitdir:n,oid:r.oid,filenames:i,prefix:H(a,r.path)}):i.push(H(a,r.path))}async function Yi({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e);return await qi({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listFiles`,e}}async function Xi({fs:e,cache:t,gitdir:n,ref:r}){let i;try{i=await W.resolve({gitdir:n,fs:e,ref:r})}catch(e){if(e instanceof B)return[]}return(await Xn({fs:e,cache:t,gitdir:n,oid:i})).tree.map(e=>({target:e.path,note:e.oid}))}async function Zi({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r=`refs/notes/commits`,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let t=new Y(e);return await Xi({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),ref:r})}catch(e){throw e.caller=`git.listNotes`,e}}async function Qi({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e),i=await Z({fsp:t,dotgit:n});return W.listRefs({fs:t,gitdir:i,filepath:r})}catch(e){throw e.caller=`git.listRefs`,e}}async function $i({fs:e,gitdir:t}){let n=await U.get({fs:e,gitdir:t}),r=await n.getSubsections(`remote`);return Promise.all(r.map(async e=>({remote:e,url:await n.get(`remote.${e}.url`)})))}async function ea({fs:e,dir:t,gitdir:n=H(t,`.git`)}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e);return await $i({fs:t,gitdir:await Z({fsp:t,dotgit:n})})}catch(e){throw e.caller=`git.listRemotes`,e}}async function ta(e){let t=$.streamReader(e),n=[],r;for(;r=await t(),r!==!0;){if(r===null)continue;r=r.toString(`utf8`).replace(/\n$/,``);let[e,t,...i]=r.split(` `),a={ref:t,oid:e};for(let e of i){let[t,n]=e.split(`:`);t===`symref-target`?a.target=n:t===`peeled`&&(a.peeled=n)}n.push(a)}return n}async function na({prefix:e,symrefs:t,peelTags:n}){let r=[];return r.push($.encode(`command=ls-refs
|
|
71
|
-
`)),r.push($.encode(`agent=${$r.agent}\n`)),(n||t||e)&&r.push($.delim()),n&&r.push($.encode(`peel`)),t&&r.push($.encode(`symrefs`)),e&&r.push($.encode(`ref-prefix ${e}`)),r.push($.flush()),r}async function ra({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,url:a,headers:o={},forPush:s=!1,protocolVersion:c=2,prefix:l,symrefs:u,peelTags:d}){try{X(`http`,e),X(`url`,a);let f=await Ur.discover({http:e,onAuth:t,onAuthSuccess:n,onAuthFailure:r,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,headers:o,protocolVersion:c});if(f.protocolVersion===1)return Ii(f,l,u,d);let p=await na({prefix:l,symrefs:u,peelTags:d});return ta((await Ur.connect({http:e,auth:f.auth,headers:o,corsProxy:i,service:s?`git-receive-pack`:`git-upload-pack`,url:a,body:p})).body)}catch(e){throw e.caller=`git.listServerRefs`,e}}async function ia({fs:e,dir:t,gitdir:n=H(t,`.git`)}){try{X(`fs`,e),X(`gitdir`,n);let t=new Y(e),r=await Z({fsp:t,dotgit:n});return W.listTags({fs:t,gitdir:r})}catch(e){throw e.caller=`git.listTags`,e}}function aa(e,t){return e.committer.timestamp-t.committer.timestamp}async function oa({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`)return;let a=r,o,s=await fn({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await sa({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function sa({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=H(s,r.path),o.push(c)):r.type===`tree`&&(c=K({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return sa({fs:e,cache:t,gitdir:n,tree:G.from(c),fileId:i,oid:a,filepaths:o,parentPath:H(s,r.path)})})),c});return await Promise.all(c),o}async function ca({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,force:s,follow:c}){let l=o===void 0?void 0:Math.floor(o.valueOf()/1e3),u=[],d=await qr.read({fs:e,gitdir:n}),f=[await Gn({fs:e,cache:t,gitdir:n,oid:await W.resolve({fs:e,gitdir:n,ref:i})})],p,m,h;function g(e){h&&r&&u.push(e)}for(;f.length>0;){let i=f.pop();if(l!==void 0&&i.commit.committer.timestamp<=l)break;if(r){let a;try{a=await Jn({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),m&&p!==a&&u.push(m),p=a,m=i,h=!0}catch(a){if(a instanceof B){let o=c&&p;if(o&&(o=await oa({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:p}),o))if(Array.isArray(o)){if(m){let i=await oa({fs:e,cache:t,gitdir:n,oid:m.commit.tree,fileId:p});if(Array.isArray(i))if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,m&&u.push(m);else{o=!1,m&&u.push(m);break}}}else r=o,m&&u.push(m);if(!o){if(h&&p&&(u.push(m),!s))break;if(!s&&!c)throw a}m=i,h=!1}else throw a}}else u.push(i);if(a!==void 0&&u.length===a){g(i);break}if(!d.has(i.oid))for(let r of i.commit.parent){let i=await Gn({fs:e,cache:t,gitdir:n,oid:r});f.map(e=>e.oid).includes(i.oid)||f.push(i)}f.length===0&&g(i),f.sort((e,t)=>aa(e.commit,t.commit))}return u}async function la({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,force:s,follow:c,cache:l={}}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,i);let t=new Y(e);return await ca({fs:t,cache:l,gitdir:await Z({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,force:s,follow:c})}catch(e){throw e.caller=`git.log`,e}}async function ua({fs:e,onSign:t,dir:n,gitdir:r=H(n,`.git`),ours:i,theirs:a,fastForward:o=!0,fastForwardOnly:s=!1,dryRun:c=!1,noUpdateBranch:l=!1,abortOnConflict:u=!0,message:d,author:f,committer:p,signingKey:m,cache:h={},mergeDriver:g,allowUnrelatedHistories:_=!1}){try{X(`fs`,e),m&&X(`onSign`,t);let v=new Y(e),y=await Z({fsp:v,dotgit:r}),b=await Hn({fs:v,gitdir:y,author:f});if(!b&&(!s||!o))throw new q(`author`);let x=await Un({fs:v,gitdir:y,author:b,committer:p});if(!x&&(!s||!o))throw new q(`committer`);return await Ti({fs:v,cache:h,dir:n,gitdir:y,ours:i,theirs:a,fastForward:o,fastForwardOnly:s,dryRun:c,noUpdateBranch:l,abortOnConflict:u,message:d,author:b,committer:x,signingKey:m,onSign:t,mergeDriver:g,allowUnrelatedHistories:_})}catch(e){throw e.caller=`git.merge`,e}}let da={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function fa({fs:e,cache:t,dir:n,gitdir:i=H(n,`.git`),oids:a}){let o=new c,s=[];function l(e,t){let n=r.Buffer.from(e,t);s.push(n),o.update(n)}async function u({stype:e,object:t}){let n=da[e],i=t.length,a=i>15?128:0,o=i&15;i>>>=4;let s=(a|n|o).toString(16);for(l(s,`hex`);a;)a=i>127?128:0,s=a|i&127,l(Ir(2,s),`hex`),i>>>=7;l(r.Buffer.from(await Pn(t)))}l(`PACK`),l(`00000002`,`hex`),l(Ir(8,a.length),`hex`);for(let n of a){let{type:r,object:a}=await K({fs:e,cache:t,gitdir:i,oid:n});await u({write:l,object:a,stype:r})}let d=o.digest();return s.push(d),s}async function pa({fs:e,cache:t,gitdir:n,oids:i,write:a}){let o=await fa({fs:e,cache:t,gitdir:n,oids:i}),s=r.Buffer.from(await Pr(o)),c=`pack-${s.slice(-20).toString(`hex`)}.pack`;return a?(await e.write(H(n,`objects/pack/${c}`),s),{filename:c}):{filename:c,packfile:new Uint8Array(s)}}async function ma({fs:e,dir:t,gitdir:n=H(t,`.git`),oids:r,write:i=!1,cache:a={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oids`,r);let t=new Y(e);return await pa({fs:t,cache:a,gitdir:await Z({fsp:t,dotgit:n}),oids:r,write:i})}catch(e){throw e.caller=`git.packObjects`,e}}async function ha({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:c=H(s,`.git`),ref:l,url:u,remote:d,remoteRef:f,prune:p=!1,pruneTags:m=!1,fastForward:h=!0,fastForwardOnly:g=!1,corsProxy:_,singleBranch:v,headers:y={},author:b,committer:x,signingKey:S,cache:C={}}){try{X(`fs`,e),X(`gitdir`,c);let w=new Y(e),T=await Z({fsp:w,dotgit:c}),ee=await Hn({fs:w,gitdir:T,author:b});if(!ee)throw new q(`author`);let E=await Un({fs:w,gitdir:T,author:ee,committer:x});if(!E)throw new q(`committer`);return await Ei({fs:w,cache:C,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,dir:s,gitdir:T,ref:l,url:u,remote:d,remoteRef:f,fastForward:h,fastForwardOnly:g,corsProxy:_,singleBranch:v,headers:y,author:ee,committer:E,signingKey:S,prune:p,pruneTags:m})}catch(e){throw e.caller=`git.pull`,e}}async function ga({fs:e,cache:t,dir:n,gitdir:r=H(n,`.git`),start:i,finish:a}){let o=await qr.read({fs:e,gitdir:r}),s=new Set,c=new Set;for(let t of i)s.add(await W.resolve({fs:e,gitdir:r,ref:t}));for(let t of a)try{let n=await W.resolve({fs:e,gitdir:r,ref:t});c.add(n)}catch{}let l=new Set;async function u(n){l.add(n);let{type:i,object:a}=await K({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=cn.from(a).headers().object;return u(e)}if(i!==`commit`)throw new V(n,i,`commit`);if(!o.has(n))for(n of dn.from(a).headers().parent)!c.has(n)&&!l.has(n)&&await u(n)}for(let e of s)await u(e);return l}async function _a({fs:e,cache:t,dir:n,gitdir:r=H(n,`.git`),oids:i}){let a=new Set;async function o(n){if(a.has(n))return;a.add(n);let{type:i,object:s}=await K({fs:e,cache:t,gitdir:r,oid:n});if(i===`tag`){let e=cn.from(s).headers().object;await o(e)}else if(i===`commit`){let e=dn.from(s).headers().tree;await o(e)}else if(i===`tree`){let e=G.from(s);for(let t of e)t.type===`blob`&&a.add(t.oid),t.type===`tree`&&await o(t.oid)}}for(let e of i)await o(e);return a}async function va(e){let t={},n=``,r=$.streamReader(e),i=await r();for(;i!==!0;)i!==null&&(n+=i.toString(`utf8`)+`
|
|
72
|
-
`),i=await r();let a=n.toString(`utf8`).split(`
|
|
73
|
-
`);if(i=a.shift(),!i.startsWith(`unpack `))throw new Ut(`unpack ok" or "unpack [error message]`,i);t.ok=i===`unpack ok`,t.ok||(t.error=i.slice(7)),t.refs={};for(let e of a){if(e.trim()===``)continue;let n=e.slice(0,2),r=e.slice(3),i=r.indexOf(` `);i===-1&&(i=r.length);let a=r.slice(0,i),o=r.slice(i+1);t.refs[a]={ok:n===`ok`,error:o}}return t}async function ya({capabilities:e=[],triplets:t=[]}){let n=[],r=`\x00 ${e.join(` `)}`;for(let e of t)n.push($.encode(`${e.oldoid} ${e.oid} ${e.fullRef}${r}\n`)),r=``;return n.push($.flush()),n}async function ba({fs:e,cache:t,http:n,onProgress:r,onMessage:i,onAuth:a,onAuthSuccess:o,onAuthFailure:s,onPrePush:c,gitdir:l,ref:u,remoteRef:d,remote:f,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={}}){let v=u||await Ar({fs:e,gitdir:l});if(v===void 0)throw new Vt(`ref`);let y=await U.get({fs:e,gitdir:l});f=f||await y.get(`branch.${v}.pushRemote`)||await y.get(`remote.pushDefault`)||await y.get(`branch.${v}.remote`)||`origin`;let b=p||await y.get(`remote.${f}.pushurl`)||await y.get(`remote.${f}.url`);if(b===void 0)throw new Vt(`remote OR url`);let x=d||await y.get(`branch.${v}.merge`);if(b===void 0)throw new Vt(`remoteRef`);g===void 0&&(g=await y.get(`http.corsProxy`));let S=await W.expand({fs:e,gitdir:l,ref:v}),C=h?`0000000000000000000000000000000000000000`:await W.resolve({fs:e,gitdir:l,ref:S}),w=Wr.getRemoteHelperFor({url:b}),T=await w.discover({http:n,onAuth:a,onAuthSuccess:o,onAuthFailure:s,corsProxy:g,service:`git-receive-pack`,url:b,headers:_,protocolVersion:1}),ee=T.auth,E;if(!x)E=S;else try{E=await W.expandAgainstMap({ref:x,map:T.refs})}catch(e){if(e instanceof B)E=x.startsWith(`refs/`)?x:`refs/heads/${x}`;else throw e}let D=T.refs.get(E)||`0000000000000000000000000000000000000000`;if(c&&!await c({remote:f,url:b,localRef:{ref:h?`(delete)`:S,oid:C},remoteRef:{ref:E,oid:D}}))throw new Yt;let O=!T.capabilities.has(`no-thin`),k=new Set;if(!h){let n=[...T.refs.values()],r=new Set;if(D!==`0000000000000000000000000000000000000000`){let i=await wi({fs:e,cache:t,gitdir:l,oids:[C,D]});for(let e of i)n.push(e);O&&(r=await _a({fs:e,cache:t,gitdir:l,oids:i}))}if(n.includes(C)||(k=await _a({fs:e,cache:t,gitdir:l,oids:await ga({fs:e,cache:t,gitdir:l,start:[C],finish:n})})),O){try{let n=await W.resolve({fs:e,gitdir:l,ref:`refs/remotes/${f}/HEAD`,depth:2}),{oid:i}=await W.resolveAgainstMap({ref:n.replace(`refs/remotes/${f}/`,``),fullref:n,map:T.refs}),a=[i];for(let n of await _a({fs:e,cache:t,gitdir:l,oids:a}))r.add(n)}catch{}for(let e of r)k.delete(e)}if(C===D&&(m=!0),!m){if(S.startsWith(`refs/tags`)&&D!==`0000000000000000000000000000000000000000`)throw new Wt(`tag-exists`);if(C!==`0000000000000000000000000000000000000000`&&D!==`0000000000000000000000000000000000000000`&&!await Ui({fs:e,cache:t,gitdir:l,oid:C,ancestor:D,depth:-1}))throw new Wt(`not-fast-forward`)}}let te=await ya({capabilities:Qr([...T.capabilities],[`report-status`,`side-band-64k`,`agent=${$r.agent}`]),triplets:[{oldoid:D,oid:C,fullRef:E}]}),A=h?[]:await fa({fs:e,cache:t,gitdir:l,oids:[...k]}),j=await w.connect({http:n,onProgress:r,corsProxy:g,service:`git-receive-pack`,url:b,auth:ee,headers:_,body:[...te,...A]}),{packfile:M,progress:ne}=await ri.demux(j.body);i&&Nr(ni(ne),async e=>{await i(e)});let re=await va(M);if(j.headers&&(re.headers=j.headers),f&&re.ok&&re.refs[E].ok&&!S.startsWith(`refs/tags`)){let t=`refs/remotes/${f}/${E.replace(`refs/heads`,``)}`;h?await W.deleteRef({fs:e,gitdir:l,ref:t}):await W.writeRef({fs:e,gitdir:l,ref:t,value:C})}if(re.ok&&Object.values(re.refs).every(e=>e.ok))return re;throw new Pt(Object.entries(re.refs).filter(([e,t])=>!t.ok).map(([e,t])=>`\n - ${e}: ${t.error}`).join(``),re)}async function xa({fs:e,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,dir:c,gitdir:l=H(c,`.git`),ref:u,remoteRef:d,remote:f=`origin`,url:p,force:m=!1,delete:h=!1,corsProxy:g,headers:_={},cache:v={}}){try{X(`fs`,e),X(`http`,t),X(`gitdir`,l);let c=new Y(e);return await ba({fs:c,cache:v,http:t,onProgress:n,onMessage:r,onAuth:i,onAuthSuccess:a,onAuthFailure:o,onPrePush:s,gitdir:await Z({fsp:c,dotgit:l}),ref:u,remoteRef:d,remote:f,url:p,force:m,delete:h,corsProxy:g,headers:_})}catch(e){throw e.caller=`git.push`,e}}async function Sa({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await K({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=cn.from(a).parse().object,Sa({fs:e,cache:t,gitdir:n,oid:r});if(i!==`blob`)throw new V(r,i,`blob`);return{oid:r,blob:new Uint8Array(a)}}async function Ca({fs:e,cache:t,gitdir:n,oid:r,filepath:i=void 0}){return i!==void 0&&(r=await Jn({fs:e,cache:t,gitdir:n,oid:r,filepath:i})),await Sa({fs:e,cache:t,gitdir:n,oid:r})}async function wa({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,filepath:i,cache:a={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e);return await Ca({fs:t,cache:a,gitdir:await Z({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readBlob`,e}}async function Ta({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e);return await Gn({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readCommit`,e}}async function Ea({fs:e,cache:t,gitdir:n,ref:r=`refs/notes/commits`,oid:i}){let{blob:a}=await Ca({fs:e,cache:t,gitdir:n,oid:await W.resolve({gitdir:n,fs:e,ref:r}),filepath:i});return a}async function Da({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r=`refs/notes/commits`,oid:i,cache:a={}}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r),X(`oid`,i);let t=new Y(e);return await Ea({fs:t,cache:a,gitdir:await Z({fsp:t,dotgit:n}),ref:r,oid:i})}catch(e){throw e.caller=`git.readNote`,e}}async function Oa({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,format:i=`parsed`,filepath:a=void 0,encoding:o=void 0,cache:s={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e),c=await Z({fsp:t,dotgit:n});a!==void 0&&(r=await Jn({fs:t,cache:s,gitdir:c,oid:r,filepath:a}));let l=await K({fs:t,cache:s,gitdir:c,oid:r,format:i===`parsed`?`content`:i});if(l.oid=r,i===`parsed`)switch(l.format=`parsed`,l.type){case`commit`:l.object=dn.from(l.object).parse();break;case`tree`:l.object=G.from(l.object).entries();break;case`blob`:o?l.object=l.object.toString(o):(l.object=new Uint8Array(l.object),l.format=`content`);break;case`tag`:l.object=cn.from(l.object).parse();break;default:throw new V(l.oid,l.type,`blob|commit|tag|tree`)}else(l.format===`deflated`||l.format===`wrapped`)&&(l.type=l.format);return l}catch(e){throw e.caller=`git.readObject`,e}}async function ka({fs:e,cache:t,gitdir:n,oid:r}){let{type:i,object:a}=await K({fs:e,cache:t,gitdir:n,oid:r,format:`content`});if(i!==`tag`)throw new V(r,i,`tag`);let o=cn.from(a);return{oid:r,tag:o.parse(),payload:o.payload()}}async function Aa({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e);return await ka({fs:t,cache:i,gitdir:await Z({fsp:t,dotgit:n}),oid:r})}catch(e){throw e.caller=`git.readTag`,e}}async function ja({fs:e,dir:t,gitdir:n=H(t,`.git`),oid:r,filepath:i=void 0,cache:a={}}){try{X(`fs`,e),X(`gitdir`,n),X(`oid`,r);let t=new Y(e);return await Xn({fs:t,cache:a,gitdir:await Z({fsp:t,dotgit:n}),oid:r,filepath:i})}catch(e){throw e.caller=`git.readTree`,e}}async function Ma({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`filepath`,r);let t=new Y(e),a=await Z({fsp:t,dotgit:n});await R.acquire({fs:t,gitdir:a,cache:i},async function(e){e.delete({filepath:r})})}catch(e){throw e.caller=`git.remove`,e}}async function Na({fs:e,cache:t,onSign:n,gitdir:r,ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c}){let l;try{l=await W.resolve({gitdir:r,fs:e,ref:i})}catch(e){if(!(e instanceof B))throw e}let u=(await Xn({fs:e,cache:t,gitdir:r,oid:l||`4b825dc642cb6eb9a060e54bf8d69288fbee4904`})).tree;return u=u.filter(e=>e.path!==a),await Kn({fs:e,cache:t,onSign:n,gitdir:r,ref:i,tree:await Zn({fs:e,gitdir:r,tree:u}),parent:l&&[l],message:`Note removed by 'isomorphic-git removeNote'
|
|
74
|
-
`,author:o,committer:s,signingKey:c})}async function Pa({fs:e,onSign:t,dir:n,gitdir:r=H(n,`.git`),ref:i=`refs/notes/commits`,oid:a,author:o,committer:s,signingKey:c,cache:l={}}){try{X(`fs`,e),X(`gitdir`,r),X(`oid`,a);let n=new Y(e),u=await Z({fsp:n,dotgit:r}),d=await Hn({fs:n,gitdir:u,author:o});if(!d)throw new q(`author`);let f=await Un({fs:n,gitdir:u,author:d,committer:s});if(!f)throw new q(`committer`);return await Na({fs:n,cache:l,onSign:t,gitdir:u,ref:i,oid:a,author:d,committer:f,signingKey:c})}catch(e){throw e.caller=`git.removeNote`,e}}async function Fa({fs:e,gitdir:t,oldref:n,ref:r,checkout:i=!1}){if(!tr(r,!0))throw new Lt(r,v.clean(r));if(!tr(n,!0))throw new Lt(n,v.clean(n));let a=`refs/heads/${n}`,o=`refs/heads/${r}`;if(await W.exists({fs:e,gitdir:t,ref:o}))throw new Et(`branch`,r,!1);let s=await W.resolve({fs:e,gitdir:t,ref:a,depth:1});await W.writeRef({fs:e,gitdir:t,ref:o,value:s}),await W.deleteRef({fs:e,gitdir:t,ref:a});let c=await Ar({fs:e,gitdir:t,fullname:!0})===a;(i||c)&&await W.writeSymbolicRef({fs:e,gitdir:t,ref:`HEAD`,value:o})}async function Ia({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,oldref:i,checkout:a=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r),X(`oldref`,i);let t=new Y(e);return await Fa({fs:t,gitdir:await Z({fsp:t,dotgit:n}),ref:r,oldref:i,checkout:a})}catch(e){throw e.caller=`git.renameBranch`,e}}async function La({gitdir:e,type:t,object:n}){return N(tt.wrap({type:t,object:n}))}async function Ra({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r,ref:i,cache:a={}}){try{X(`fs`,e),X(`gitdir`,n),X(`filepath`,r);let o=new Y(e),s=await Z({fsp:o,dotgit:n}),c,l;try{c=await W.resolve({fs:o,gitdir:s,ref:i||`HEAD`})}catch(e){if(i)throw e}if(c)try{c=await Jn({fs:o,cache:a,gitdir:s,oid:c,filepath:r})}catch{c=null}let u={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},d=t&&await o.read(H(t,r));d&&(l=await La({gitdir:s,type:`blob`,object:d}),c===l&&(u=await o.lstat(H(t,r)))),await R.acquire({fs:o,gitdir:s,cache:a},async function(e){e.delete({filepath:r}),c&&e.insert({filepath:r,stats:u,oid:c})})}catch(e){throw e.caller=`git.reset`,e}}async function za({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,depth:i}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let t=new Y(e),a=await Z({fsp:t,dotgit:n});return await W.resolve({fs:t,gitdir:a,ref:r,depth:i})}catch(e){throw e.caller=`git.resolveRef`,e}}async function Ba({fs:e,dir:t,gitdir:n=H(t,`.git`),path:r,value:i,append:a=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`path`,r);let t=new Y(e),o=await Z({fsp:t,dotgit:n}),s=await U.get({fs:t,gitdir:o});a?await s.append(r,i):await s.set(r,i),await U.save({fs:t,gitdir:o,config:s})}catch(e){throw e.caller=`git.setConfig`,e}}async function Va({fs:e,gitdir:t,commit:n}){return await Q({fs:e,gitdir:t,type:`commit`,object:dn.from(n).toObject(),format:`content`})}var Ha=class e{static get timezoneOffsetForRefLogEntry(){let e=new Date().getTimezoneOffset(),t=Math.abs(Math.floor(e/60)),n=Math.abs(e%60).toString().padStart(2,`0`);return`${e>0?`-`:`+`}${t.toString().padStart(2,`0`)}${n}`}static createStashReflogEntry(t,n,r){let i=t.name.replace(/\s/g,``),a=Math.floor(Date.now()/1e3),o=e.timezoneOffsetForRefLogEntry;return`0000000000000000000000000000000000000000 ${n} ${i} ${t.email} ${a} ${o}\t${r}\n`}static getStashReflogEntry(e,t=!1){return e.split(`
|
|
75
|
-
`).filter(e=>e).reverse().map((e,n)=>t?`stash@{${n}}: ${e.split(` `)[1]}`:e)}},Ua=class e{constructor({fs:e,dir:t,gitdir:n=H(t,`.git`)}){Object.assign(this,{fs:e,dir:t,gitdir:n,_author:null})}static get refStash(){return`refs/stash`}static get refLogsStash(){return`logs/refs/stash`}get refStashPath(){return H(this.gitdir,e.refStash)}get refLogsStashPath(){return H(this.gitdir,e.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await Hn({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new q(`author`);return this._author}async getStashSHA(e,t){return await this.fs.exists(this.refStashPath)?(t||await this.readStashReflogs({parsed:!1}))[e].split(` `)[1]:null}async writeStashCommit({message:e,tree:t,parent:n}){return Va({fs:this.fs,gitdir:this.gitdir,commit:{message:e,tree:t,parent:n,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(e){let t=await this.readStashReflogs({parsed:!1});if(e!==0&&(e<0||e>t.length-1))throw new Lt(`stash@${e}`,`number that is in range of [0, num of stash pushed]`);let n=await this.getStashSHA(e,t);return n?Gn({fs:this.fs,cache:{},gitdir:this.gitdir,oid:n}):{}}async writeStashRef(t){return W.writeRef({fs:this.fs,gitdir:this.gitdir,ref:e.refStash,value:t})}async writeStashReflogEntry({stashCommit:e,message:t}){let n=await this.getAuthor(),r=Ha.createStashReflogEntry(n,e,t),i=this.refLogsStashPath;await xr({filepath:i,entry:r},async()=>{let e=await this.fs.exists(i)?await this.fs.read(i,`utf8`):``;await this.fs.write(i,e+r,`utf8`)})}async readStashReflogs({parsed:e=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];let t=await this.fs.read(this.refLogsStashPath,`utf8`);return Ha.getStashReflogEntry(t,e)}};async function Wa({fs:e,dir:t,gitdir:n,message:r=``}){let i=new Ua({fs:e,dir:t,gitdir:n});await i.getAuthor();let a=await Ar({fs:e,gitdir:n,fullname:!1}),o=await W.resolve({fs:e,gitdir:n,ref:`HEAD`}),s=(await Ta({fs:e,dir:t,gitdir:n,oid:o})).commit.message,c=[o],l=null,u=J({ref:`HEAD`}),d=await wr({fs:e,dir:t,gitdir:n,treePair:[J({ref:`HEAD`}),`stage`]});if(d){let e=await i.writeStashCommit({message:`stash-Index: WIP on ${a} - ${new Date().toISOString()}`,tree:d,parent:c});c.push(e),l=d,u=ve()}let f=await wr({fs:e,dir:t,gitdir:n,treePair:[u,`workdir`]});if(f){let e=await i.writeStashCommit({message:`stash-WorkDir: WIP on ${a} - ${new Date().toISOString()}`,tree:f,parent:[c[c.length-1]]});c.push(e),l=f}if(!l||!d&&!f)throw new B(`changes, nothing to stash`);let p=(r.trim()||`WIP on ${a}`)+`: ${o.substring(0,7)} ${s}`;return{stashCommit:await i.writeStashCommit({message:p,tree:l,parent:c}),stashMsg:p,branch:a,stashMgr:i}}async function Ga({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i,stashMsg:a,branch:o,stashMgr:s}=await Wa({fs:e,dir:t,gitdir:n,message:r});return await s.writeStashRef(i),await s.writeStashReflogEntry({stashCommit:i,message:a}),await mr({fs:e,dir:t,gitdir:n,ref:o,track:!1,force:!0}),i}async function Ka({fs:e,dir:t,gitdir:n,message:r=``}){let{stashCommit:i}=await Wa({fs:e,dir:t,gitdir:n,message:r});return i}async function qa({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=await new Ua({fs:e,dir:t,gitdir:n}).readStashCommit(r),{parent:a=null}=i.commit?i.commit:{};if(!(!a||!Array.isArray(a)))for(let r=0;r<a.length-1;r++){let i=(await Gn({fs:e,cache:{},gitdir:n,oid:a[r+1]})).commit.message.startsWith(`stash-Index`);await Tr({fs:e,dir:t,gitdir:n,stashCommit:a[r+1],parentCommit:a[r],wasStaged:i})}}async function Ja({fs:e,dir:t,gitdir:n,refIdx:r=0}){let i=new Ua({fs:e,dir:t,gitdir:n});if(!(await i.readStashCommit(r)).commit)return;let a=i.refStashPath;await xr(a,async()=>{await e.exists(a)&&await e.rm(a)});let o=await i.readStashReflogs({parsed:!1});if(!o.length)return;o.splice(r,1);let s=i.refLogsStashPath;await xr({reflogEntries:o,stashReflogPath:s,stashMgr:i},async()=>{if(o.length){await e.write(s,o.reverse().join(`
|
|
76
|
-
`)+`
|
|
77
|
-
`,`utf8`);let t=o[o.length-1].split(` `)[1];await i.writeStashRef(t)}else await e.rm(s)})}async function Ya({fs:e,dir:t,gitdir:n}){return new Ua({fs:e,dir:t,gitdir:n}).readStashReflogs({parsed:!0})}async function Xa({fs:e,dir:t,gitdir:n}){let r=new Ua({fs:e,dir:t,gitdir:n}),i=[r.refStashPath,r.refLogsStashPath];await xr(i,async()=>{await Promise.all(i.map(async t=>{if(await e.exists(t))return e.rm(t)}))})}async function Za({fs:e,dir:t,gitdir:n,refIdx:r=0}){await qa({fs:e,dir:t,gitdir:n,refIdx:r}),await Ja({fs:e,dir:t,gitdir:n,refIdx:r})}async function Qa({fs:e,dir:t,gitdir:n=H(t,`.git`),op:r=`push`,message:i=``,refIdx:a=0}){X(`fs`,e),X(`dir`,t),X(`gitdir`,n),X(`op`,r);let o={push:Ga,apply:qa,drop:Ja,list:Ya,clear:Xa,pop:Za,create:Ka},s=[`apply`,`drop`,`pop`];try{let c=new Y(e),l=await Z({fsp:c,dotgit:n});[`refs`,`logs`,`logs/refs`].map(e=>H(l,e)).forEach(async e=>{await c.exists(e)||await c.mkdir(e)});let u=o[r];if(u){if(s.includes(r)&&a<0)throw new Lt(`stash@${a}`,`number that is in range of [0, num of stash pushed]`);return await u({fs:c,dir:t,gitdir:l,message:i,refIdx:a})}throw Error(`To be implemented: ${r}`)}catch(e){throw e.caller=`git.stash`,e}}async function $a({fs:e,dir:t,gitdir:n=H(t,`.git`),filepath:r,cache:i={}}){try{X(`fs`,e),X(`gitdir`,n),X(`filepath`,r);let a=new Y(e),o=await Z({fsp:a,dotgit:n});if(await jn.isIgnored({fs:a,gitdir:o,dir:t,filepath:r}))return`ignored`;let s=await eo({fs:a,cache:i,gitdir:o,tree:await to({fs:a,cache:i,gitdir:o}),path:r}),c=await R.acquire({fs:a,gitdir:o,cache:i},async function(e){for(let t of e)if(t.path===r)return t;return null}),l=await a.lstat(H(t,r)),u=s!==null,d=c!==null,f=l!==null,p=async()=>{if(d&&!F(c,l))return c.oid;{let e=await a.read(H(t,r)),n=await La({gitdir:o,type:`blob`,object:e});return d&&c.oid===n&&l.size!==-1&&R.acquire({fs:a,gitdir:o,cache:i},async function(e){e.insert({filepath:r,stats:l,oid:n})}),n}};if(!u&&!f&&!d)return`absent`;if(!u&&!f&&d)return`*absent`;if(!u&&f&&!d)return`*added`;if(!u&&f&&d)return await p()===c.oid?`added`:`*added`;if(u&&!f&&!d)return`deleted`;if(u&&!f&&d)return c.oid,`*deleted`;if(u&&f&&!d)return await p()===s?`*undeleted`:`*undeletemodified`;if(u&&f&&d){let e=await p();return e===s?e===c.oid?`unmodified`:`*unmodified`:e===c.oid?`modified`:`*modified`}}catch(e){throw e.caller=`git.status`,e}}async function eo({fs:e,cache:t,gitdir:n,tree:r,path:i}){typeof i==`string`&&(i=i.split(`/`));let a=i.shift();for(let o of r)if(o.path===a){if(i.length===0)return o.oid;let{type:r,object:a}=await K({fs:e,cache:t,gitdir:n,oid:o.oid});if(r===`tree`)return eo({fs:e,cache:t,gitdir:n,tree:G.from(a),path:i});if(r===`blob`)throw new V(o.oid,r,`blob`,i.join(`/`))}return null}async function to({fs:e,cache:t,gitdir:n}){let r;try{r=await W.resolve({fs:e,gitdir:n,ref:`HEAD`})}catch(e){if(e instanceof B)return[]}let{tree:i}=await Xn({fs:e,cache:t,gitdir:n,oid:r});return i}async function no({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r=`HEAD`,filepaths:i=[`.`],filter:a,cache:o={},ignored:s=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let c=new Y(e);return await bn({fs:c,cache:o,dir:t,gitdir:await Z({fsp:c,dotgit:n}),trees:[J({ref:r}),hn(),ve()],map:async function(e,[n,r,o]){if(!n&&!o&&r&&!s&&await jn.isIgnored({fs:c,dir:t,filepath:e})||!i.some(t=>cr(e,t)))return null;if(a&&!a(e))return;let[l,u,d]=await Promise.all([n&&n.type(),r&&r.type(),o&&o.type()]),f=[l,u,d].includes(`blob`);if((l===`tree`||l===`special`)&&!f)return;if(l===`commit`)return null;if((u===`tree`||u===`special`)&&!f)return;if(d===`commit`)return null;if((d===`tree`||d===`special`)&&!f)return;let p=l===`blob`?await n.oid():void 0,m=d===`blob`?await o.oid():void 0,h;l!==`blob`&&u===`blob`&&d!==`blob`?h=`42`:u===`blob`&&(h=await r.oid());let g=[void 0,p,h,m],_=g.map(e=>g.indexOf(e));return _.shift(),[e,..._]}})}catch(e){throw e.caller=`git.statusMatrix`,e}}async function ro({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,object:i,force:a=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r);let t=new Y(e);if(r===void 0)throw new Vt(`ref`);r=r.startsWith(`refs/tags/`)?r:`refs/tags/${r}`;let o=await Z({fsp:t,dotgit:n}),s=await W.resolve({fs:t,gitdir:o,ref:i||`HEAD`});if(!a&&await W.exists({fs:t,gitdir:o,ref:r}))throw new Et(`tag`,r);await W.writeRef({fs:t,gitdir:o,ref:r,value:s})}catch(e){throw e.caller=`git.tag`,e}}async function io({fs:e,dir:t,gitdir:n=H(t,`.git`),cache:r={},filepath:i,oid:a,mode:o,add:s,remove:c,force:l}){try{X(`fs`,e),X(`gitdir`,n),X(`filepath`,i);let u=new Y(e),d=await Z({fsp:u,dotgit:n});if(c)return await R.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!l){let e=await u.lstat(H(t,i));if(e){if(e.isDirectory())throw new It(`directory`);return}}e.has({filepath:i})&&e.delete({filepath:i})});let f;if(!a){if(f=await u.lstat(H(t,i)),!f)throw new B(`file at "${i}" on disk and "remove" not set`);if(f.isDirectory())throw new It(`directory`)}return await R.acquire({fs:u,gitdir:d,cache:r},async function(e){if(!s&&!e.has({filepath:i}))throw new B(`file at "${i}" in index and "add" not set`);let n;if(a)n={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:o,uid:0,gid:0,size:0};else{n=f;let e=n.isSymbolicLink()?await u.readlink(H(t,i)):await u.read(H(t,i));a=await Q({fs:u,gitdir:d,type:`blob`,format:`content`,object:e})}return e.insert({filepath:i,oid:a,stats:n}),a})}catch(e){throw e.caller=`git.updateIndex`,e}}function ao(){try{return $r.version}catch(e){throw e.caller=`git.version`,e}}async function oo({fs:e,dir:t,gitdir:n=H(t,`.git`),trees:r,map:i,reduce:a,iterate:o,cache:s={}}){try{X(`fs`,e),X(`gitdir`,n),X(`trees`,r);let c=new Y(e);return await bn({fs:c,cache:s,dir:t,gitdir:await Z({fsp:c,dotgit:n}),trees:r,map:i,reduce:a,iterate:o})}catch(e){throw e.caller=`git.walk`,e}}async function so({fs:e,dir:t,gitdir:n=H(t,`.git`),blob:r}){try{X(`fs`,e),X(`gitdir`,n),X(`blob`,r);let t=new Y(e);return await Q({fs:t,gitdir:await Z({fsp:t,dotgit:n}),type:`blob`,object:r,format:`content`})}catch(e){throw e.caller=`git.writeBlob`,e}}async function co({fs:e,dir:t,gitdir:n=H(t,`.git`),commit:r}){try{X(`fs`,e),X(`gitdir`,n),X(`commit`,r);let t=new Y(e);return await Va({fs:t,gitdir:await Z({fsp:t,dotgit:n}),commit:r})}catch(e){throw e.caller=`git.writeCommit`,e}}async function lo({fs:e,dir:t,gitdir:n=H(t,`.git`),type:i,object:a,format:o=`parsed`,oid:s,encoding:c=void 0}){try{let t=new Y(e),l=await Z({fsp:t,dotgit:n});if(o===`parsed`){switch(i){case`commit`:a=dn.from(a).toObject();break;case`tree`:a=G.from(a).toObject();break;case`blob`:a=r.Buffer.from(a,c);break;case`tag`:a=cn.from(a).toObject();break;default:throw new V(s||``,i,`blob|commit|tag|tree`)}o=`content`}return s=await Q({fs:t,gitdir:l,type:i,object:a,oid:s,format:o}),s}catch(e){throw e.caller=`git.writeObject`,e}}async function uo({fs:e,dir:t,gitdir:n=H(t,`.git`),ref:r,value:i,force:a=!1,symbolic:o=!1}){try{X(`fs`,e),X(`gitdir`,n),X(`ref`,r),X(`value`,i);let t=new Y(e);if(!tr(r,!0))throw new Lt(r,v.clean(r));let s=await Z({fsp:t,dotgit:n});if(!a&&await W.exists({fs:t,gitdir:s,ref:r}))throw new Et(`ref`,r);o?await W.writeSymbolicRef({fs:t,gitdir:s,ref:r,value:i}):(i=await W.resolve({fs:t,gitdir:s,ref:i}),await W.writeRef({fs:t,gitdir:s,ref:r,value:i}))}catch(e){throw e.caller=`git.writeRef`,e}}async function fo({fs:e,gitdir:t,tag:n}){return await Q({fs:e,gitdir:t,type:`tag`,object:cn.from(n).toObject(),format:`content`})}async function po({fs:e,dir:t,gitdir:n=H(t,`.git`),tag:r}){try{X(`fs`,e),X(`gitdir`,n),X(`tag`,r);let t=new Y(e);return await fo({fs:t,gitdir:await Z({fsp:t,dotgit:n}),tag:r})}catch(e){throw e.caller=`git.writeTag`,e}}async function mo({fs:e,dir:t,gitdir:n=H(t,`.git`),tree:r}){try{X(`fs`,e),X(`gitdir`,n),X(`tree`,r);let t=new Y(e);return await Zn({fs:t,gitdir:await Z({fsp:t,dotgit:n}),tree:r})}catch(e){throw e.caller=`git.writeTree`,e}}var ho={Errors:Qt,STAGE:ve,TREE:J,WORKDIR:hn,add:Rn,abortMerge:An,addNote:$n,addRemote:rr,annotatedTag:ar,branch:sr,cherryPick:Dr,checkout:mr,clone:li,commit:ui,getConfig:Mi,getConfigAll:Pi,setConfig:Ba,currentBranch:di,deleteBranch:pi,deleteRef:mi,deleteRemote:gi,deleteTag:vi,expandOid:Si,expandRef:Ci,fastForward:Di,fetch:Oi,findMergeBase:ki,findRoot:ji,getRemoteInfo:Fi,getRemoteInfo2:Li,hashBlob:zi,indexPack:Vi,init:Hi,isDescendent:Wi,isIgnored:Gi,listBranches:Ki,listFiles:Yi,listNotes:Zi,listRefs:Qi,listRemotes:ea,listServerRefs:ra,listTags:ia,log:la,merge:ua,packObjects:ma,pull:ha,push:xa,readBlob:wa,readCommit:Ta,readNote:Da,readObject:Oa,readTag:Aa,readTree:ja,remove:Ma,removeNote:Pa,renameBranch:Ia,resetIndex:Ra,updateIndex:io,resolveRef:za,status:$a,statusMatrix:no,tag:ro,version:ao,walk:oo,writeBlob:so,writeCommit:co,writeObject:lo,writeRef:uo,writeTag:po,writeTree:mo,stash:Qa};t.Errors=Qt,t.STAGE=ve,t.TREE=J,t.WORKDIR=hn,t.abortMerge=An,t.add=Rn,t.addNote=$n,t.addRemote=rr,t.annotatedTag=ar,t.branch=sr,t.checkout=mr,t.cherryPick=Dr,t.clone=li,t.commit=ui,t.currentBranch=di,t.default=ho,t.deleteBranch=pi,t.deleteRef=mi,t.deleteRemote=gi,t.deleteTag=vi,t.expandOid=Si,t.expandRef=Ci,t.fastForward=Di,t.fetch=Oi,t.findMergeBase=ki,t.findRoot=ji,t.getConfig=Mi,t.getConfigAll=Pi,t.getRemoteInfo=Fi,t.getRemoteInfo2=Li,t.hashBlob=zi,t.indexPack=Vi,t.init=Hi,t.isDescendent=Wi,t.isIgnored=Gi,t.listBranches=Ki,t.listFiles=Yi,t.listNotes=Zi,t.listRefs=Qi,t.listRemotes=ea,t.listServerRefs=ra,t.listTags=ia,t.log=la,t.merge=ua,t.packObjects=ma,t.pull=ha,t.push=xa,t.readBlob=wa,t.readCommit=Ta,t.readNote=Da,t.readObject=Oa,t.readTag=Aa,t.readTree=ja,t.remove=Ma,t.removeNote=Pa,t.renameBranch=Ia,t.resetIndex=Ra,t.resolveRef=za,t.setConfig=Ba,t.stash=Qa,t.status=$a,t.statusMatrix=no,t.tag=ro,t.updateIndex=io,t.version=ao,t.walk=oo,t.writeBlob=so,t.writeCommit=co,t.writeObject=lo,t.writeRef=uo,t.writeTag=po,t.writeTree=mo}))(),1),D=a();globalThis.Buffer||(globalThis.Buffer=D.Buffer);const O={async request({url:e,method:t=`GET`,headers:n={},body:r}){r&&=await k(r);let i=await fetch(e,{method:t,headers:n,body:r,credentials:`omit`}),a=i.body&&typeof i.body.getReader==`function`?te(i.body):[new Uint8Array(await i.arrayBuffer())],o={};for(let[e,t]of i.headers.entries())o[e]=t;return{url:i.url,method:t,statusCode:i.status,statusMessage:i.statusText,body:a,headers:o}}};async function k(e){let t=[];if(e[Symbol.asyncIterator])for await(let n of e)t.push(n);else if(e[Symbol.iterator])for(let n of e)t.push(n);else if(e.next){let n=await e.nexT();for(;!n.done;)t.push(n.value),n=await e.nexT()}else return e;let n=t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.length;return r}function te(e){let t=e.getReader();return{next(){return t.read()},return(){return t.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}let A=null,j=null,M=null,ne=null,re=null;function ie(e){return e.trim().replace(/^[\\/]+/,``).replace(/[\\/]+$/,``).split(/[\\/]+/).filter(e=>e!==`.`&&e!==``).join(`/`)}const N=new class{_map=new Map;_maxSize;constructor(e=2048){this._maxSize=e}clear(){this._map.clear()}get(e){let t=this._map.get(e);return t!==void 0&&(this._map.delete(e),this._map.set(e,t)),t}invalidate(e){let t=e.endsWith(`/`)?e:e+`/`;for(let n of this._map.keys())(n===e||n.startsWith(t))&&this._map.delete(n)}set(e,t){if(this._map.size>=this._maxSize){let e=this._map.keys().next().value;e!==void 0&&this._map.delete(e)}this._map.set(e,t)}};async function ae(e,t,n={},r=``){let i=e,a=r;for(let e of t){a=a?`${a}/${e}`:e;let t=N.get(a);t&&!n.create?i=t:(i=await i.getDirectoryHandle(e,{create:n.create??!1}),N.set(a,i))}return i}async function oe(e,t,n={}){let r=ie(t),i=r.split(`/`).filter(Boolean);if(i.length===0)return e;let a=await ae(e,i.slice(0,-1),n),o=i[i.length-1];if(n.forceFile||o.includes(`.`))try{return await a.getFileHandle(o,{create:n.create??!1})}catch{}try{let e=await a.getDirectoryHandle(o,{create:n.create??!1}),t=r;return N.set(t,e),e}catch{return await a.getFileHandle(o,{create:n.create??!1})}}async function se(e,t,n={}){let r=ie(t).split(`/`).filter(Boolean);return r.length===0?e:ae(e,r,n)}async function ce(e,t,n={}){let r=ie(t).split(`/`).filter(Boolean);if(r.length===0)throw Error(`Cannot resolve '.' as file`);return(await ae(e,r.slice(0,-1),n)).getFileHandle(r[r.length-1],{create:n.create??!1})}async function le(e,t){let n=ie(t).split(`/`).filter(Boolean);if(n.length===0)throw Error(`Cannot get parent of root`);let r=n[n.length-1];return[await ae(e,n.slice(0,-1)),r]}function P(e){return e.trim().replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^\.\//,``)}function F(e){let t=new Map,n=`repos/.git-modes`;function r(e){return e.replace(/\\/g,`/`.replace(/^\/+/,``))}async function i(){try{let r=await(await(await ce(e,n)).getFile()).text(),i=JSON.parse(r);for(let[e,n]of i)t.set(e,n)}catch{}}let a=null;function o(){a===null&&(a=setTimeout(async()=>{a=null;try{let r=await(await ce(e,n,{create:!0})).createWritable(),i=JSON.stringify([...t.entries()]);await r.write(new TextEncoder().encode(i)),await r.close()}catch{}},500))}let s=i(),c={async readFile(t,n){let r=await(await(await ce(e,t)).getFile()).arrayBuffer(),i=typeof n==`string`?n:n?.encoding;return i===`utf8`||i===`utf-8`?new TextDecoder().decode(r):new Uint8Array(r)},async writeFile(n,i,a){let s=await(await ce(e,n,{create:!0})).createWritable();typeof i==`string`&&(i=new TextEncoder().encode(i)),await s.write(i),await s.close();let c=typeof a==`object`&&a?a.mode:void 0,l=r(n);if(c!=null){let e=(c&73)!=0;t.set(l,e?33261:33188),o()}else t.has(l)||t.set(l,33188)},async mkdir(t){await se(e,t,{create:!0})},async rmdir(n){let[i,a]=await le(e,n);await i.removeEntry(a,{recursive:!0});let o=r(n)+`/`;for(let e of t.keys())(e===r(n)||e.startsWith(o))&&t.delete(e);N.invalidate(ie(n))},async readdir(t){let n=await se(e,t),r=[];for await(let[e]of n.entries())r.push(e);return r},async stat(n){await s;let i;try{i=await oe(e,n)}catch{let e=Error(`ENOENT: no such file or directory, stat '${n}'`);throw e.code=`ENOENT`,e}if(i.kind===`directory`){let e=new Date;return{isDirectory:()=>!0,isFile:()=>!1,isSymbolicLink:()=>!1,size:0,mtimeMs:Date.now(),mode:16877,ino:0,dev:0,nlink:1,uid:0,gid:0,ctime:e,mtime:e}}else{let e=await i.getFile(),a=new Date(e.lastModified),o=r(n),s=t.get(o)??33188;return{isDirectory:()=>!1,isFile:()=>!0,isSymbolicLink:()=>!1,size:e.size,mtimeMs:e.lastModified,mode:s,ino:0,dev:0,nlink:1,uid:0,gid:0,ctime:a,mtime:a}}},async lstat(e){return c.stat(e)},async unlink(n){let[i,a]=await le(e,n);await i.removeEntry(a),t.delete(r(n))},async symlink(e,t){throw Error(`OPFS does not support symlinks`)},async readlink(e){return await c.readFile(e,`utf8`)}};return{promises:c}}const ue=F,I=`repos`;function de(e,t){if(e===`custom`&&t)return t;if(e===`public`)return`https://www.cors-anywhere.com`;let{protocol:i,host:a,hostname:o}=globalThis.location;return o===`localhost`||o===`127.0.0.1`?`${i}//${a}/git-proxy`:`http://${r}:${n}/git-proxy`}async function fe(){return re||=(async()=>{if(A=E.default,j=O,!M){let e;try{e=await navigator.storage.getDirectory()}catch(t){console.warn(`OPFS is unavailable for git root, falling back to memory:`,t);let{getMemoryOpfsRoot:n}=await import(`./memoryStorage-C1llaYus.js`).then(e=>e.n);e=n()}M=F(e),ne=M.promises}})(),await re,{git:A,http:j,fs:M,pfs:ne}}async function L(e){let t=await fe();if(e){let n=F(e);return{git:t.git,http:t.http,fs:n,pfs:n.promises,repoDirFn:e=>`repos/${e}`}}return{...t,repoDirFn:pe}}function R(e){return(e.replace(/\/+$/,``).split(`/`).pop()||`repo`).replace(/\.git$/,``)}function pe(e){return`${I}/${e}`}async function z(e,t,n){try{await e.getConfig({fs:t,dir:n,path:`core.filemode`})!==!1&&await e.setConfig({fs:t,dir:n,path:`core.filemode`,value:!1})}catch(e){console.error(`Failed to set core.filemode=false:`,e)}}async function me(e,t){try{await e.mkdir(t)}catch{}}function he({token:e,username:t,password:n}={}){if(!e&&!t)return{};let r;e?r={Authorization:`Basic ${btoa(`${e}:x-oauth-basic`)}`}:t&&(r={Authorization:`Basic ${btoa(`${t}:${n||``}`)}`});let i=()=>e?{username:e,password:`x-oauth-basic`}:t?{username:t,password:n||``}:{cancel:!0},a=()=>({cancel:!0});return{...r?{headers:r}:{},onAuth:i,onAuthFailure:a}}async function ge({url:e,branch:t,depth:n=20,corsProxy:r,name:i,token:a,username:o,password:s,groupRoot:c}){let{git:l,http:u,fs:d,pfs:f,repoDirFn:p}=await L(c),m=i||R(e),h=p(m);r||=de(`local`),await me(f,I),await me(f,h);let g=he({token:a,username:o,password:s});try{let i={fs:d,http:u,dir:h,url:e,singleBranch:!0,depth:n,corsProxy:r,...g};t&&(i.ref=t),await l.clone(i)}catch{try{let i={fs:d,http:u,dir:h,url:e,singleBranch:!0,depth:n,corsProxy:r,...g};t&&(i.ref=t),await l.fetch(i)}catch{try{await Pe(f,h),await me(f,h);let i={fs:d,http:u,dir:h,url:e,singleBranch:!0,depth:n,corsProxy:r,...g};t&&(i.ref=t),await l.clone(i)}catch(t){throw Error(`Failed to clone/fetch ${e}: ${t instanceof Error?t.message:String(t)}`)}}}return await z(l,d,h),m}async function _e({repo:e,ref:t,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e);return await r.checkout({fs:i,dir:o,ref:t,force:!0}),`Checked out ${t} in ${e}`}async function ve({repo:e,name:t,checkout:n=!1,startPoint:r,groupRoot:i}){let{git:a,fs:o,repoDirFn:s}=await L(i),c=s(e),l={fs:o,dir:c,ref:t};return r&&(l.object=r),await a.branch(l),n?(await a.checkout({fs:o,dir:c,ref:t}),`Created and switched to branch ${t} in ${e}`):`Created branch ${t} in ${e}`}async function B({repo:e,groupRoot:t}){let{git:n,fs:r,repoDirFn:i}=await L(t),a=i(e);await z(n,r,a);let o=await n.statusMatrix({fs:r,dir:a});if(o.length===0)return`Empty repository.`;let s=[];for(let[e,t,n,r]of o){let i=``;if(t===0&&n===2&&r===2)i=`added`;else if(t===0&&n===2&&r===0)i=`new (unstaged)`;else if(t===1&&n===2&&r===2)i=`modified (staged)`;else if(t===1&&n===2&&r===1)i=`modified`;else if(t===1&&n===0&&r===0)i=`deleted`;else if(t===1&&n===1&&r===1)continue;else i=`[${t},${n},${r}]`;s.push(`${i}: ${e}`)}return s.length===0?`On branch ${await n.currentBranch({fs:r,dir:a})||`(detached HEAD)`}\nNothing to commit, working tree clean.`:`On branch ${await n.currentBranch({fs:r,dir:a})||`(detached HEAD)`}\n${s.join(`
|
|
78
|
-
`)}`}async function V({repo:e,ref:t,depth:n=10,groupRoot:r}){let{git:i,fs:a,repoDirFn:o}=await L(r),s={fs:a,dir:o(e),depth:n};t&&(s.ref=t);let c=await i.log(s);return c.length===0?`No commits found.`:c.map(e=>{let t=e.commit,n=new Date(t.author.timestamp*1e3).toISOString();return`${e.oid} ${n} ${t.author.name} — ${t.message.trim().split(`
|
|
79
|
-
`)[0]}`}).join(`
|
|
80
|
-
`)}async function ye({repo:e,ref1:t,ref2:n,groupRoot:r}){let{git:i,fs:a,repoDirFn:o}=await L(r),s=o(e),c=a.promises;if(await z(i,a,s),!t&&!n){let e=(await i.statusMatrix({fs:a,dir:s})).filter(([,e,t])=>!(e===1&&t===1));if(e.length===0)return`No differences.`;let t=[];for(let[n,r,o]of e)try{if(r===0&&o===2){let e=(await xe(c,s,n)).split(`
|
|
81
|
-
`).map(e=>`+${e}`).join(`
|
|
82
|
-
`);t.push(`--- /dev/null\n+++ ${n} (new file)\n${e}`)}else if(r===1&&o===0){let e=(await be(i,a,s,n)).split(`
|
|
83
|
-
`).map(e=>`-${e}`).join(`
|
|
84
|
-
`);t.push(`--- ${n} (deleted)\n+++ /dev/null\n${e}`)}else if(r===1&&o===2){let e=await be(i,a,s,n),r=await xe(c,s,n);t.push(Ce(n,e,r))}else t.push(`??? ${n} [${r},${o}]`)}catch{r===0&&o===2?t.push(`+++ ${n} (new file)`):r===1&&o===0?t.push(`--- ${n} (deleted)`):t.push(`~~~ ${n} (modified)`)}return t.join(`
|
|
85
|
-
`)}let l=await i.resolveRef({fs:a,dir:s,ref:t||`HEAD`}),u=await i.resolveRef({fs:a,dir:s,ref:n});if(l===u)return`Refs are identical.`;let d=[i.TREE({ref:l}),i.TREE({ref:u})],f=(await i.walk({fs:a,dir:s,trees:d,map:async function(e,[t,n]){if(e===`.`||await t?.type()===`tree`||await n?.type()===`tree`)return;let r=await t?.oid(),i=await n?.oid();if(r===i)return;let a=``,o=``,s=`modified`;try{t&&r?a=Se(await t.content()):s=`added`,n&&i?o=Se(await n.content()):s=`deleted`}catch{return`??? ${e} (binary or read error)`}return s===`added`?`--- /dev/null\n+++ ${e} (new file)\n${o.split(`
|
|
86
|
-
`).map(e=>`+${e}`).join(`
|
|
87
|
-
`)}`:s===`deleted`?`--- ${e} (deleted)\n+++ /dev/null\n${a.split(`
|
|
88
|
-
`).map(e=>`-${e}`).join(`
|
|
89
|
-
`)}`:Ce(e,a,o)}})).filter(Boolean).join(`
|
|
90
|
-
|
|
91
|
-
`);return f?`Comparing ${t||`HEAD`} (${l.substring(0,7)}) → ${n} (${u.substring(0,7)})\n\n${f}`:`Comparing ${t||`HEAD`} (${l.substring(0,7)}) → ${n} (${u.substring(0,7)})\nNo differences.`}async function be(e,t,n,r){let i=await e.resolveRef({fs:t,dir:n,ref:`HEAD`}),{blob:a}=await e.readBlob({fs:t,dir:n,oid:i,filepath:r});return Se(a)}async function xe(e,t,n){let r=await e.readFile(`${t}/${n}`);return typeof r==`string`?r:Se(r)}function Se(e){return typeof TextDecoder<`u`?new TextDecoder().decode(e):D.Buffer.from(e).toString(`utf-8`)}function Ce(e,t,n){let r=t.split(`
|
|
92
|
-
`),i=n.split(`
|
|
93
|
-
`),a=`--- a/${e}\n+++ b/${e}`,o=[],s=Math.max(r.length,i.length);for(let e=0;e<s;e++){let t=e<r.length?r[e]:void 0,n=e<i.length?i[e]:void 0;t===n?o.push(` ${t}`):(t!==void 0&&o.push(`-${t}`),n!==void 0&&o.push(`+${n}`))}return`${a}\n${o.join(`
|
|
94
|
-
`)}`}async function we({repo:e,remote:t=`origin`,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e);try{return(await r.listRemotes({fs:i,dir:o})).find(e=>e.remote===t)?.url}catch{return}}async function Te({repo:e,remote:t=!1,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e),s=await r.listBranches({fs:i,dir:o,remote:t?`origin`:void 0}),c=null;try{c=await r.currentBranch({fs:i,dir:o})}catch{}return s.length===0?`No branches found.`:s.map(e=>e===c?`* ${e}`:` ${e}`).join(`
|
|
95
|
-
`)}async function Ee({repo:e,groupRoot:t}){let{git:n,fs:r,repoDirFn:i}=await L(t),a=i(e);return await n.currentBranch({fs:r,dir:a})||`(detached HEAD)`}async function H({repo:e,message:t,authorName:n=`ShadowClaw`,authorEmail:r=`agent@example.com`,groupRoot:i}){let{git:a,fs:o,repoDirFn:s}=await L(i),c=s(e);await z(a,o,c);let l=await a.statusMatrix({fs:o,dir:c});for(let[e,t,n,r]of l)(n!==r||t===0)&&(n===0?await a.remove({fs:o,dir:c,filepath:e}):await a.add({fs:o,dir:c,filepath:e}));return`Committed ${(await a.commit({fs:o,dir:c,message:t,author:{name:n,email:r}})).substring(0,7)}: ${t}`}async function De({repo:e,filepath:t,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e),s=t==null||t===``?[`.`]:Array.isArray(t)?t.filter(e=>e!=null&&e!==``).map(e=>P(e)):[P(t)];if(s.length===0&&s.push(`.`),await z(r,i,o),s.length===1&&s[0]===`.`){let t=(await r.statusMatrix({fs:i,dir:o})).filter(([,e,t,n])=>t!==n||e===0).map(([e])=>e);if(t.length===0)return`No changes to add in ${e}`;for(let e of t)await r.add({fs:i,dir:o,filepath:e});return`Added ${t.join(`, `)} to the index in ${e}`}for(let e of s)await r.add({fs:i,dir:o,filepath:e});return`Added ${s.join(`, `)} to the index in ${e}`}async function Oe({repo:e,branch:t,authorName:n=`ShadowClaw`,authorEmail:r=`agent@example.com`,token:i,username:a,password:o,remote:s=`origin`,corsProxy:c,groupRoot:l}){let{git:u,http:d,fs:f,repoDirFn:p}=await L(l),m=p(e),h=t||await u.currentBranch({fs:f,dir:m});if(!h)throw Error(`No branch to pull — HEAD is detached.`);let g=he({token:i,username:a,password:o}),_={fs:f,http:d,dir:m,ref:h,remote:s,singleBranch:!0,author:{name:n,email:r},corsProxy:c||de(`local`),...g};return await u.pull(_),`Pulled latest changes for ${h} from ${s} successfully.`}async function ke({repo:e,branch:t,remoteRef:n,token:r,username:i,password:a,remote:o=`origin`,corsProxy:s,force:c=!1,tags:l=!1,groupRoot:u}){let{git:d,http:f,fs:p,repoDirFn:m}=await L(u),h=m(e),g=t||await d.currentBranch({fs:p,dir:h});if(!g)throw Error(`No branch to push — HEAD is detached.`);let _=he({token:r,username:i,password:a}),v={fs:p,http:f,dir:h,ref:g,remote:o,force:c,corsProxy:s||de(`local`),..._,...n?{remoteRef:n}:{},...l?{tags:!0}:{}},y=await d.push(v),b=n||g;return y.ok?`Pushed ${g} to ${o}/${b} successfully.`:`Push result: ${JSON.stringify(y.refs||y)}`}async function Ae({repo:e,theirs:t,authorName:n=`ShadowClaw`,authorEmail:r=`agent@example.com`,groupRoot:i}){let{git:a,fs:o,repoDirFn:s}=await L(i),c=s(e),l=await a.currentBranch({fs:o,dir:c});if(!l)throw Error(`Cannot merge — HEAD is detached.`);let u=await a.merge({fs:o,dir:c,ours:l,theirs:t,abortOnConflict:!1,author:{name:n,email:r}});return u.alreadyMerged?`Already up to date — ${l} already contains ${t}.`:u.fastForward?(await a.checkout({fs:o,dir:c,ref:l}),`Fast-forward merge: ${l} updated to ${t} (${u.oid?.substring(0,7)}).`):`Merged ${t} into ${l} (merge commit: ${u.oid?.substring(0,7)}).`}async function je({repo:e,ref:t,groupRoot:n}){let{git:r,fs:i,pfs:a,repoDirFn:o}=await L(n),s=o(e),c=await r.currentBranch({fs:i,dir:s});if(!c)throw Error(`Cannot reset — HEAD is detached.`);let l=await r.resolveRef({fs:i,dir:s,ref:t}),u=`${s}/.git/refs/heads/${c}`;return await a.writeFile(u,l+`
|
|
96
|
-
`,`utf8`),await r.checkout({fs:i,dir:s,ref:c,force:!0}),`Reset ${c} to ${t} (${l.substring(0,7)}). Working tree updated.`}async function Me({groupRoot:e}={}){let{pfs:t}=await L(e),n=I;try{let e=await t.readdir(n),r=[];for(let i of e){let e=`${n}/${i}/.git`;try{(await t.stat(e)).isDirectory()&&r.push(i)}catch{}}return r.length===0?`No repos cloned.`:r.join(`
|
|
97
|
-
`)}catch{return`No repos cloned.`}}async function Ne({repo:e,groupRoot:t}){if(!e)throw Error(`repo name is required`);if(e.includes(`..`)||e.includes(`/`))throw Error(`Invalid repo name`);let{pfs:n,repoDirFn:r}=await L(t),i=`${r(e)}/.git`;try{await n.readdir(i)}catch{return`Repo "${e}" not found in git storage.`}return await Pe(n,i),`Deleted git metadata for "${e}" from OPFS git storage. Working tree files remain in repos/${e}.`}async function Pe(e,t){try{await e.rmdir(t)}catch{let n=await e.readdir(t);for(let r of n){let n=`${t}/${r}`;(await e.stat(n)).isDirectory()?await Pe(e,n):await e.unlink(n)}await e.rmdir(t)}}async function Fe({repo:e,branch:t,token:n,username:r,password:i,remote:a=`origin`,corsProxy:o,groupRoot:s}){let{git:c,http:l,fs:u,repoDirFn:d}=await L(s),f=d(e),p=he({token:n,username:r,password:i}),m={fs:u,http:l,dir:f,remote:a,singleBranch:!0,corsProxy:o||de(`local`),...p};t&&(m.ref=t);let h=(await c.fetch(m)).fetchHead||`unknown`;return`Fetched ${t||`default branch`} from ${a} successfully. (FETCH_HEAD is ${h})`}async function Ie({repo:e,ref:t,filepath:n,groupRoot:r}){let{git:i,fs:a,repoDirFn:o}=await L(r),s=o(e),c=await i.resolveRef({fs:a,dir:s,ref:t}),{blob:l}=await i.readBlob({fs:a,dir:s,oid:c,filepath:n});return Se(l)}async function Le({repo:e,ref:t,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e),s=await r.resolveRef({fs:i,dir:o,ref:t}),c=await r.readCommit({fs:i,dir:o,oid:s}),l=c.commit.parent&&c.commit.parent.length>0?c.commit.parent[0]:void 0,u=`(No parent commit, showing as new file is not yet supported in gitShow)`;return u=l?await ye({repo:e,ref1:l,ref2:s}):`Initial commit.`,`commit ${s}\nAuthor: ${`${c.commit.author.name} <${c.commit.author.email}>`}\nDate: ${new Date(c.commit.author.timestamp*1e3).toISOString()}\n\n ${c.commit.message.replace(/\n/g,`
|
|
98
|
-
`)}\n\n${u}`}async function Re({repo:e,name:t,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e);return await r.deleteBranch({fs:i,dir:o,ref:t}),`Deleted local branch ${t} in ${e}`}async function ze({repo:e,groupRoot:t}){let{git:n,fs:r,pfs:i,repoDirFn:a}=await L(t),o=a(e);return await me(i,I),await me(i,o),await n.init({fs:r,dir:o,defaultBranch:`main`}),await z(n,r,o),`Initialized empty Git repository in ${e} (branch: main)`}async function Be({repo:e,tag:t,message:n,authorName:r=`ShadowClaw`,authorEmail:i=`agent@example.com`,groupRoot:a}){let{git:o,fs:s,repoDirFn:c}=await L(a),l=c(e);return n?(await o.annotatedTag({fs:s,dir:l,ref:t,message:n,tagger:{name:r,email:i}}),`Created annotated tag ${t} in ${e}`):(await o.tag({fs:s,dir:l,ref:t}),`Created tag ${t} in ${e}`)}async function Ve({repo:e,groupRoot:t}){let{git:n,fs:r,repoDirFn:i}=await L(t),a=i(e),o=await n.listTags({fs:r,dir:a});return o.length===0?`No tags found.`:o.join(`
|
|
99
|
-
`)}async function He({repo:e,command:t,remote:n,url:r,groupRoot:i}){let{git:a,fs:o,repoDirFn:s}=await L(i),c=s(e);if(t===`list`){let e=await a.listRemotes({fs:o,dir:c});return e.length===0?`No remotes.`:e.map(e=>`${e.remote}\t${e.url}`).join(`
|
|
100
|
-
`)}else if(t===`add`){if(!n||!r)throw Error(`remote and url are required for add`);return await a.addRemote({fs:o,dir:c,remote:n,url:r}),`Added remote ${n} -> ${r}`}else if(t===`remove`){if(!n)throw Error(`remote is required for remove`);return await a.deleteRemote({fs:o,dir:c,remote:n}),`Removed remote ${n}`}throw Error(`Invalid command`)}async function Ue({repo:e,command:t,key:n,value:r,groupRoot:i}){let{git:a,fs:o,repoDirFn:s}=await L(i),c=s(e);if(t===`get`){let e=await a.getConfig({fs:o,dir:c,path:n});return e===void 0?``:String(e)}else if(t===`set`){if(r===void 0)throw Error(`value is required for set`);return await a.setConfig({fs:o,dir:c,path:n,value:r}),`Set ${n} = ${r}`}throw Error(`Invalid command`)}async function We({repo:e,filepath:t,groupRoot:n}){let{git:r,fs:i,repoDirFn:a}=await L(n),o=a(e);if(Array.isArray(t))for(let e of t)await r.remove({fs:i,dir:o,filepath:e});else await r.remove({fs:i,dir:o,filepath:t});return`Unstaged ${Array.isArray(t)?t.join(`, `):t} in ${e}`}export{he as buildAuthCallbacks,z as ensureCoreFilemodeFalse,me as ensureDir,de as getProxyUrl,we as getRemoteUrl,De as gitAdd,ve as gitBranch,_e as gitCheckout,ge as gitClone,H as gitCommit,Ue as gitConfig,Ee as gitCurrentBranch,Re as gitDeleteBranch,Ne as gitDeleteRepo,ye as gitDiff,Fe as gitFetch,ze as gitInit,Te as gitListBranches,Me as gitListRepos,Ve as gitListTags,V as gitLog,Ae as gitMerge,Oe as gitPull,ke as gitPush,Ie as gitReadFileAtRef,He as gitRemote,je as gitReset,Le as gitShow,B as gitStatus,Be as gitTag,We as gitUnstage,L as initGitContext,fe as initGitFs,F as makeDirHandleFs,ue as makeOpfsFs,pe as repoDir,R as repoNameFromUrl,Pe as rmdirRecursive};
|