git-truck 4.0.0 → 4.1.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/build/client/assets/ChevronButton-DK6ES4LI.js +1 -0
- package/build/client/assets/{CollapsibleHeader-Bu4p-oqI.js → CollapsibleHeader-CowQ8BBC.js} +1 -1
- package/build/client/assets/Tooltip-4EXAWNsE.js +5 -0
- package/build/client/assets/api.abort-BsuDY3rd.js +1 -0
- package/build/client/assets/api.abort-D0XxKxsc.js +1 -0
- package/build/client/assets/api.commits-B4POWHc4.js +1 -0
- package/build/client/assets/api.commits-BwXLd7eY.js +1 -0
- package/build/client/assets/api.progress-9Sjpquqz.js +1 -0
- package/build/client/assets/api.progress-PbuJDh_8.js +1 -0
- package/build/client/assets/browse-D4C7blMn.js +1 -0
- package/build/client/assets/browse-f4khjgf7.js +1 -0
- package/build/client/assets/clear-cache-BzRoZVxS.js +1 -0
- package/build/client/assets/clear-cache-_qCibnyW.js +1 -0
- package/build/client/assets/{dist-QDdB6dtJ.js → dist-Q88wN5JZ.js} +1 -1
- package/build/client/assets/{manifest-a38e366c.js → manifest-27f3fdf9.js} +1 -1
- package/build/client/assets/root-C1A3dI8J.css +2 -0
- package/build/client/assets/{root-CA2KruPD.js → root-CBAhjBmF.js} +2 -2
- package/build/client/assets/{ui-HOyuwkxV.js → ui-apdBVMs3.js} +1 -1
- package/build/client/assets/util-Cy1DhIdh.js +44 -0
- package/build/client/assets/view-xdV5WFuZ.js +4 -0
- package/build/client/assets/viewParams-BGn6CoZr.js +1 -0
- package/build/server/assets/{server-build-D8iMgYfe.js → server-build-CZoDK47O.js} +6008 -5774
- package/build/server/index.js +1 -1
- package/cli.mjs +94 -23
- package/package.json +2 -2
- package/build/client/assets/ChevronButton-ANoRM4oe.js +0 -1
- package/build/client/assets/Tooltip-DRu0grUy.js +0 -5
- package/build/client/assets/api.abort-CX5xkHwa.js +0 -1
- package/build/client/assets/api.abort-DxAkeS-W.js +0 -1
- package/build/client/assets/api.commits-DAF4WH2m.js +0 -1
- package/build/client/assets/api.commits-iEgBtL-A.js +0 -1
- package/build/client/assets/api.progress-BENNzkFW.js +0 -1
- package/build/client/assets/api.progress-DICNnGq5.js +0 -1
- package/build/client/assets/browse-DGrdg-dm.js +0 -1
- package/build/client/assets/browse-Mvd04mK4.js +0 -1
- package/build/client/assets/clear-cache-BTEuD7P-.js +0 -1
- package/build/client/assets/clear-cache-BdU23_cx.js +0 -1
- package/build/client/assets/root-CV-2KSQa.css +0 -2
- package/build/client/assets/util-CPW5oMgy.js +0 -44
- package/build/client/assets/view-Cwcd1vTK.js +0 -4
- package/build/client/assets/viewParams-BaE5Z0S4.js +0 -1
package/build/server/index.js
CHANGED
|
@@ -23036,6 +23036,6 @@ var require_express$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
23036
23036
|
var app = (0, (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
23037
23037
|
module.exports = require_express$1();
|
|
23038
23038
|
})))(), 1)).default)();
|
|
23039
|
-
app.use(createRequestHandler({ build: () => import("./assets/server-build-
|
|
23039
|
+
app.use(createRequestHandler({ build: () => import("./assets/server-build-CZoDK47O.js") }));
|
|
23040
23040
|
//#endregion
|
|
23041
23041
|
export { app };
|
package/cli.mjs
CHANGED
|
@@ -362,7 +362,7 @@ var n=an(),r=P(`node:events`).EventEmitter,i=on(),a=wn(),o=Cn(),s=Nn(),c=zn();e=
|
|
|
362
362
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
363
363
|
* MIT Licensed
|
|
364
364
|
*/
|
|
365
|
-
t.exports=Vn()}))(),1),Un=`4.
|
|
365
|
+
t.exports=Vn()}))(),1),Un=`4.1.0`,Wn=class extends Error{constructor(e){super(`${e} is locked`)}};const Gn={old:new Set,young:new Set},Kn=1024,qn=65535;let Jn;const Yn=()=>{let e=y.networkInterfaces(),t=new Set([void 0,`0.0.0.0`]);for(let n of Object.values(e))for(let e of n)t.add(e.address);return t},Xn=e=>new Promise((t,n)=>{let r=v.createServer();r.unref(),r.on(`error`,n),r.listen(e,()=>{let{port:e}=r.address();r.close(()=>{t(e)})})}),Zn=async(e,t)=>{if(e.host||e.port===0)return Xn(e);for(let n of t)try{await Xn({port:e.port,host:n})}catch(e){if(![`EADDRNOTAVAIL`,`EINVAL`].includes(e.code))throw e}return e.port},Qn=function*(e){e&&(yield*e),yield 0};async function $n(e){let t,n=new Set;if(e&&(e.port&&(t=typeof e.port==`number`?[e.port]:e.port),e.exclude)){let t=e.exclude;if(typeof t[Symbol.iterator]!=`function`)throw TypeError("The `exclude` option must be an iterable.");for(let e of t){if(typeof e!=`number`)throw TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(e))throw TypeError(`Number ${e} in the exclude option is not a safe integer and can't be used`)}n=new Set(t)}Jn===void 0&&(Jn=setTimeout(()=>{Jn=void 0,Gn.old=Gn.young,Gn.young=new Set},15e3),Jn.unref&&Jn.unref());let r=Yn();for(let i of Qn(t))try{if(n.has(i))continue;let t=await Zn({...e,port:i},r);for(;Gn.old.has(t)||Gn.young.has(t);){if(i!==0)throw new Wn(i);t=await Zn({...e,port:i},r)}return Gn.young.add(t),t}catch(e){if(![`EADDRINUSE`,`EACCES`].includes(e.code)&&!(e instanceof Wn))throw e}throw Error(`No available ports found`)}function er(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw TypeError("`from` and `to` must be integer numbers");if(e<Kn||e>qn)throw RangeError(`'from' must be between ${Kn} and ${qn}`);if(t<Kn||t>qn)throw RangeError(`'to' must be between ${Kn} and ${qn}`);if(e>t)throw RangeError("`to` must be greater than or equal to `from`");return function*(e,t){for(let n=e;n<=t;n++)yield n}(e,t)}let tr;function nr(){try{return d.statSync(`/.dockerenv`),!0}catch{return!1}}function rr(){try{return d.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function ir(){return tr===void 0&&(tr=nr()||rr()),tr}let ar;const or=()=>{try{return d.statSync(`/run/.containerenv`),!0}catch{return!1}};function sr(){return ar===void 0&&(ar=or()||ir()),ar}const cr=()=>{if(C.platform!==`linux`)return!1;if(y.release().toLowerCase().includes(`microsoft`))return!sr();try{if(d.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`))return!sr()}catch{}return d.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`)||d.existsSync(`/run/WSL`)?!sr():!1};var lr=C.env.__IS_WSL_TEST__?cr:cr();const ur=A(T.execFile),dr=()=>`${C.env.SYSTEMROOT||C.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,fr=async(e,t={})=>{let{powerShellPath:n,...r}=t,i=fr.encodeCommand(e);return ur(n??dr(),[...fr.argumentsPrefix,i],{encoding:`utf8`,...r})};fr.argumentsPrefix=[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`],fr.encodeCommand=e=>_.from(e,`utf16le`).toString(`base64`),fr.escapeArgument=e=>`'${String(e).replaceAll(`'`,`''`)}'`;function pr(e){for(let t of e.split(`
|
|
366
366
|
`)){if(/^\s*#/.test(t))continue;let e=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(e)return e.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,``)}}const mr=A(T.execFile),hr=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await D.access(n,O.F_OK),r=!0}catch{}if(!r)return e;let i=pr(await D.readFile(n,{encoding:`utf8`}));return i===void 0?e:(t=i,t=t.endsWith(`/`)?t:`${t}/`,t)}})(),gr=lr?async()=>`${await hr()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:dr;let _r;const vr=async()=>(_r??=(async()=>{try{let e=await gr();return await D.access(e,O.X_OK),!0}catch{return!1}})(),_r),yr=async()=>{let e=await gr(),{stdout:t}=await fr(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{powerShellPath:e});return t.trim()},br=async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await mr(`wslpath`,[`-aw`,e],{encoding:`utf8`});return t.trim()}catch{return e}};function xr(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}const Sr=A(E);async function Cr(){if(C.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await Sr(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}const wr=A(E);async function Tr(e,{humanReadableOutput:t=!0,signal:n}={}){if(C.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await wr(`osascript`,[`-e`,e,r],i);return a.trim()}async function Er(e){return Tr(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const Dr=A(E),Or={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},kr=new Map(Object.entries(Or));var Ar=class extends Error{};async function jr(e=Dr){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new Ar(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=r.lastIndexOf(`.`),a=r.lastIndexOf(`-`),o=i===-1?void 0:r.slice(0,i),s=a===-1?void 0:r.slice(0,a);return Or[r]??Or[o]??Or[s]??{name:r,id:r}}const Mr=A(E),Nr=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function Pr(){if(C.platform===`darwin`){let e=await Cr();return{name:await Er(e),id:e}}if(C.platform===`linux`){let{stdout:e}=await Mr(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:Nr(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(C.platform===`win32`)return jr();throw Error(`Only macOS, Linux, and Windows are supported`)}const Fr=!!(C.env.SSH_CONNECTION||C.env.SSH_CLIENT||C.env.SSH_TTY),Ir=Symbol(`fallbackAttempt`),Lr=import.meta.url?c.dirname(w(import.meta.url)):``,Rr=c.join(Lr,`xdg-open`),{platform:zr,arch:Br}=C,Vr=async(e,t)=>{if(e.length===0)return;let n=[];for(let r of e)try{return await t(r)}catch(e){n.push(e)}throw AggregateError(n,`Failed to open in all supported apps`)},Hr=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[Ir]===!0;if(delete e[Ir],Array.isArray(e.app))return Vr(e.app,t=>Hr({...e,app:t,[Ir]:!0}));let{name:n,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(n))return Vr(n,t=>Hr({...e,app:{name:t,arguments:r},[Ir]:!0}));if(n===`browser`||n===`browserPrivate`){let t={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`,"com.apple.safari":`safari`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a;if(lr){let e=await yr();a=kr.get(e)??{}}else a=await Pr();if(a.id in t){let o=t[a.id.toLowerCase()];if(n===`browserPrivate`){if(o===`safari`)throw Error(`Safari doesn't support opening in private mode via command line`);r.push(i[o])}return Hr({...e,app:{name:Kr[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let i,a=[],o={},s=!1;if(lr&&!sr()&&!Fr&&!n&&(s=await vr()),zr===`darwin`)i=`open`,e.wait&&a.push(`--wait-apps`),e.background&&a.push(`--background`),e.newInstance&&a.push(`--new`),n&&a.push(`-a`,n);else if(zr===`win32`||s){i=await gr(),a.push(...fr.argumentsPrefix),lr||(o.windowsVerbatimArguments=!0),lr&&e.target&&(e.target=await br(e.target));let t=[`$ProgressPreference = 'SilentlyContinue';`,`Start`];e.wait&&t.push(`-Wait`),n?(t.push(fr.escapeArgument(n)),e.target&&r.push(e.target)):e.target&&t.push(fr.escapeArgument(e.target)),r.length>0&&(r=r.map(e=>fr.escapeArgument(e)),t.push(`-ArgumentList`,r.join(`,`))),e.target=fr.encodeCommand(t.join(` `)),e.wait||(o.stdio=`ignore`)}else{if(n)i=n;else{let e=!Lr||Lr===`/`,t=!1;try{await D.access(Rr,O.X_OK),t=!0}catch{}i=C.versions.electron??(zr===`android`||e||!t)?`xdg-open`:Rr}r.length>0&&a.push(...r),e.wait||(o.stdio=`ignore`,o.detached=!0)}zr===`darwin`&&r.length>0&&a.push(`--args`,...r),e.target&&a.push(e.target);let c=T.spawn(i,a,o);return e.wait?new Promise((t,n)=>{c.once(`error`,n),c.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r!==0){n(Error(`Exited with code ${r}`));return}t(c)})}):t?new Promise((e,t)=>{c.once(`error`,t),c.once(`spawn`,()=>{c.once(`close`,n=>{if(c.off(`error`,t),n!==0){t(Error(`Exited with code ${n}`));return}c.unref(),e(c)})})}):(c.unref(),new Promise((e,t)=>{c.once(`error`,t),c.once(`spawn`,()=>{c.off(`error`,t),e(c)})}))},Ur=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return Hr({...t,target:e})};function Wr(e){if(typeof e==`string`||Array.isArray(e))return e;let{[Br]:t}=e;if(!t)throw Error(`${Br} is not supported`);return t}function Gr({[zr]:e},{wsl:t}={}){if(t&&lr)return Wr(t);if(!e)throw Error(`${zr} is not supported`);return Wr(e)}const Kr={browser:`browser`,browserPrivate:`browserPrivate`};xr(Kr,`chrome`,()=>Gr({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`,`chromium-browser`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),xr(Kr,`brave`,()=>Gr({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),xr(Kr,`firefox`,()=>Gr({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),xr(Kr,`edge`,()=>Gr({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),xr(Kr,`safari`,()=>Gr({darwin:`Safari`}));var qr=N(((e,t)=>{let n=typeof process<`u`&&process.env.TERM_PROGRAM===`Hyper`,r=typeof process<`u`&&process.platform===`win32`,i=typeof process<`u`&&process.platform===`linux`,a={ballotDisabled:`☒`,ballotOff:`☐`,ballotOn:`☑`,bullet:`•`,bulletWhite:`◦`,fullBlock:`█`,heart:`❤`,identicalTo:`≡`,line:`─`,mark:`※`,middot:`·`,minus:`-`,multiplication:`×`,obelus:`÷`,pencilDownRight:`✎`,pencilRight:`✏`,pencilUpRight:`✐`,percent:`%`,pilcrow2:`❡`,pilcrow:`¶`,plusMinus:`±`,question:`?`,section:`§`,starsOff:`☆`,starsOn:`★`,upDownArrow:`↕`},o=Object.assign({},a,{check:`√`,cross:`×`,ellipsisLarge:`...`,ellipsis:`...`,info:`i`,questionSmall:`?`,pointer:`>`,pointerSmall:`»`,radioOff:`( )`,radioOn:`(*)`,warning:`‼`}),s=Object.assign({},a,{ballotCross:`✘`,check:`✔`,cross:`✖`,ellipsisLarge:`⋯`,ellipsis:`…`,info:`ℹ`,questionFull:`?`,questionSmall:`﹖`,pointer:i?`▸`:`❯`,pointerSmall:i?`‣`:`›`,radioOff:`◯`,radioOn:`◉`,warning:`⚠`});t.exports=r&&!n?o:s,Reflect.defineProperty(t.exports,`common`,{enumerable:!1,value:a}),Reflect.defineProperty(t.exports,`windows`,{enumerable:!1,value:o}),Reflect.defineProperty(t.exports,`other`,{enumerable:!1,value:s})})),Jr=N(((e,t)=>{let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,i=()=>typeof process<`u`?process.env.FORCE_COLOR!==`0`:!1,a=()=>{let e={enabled:i(),visible:!0,styles:{},keys:{}},t=e=>{let t=e.open=`\u001b[${e.codes[0]}m`,n=e.close=`\u001b[${e.codes[1]}m`,r=e.regex=RegExp(`\\u001b\\[${e.codes[1]}m`,`g`);return e.wrap=(e,i)=>{e.includes(n)&&(e=e.replace(r,n+t));let a=t+e+n;return i?a.replace(/\r*\n/g,`${n}$&${t}`):a},e},a=(e,t,n)=>typeof e==`function`?e(t):e.wrap(t,n),o=(t,n)=>{if(t===``||t==null)return``;if(e.enabled===!1)return t;if(e.visible===!1)return``;let r=``+t,i=r.includes(`
|
|
367
367
|
`),o=n.length;for(o>0&&n.includes(`unstyle`)&&(n=[...new Set([`unstyle`,...n])].reverse());o-- >0;)r=a(e.styles[n[o]],r,i);return r},s=(n,r,i)=>{e.styles[n]=t({name:n,codes:r}),(e.keys[i]||(e.keys[i]=[])).push(n),Reflect.defineProperty(e,n,{configurable:!0,enumerable:!0,set(t){e.alias(n,t)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(n):[n],t}})};return s(`reset`,[0,0],`modifier`),s(`bold`,[1,22],`modifier`),s(`dim`,[2,22],`modifier`),s(`italic`,[3,23],`modifier`),s(`underline`,[4,24],`modifier`),s(`inverse`,[7,27],`modifier`),s(`hidden`,[8,28],`modifier`),s(`strikethrough`,[9,29],`modifier`),s(`black`,[30,39],`color`),s(`red`,[31,39],`color`),s(`green`,[32,39],`color`),s(`yellow`,[33,39],`color`),s(`blue`,[34,39],`color`),s(`magenta`,[35,39],`color`),s(`cyan`,[36,39],`color`),s(`white`,[37,39],`color`),s(`gray`,[90,39],`color`),s(`grey`,[90,39],`color`),s(`bgBlack`,[40,49],`bg`),s(`bgRed`,[41,49],`bg`),s(`bgGreen`,[42,49],`bg`),s(`bgYellow`,[43,49],`bg`),s(`bgBlue`,[44,49],`bg`),s(`bgMagenta`,[45,49],`bg`),s(`bgCyan`,[46,49],`bg`),s(`bgWhite`,[47,49],`bg`),s(`blackBright`,[90,39],`bright`),s(`redBright`,[91,39],`bright`),s(`greenBright`,[92,39],`bright`),s(`yellowBright`,[93,39],`bright`),s(`blueBright`,[94,39],`bright`),s(`magentaBright`,[95,39],`bright`),s(`cyanBright`,[96,39],`bright`),s(`whiteBright`,[97,39],`bright`),s(`bgBlackBright`,[100,49],`bgBright`),s(`bgRedBright`,[101,49],`bgBright`),s(`bgGreenBright`,[102,49],`bgBright`),s(`bgYellowBright`,[103,49],`bgBright`),s(`bgBlueBright`,[104,49],`bgBright`),s(`bgMagentaBright`,[105,49],`bgBright`),s(`bgCyanBright`,[106,49],`bgBright`),s(`bgWhiteBright`,[107,49],`bgBright`),e.ansiRegex=r,e.hasColor=e.hasAnsi=t=>(e.ansiRegex.lastIndex=0,typeof t==`string`&&t!==``&&e.ansiRegex.test(t)),e.alias=(t,n)=>{let r=typeof n==`string`?e[n]:n;if(typeof r!=`function`)throw TypeError(`Expected alias to be the name of an existing color (string) or a function`);r.stack||=(Reflect.defineProperty(r,`name`,{value:t}),e.styles[t]=r,[t]),Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,set(n){e.alias(t,n)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(r.stack):r.stack,t}})},e.theme=t=>{if(!n(t))throw TypeError(`Expected theme to be an object`);for(let n of Object.keys(t))e.alias(n,t[n]);return e},e.alias(`unstyle`,t=>typeof t==`string`&&t!==``?(e.ansiRegex.lastIndex=0,t.replace(e.ansiRegex,``)):``),e.alias(`noop`,e=>e),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=qr(),e.define=s,e};t.exports=a(),t.exports.create=a})),Yr=N(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Xr=N((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.symbols=e.isTTY=void 0;let n=t(P(`node:tty`)),r=t(P(`node:process`)),i=r.default.env.CI||r.default.env.WT_SESSION||r.default.env.ConEmuTask===`{cmd::Cmder}`||r.default.env.TERM_PROGRAM===`vscode`||r.default.env.TERM===`xterm-256color`||r.default.env.TERM===`alacritty`,a=n.default.isatty(1)&&r.default.env.TERM!==`dumb`&&!(`CI`in r.default.env);e.isTTY=a;let o=r.default.platform===`win32`?i:r.default.env.TERM!==`linux`;e.symbols={frames:a?o?[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]:[`-`,`\\`,`|`,`/`]:[`-`],tick:o?`✔`:`√`,cross:o?`✖`:`×`,warn:o?`⚠`:`!!`,info:o?`ℹ`:`i`}})),Zr=N((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.createSpinner=a;let n=t(Yr()),r=Xr();function i(e=``,t=80){return e.replace(/\u001b[^m]*?m/g,``).split(`
|
|
368
368
|
`).reduce((e,n)=>e+=Math.max(1,Math.ceil(n.length/t)),0)}function a(e=``,t={}){let a=0,o=t.interval||50,s=t.stream||process.stderr,c=t.frames&&t.frames.length?t.frames:r.symbols.frames,l=t.color||`yellow`,u=!1,d=0,f,p=(t={})=>typeof t==`string`?t:t.text||e,m=(e={})=>typeof e==`string`?!1:!!e.update,h=(e={})=>typeof e==`string`||!e.color?l:e.color,g=(e={},t)=>typeof e==`string`||!e.mark?t:e.mark,_=()=>{process.on(`SIGINT`,b),process.on(`SIGTERM`,b)},v=()=>{process.off(`SIGINT`,b),process.off(`SIGTERM`,b)},y={reset(){return a=0,d=0,u=!1,clearTimeout(f),f=void 0,y},clear(){y.write(`\x1B[1G`);for(let e=0;e<d;e++)e>0&&y.write(`\x1B[1A`),y.write(`\x1B[2K\x1B[1G`);return d=0,y},write(e,t=!1){return t&&r.isTTY&&y.clear(),s.write(e),y},render(){let t=`${n.default[l](c[a])} ${e}`;return r.isTTY?y.write(`\x1B[?25l`):t+=`
|
|
@@ -804,7 +804,37 @@ Documentation: https://github.com/git-truck/git-truck
|
|
|
804
804
|
FROM fileChanges_commits_renamed_cached
|
|
805
805
|
WHERE filePath = ? OR starts_with(filePath, ?) = true
|
|
806
806
|
) AS exists_in_range;`,async t=>(t.bindVarchar(1,e),t.bindVarchar(2,e+`/`),(await t.runAndReadAll()).getRowObjects()),`pathExistsInSelectedRange(tree)`):await this.query(`SELECT EXISTS(SELECT 1 FROM fileChanges_commits_renamed_cached) AS exists_in_range;
|
|
807
|
-
`);let r=n[0]?.exists_in_range;return r===!0||r===1||r===1n||r===`1`}getTimeStringFormat(e){let t=(e[1]-e[0])/(3600*24);return t<150?`day`:t<1e3?`week`:t<4e3?`month`:`year`}getTimeQueryFromTimeUnit(e){return{day:`%a %-d %B %Y`,week:`Week %V %Y`,month:`%B %Y`,year:`%Y`}[e]}async getCommitCountPerTime(e,t=this.getTimeStringFormat(e)){let
|
|
807
|
+
`);let r=n[0]?.exists_in_range;return r===!0||r===1||r===1n||r===`1`}getTimeStringFormat(e){let t=(e[1]-e[0])/(3600*24);return t<150?`day`:t<1e3?`week`:t<4e3?`month`:`year`}getTimeQueryFromTimeUnit(e){return{day:`%a %-d %B %Y`,week:`Week %V %Y`,month:`%B %Y`,year:`%Y`}[e]}mapCommitCountRowsToIntervals(e,t,n){let r=new Map;for(let{lookup:t,author:n,count:i}of e){r.has(t)||r.set(t,{count:0,contributors:{}});let e=r.get(t);e.count+=i,e.contributors[n]=(e.contributors[n]||0)+i}let i=[],a=rv(n,t[0],t[1]);for(let e of a){let t=r.get(e.lookup);i.push({date:e.label,count:t?.count??0,timestamp:e.timestamp,contributors:t?.contributors??{}})}return i.sort((e,t)=>e.timestamp-t.timestamp)}async getCommitCountPerTime(e,t=this.getTimeStringFormat(e),n={}){let r=this.getTimeQueryFromTimeUnit(t??this.getTimeStringFormat(e)),i=(n.includeCoauthors?await this.query(`WITH authored_commits AS (
|
|
808
|
+
SELECT c.hash, c.committerTime, COALESCE(cg.displayName, c.author) AS author
|
|
809
|
+
FROM commits c
|
|
810
|
+
LEFT JOIN (SELECT displayName, email, name FROM contributorGroups) cg
|
|
811
|
+
ON (c.author = cg.name AND c.authorEmail = cg.email)
|
|
812
|
+
WHERE c.committerTime BETWEEN ${e[0]} AND ${e[1]}
|
|
813
|
+
),
|
|
814
|
+
commit_people AS (
|
|
815
|
+
SELECT hash, committerTime, author
|
|
816
|
+
FROM authored_commits
|
|
817
|
+
UNION
|
|
818
|
+
SELECT c.hash, c.committerTime, co.name AS author
|
|
819
|
+
FROM authored_commits c
|
|
820
|
+
JOIN commitTrailers_unioned co ON c.hash = co.commitHash
|
|
821
|
+
WHERE co.trailerType = 'coauthor'
|
|
822
|
+
),
|
|
823
|
+
commit_shares AS (
|
|
824
|
+
SELECT date_trunc('${t}', to_timestamp(committerTime)) AS date,
|
|
825
|
+
author,
|
|
826
|
+
1.0 / COUNT(*) OVER (PARTITION BY hash) AS commitShare,
|
|
827
|
+
committerTime
|
|
828
|
+
FROM commit_people
|
|
829
|
+
)
|
|
830
|
+
SELECT strftime(date, '${r}') as timestring,
|
|
831
|
+
strftime(date, '%Y-%m-%d') AS bucket_lookup,
|
|
832
|
+
author,
|
|
833
|
+
SUM(commitShare) AS count,
|
|
834
|
+
MIN(committerTime) AS ct
|
|
835
|
+
FROM commit_shares
|
|
836
|
+
GROUP BY date, author
|
|
837
|
+
ORDER BY date ASC;`):await this.query(`SELECT strftime(date, '${r}') as timestring,
|
|
808
838
|
strftime(date, '%Y-%m-%d') AS bucket_lookup,
|
|
809
839
|
author,
|
|
810
840
|
count(*) AS count,
|
|
@@ -813,30 +843,71 @@ Documentation: https://github.com/git-truck/git-truck
|
|
|
813
843
|
COALESCE(cg.displayName, c.author) AS author,
|
|
814
844
|
c.committerTime FROM commits c
|
|
815
845
|
LEFT JOIN (SELECT displayName, email, name FROM contributorGroups) cg
|
|
816
|
-
ON (c.author = cg.name AND c.authorEmail = cg.email)
|
|
846
|
+
ON (c.author = cg.name AND c.authorEmail = cg.email)
|
|
847
|
+
WHERE c.committerTime BETWEEN ${e[0]} AND ${e[1]})
|
|
817
848
|
GROUP BY date, author
|
|
818
|
-
ORDER BY date ASC;`)).map(e=>({lookup:e.bucket_lookup,author:e.author,count:Number(e.count)}))
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
849
|
+
ORDER BY date ASC;`)).map(e=>({lookup:e.bucket_lookup,author:e.author,count:Number(e.count)}));return[this.mapCommitCountRowsToIntervals(i,e,t),t]}async getCommitCountPerTimeForClickedObject({timerange:e,timeUnit:t=this.getTimeStringFormat(e),objectPath:n,includeCoauthors:r=!1}){let i=this.getTimeQueryFromTimeUnit(t),a=r?`WITH object_commits AS (
|
|
850
|
+
SELECT DISTINCT commitHash, committerTime, author
|
|
851
|
+
FROM (
|
|
852
|
+
SELECT c.hash AS commitHash,
|
|
853
|
+
c.committerTime,
|
|
854
|
+
COALESCE(cg.displayName, c.author) AS author,
|
|
855
|
+
COALESCE(r.toName, f.filePath) AS resolvedPath
|
|
856
|
+
FROM commits c
|
|
857
|
+
JOIN fileChanges f ON c.hash = f.commitHash
|
|
858
|
+
LEFT JOIN (SELECT displayName, email, name FROM contributorGroups) cg
|
|
859
|
+
ON (c.author = cg.name AND c.authorEmail = cg.email)
|
|
860
|
+
LEFT JOIN temporaryRenames r ON f.filePath = r.fromName AND (
|
|
861
|
+
c.committerTime BETWEEN r.timestamp AND r.timestampEnd
|
|
862
|
+
)
|
|
832
863
|
)
|
|
864
|
+
WHERE resolvedPath = ? OR resolvedPath LIKE ?
|
|
865
|
+
),
|
|
866
|
+
commit_people AS (
|
|
867
|
+
SELECT commitHash, committerTime, author
|
|
868
|
+
FROM object_commits
|
|
869
|
+
UNION
|
|
870
|
+
SELECT oc.commitHash, oc.committerTime, co.name AS author
|
|
871
|
+
FROM object_commits oc
|
|
872
|
+
JOIN commitTrailers_unioned co ON oc.commitHash = co.commitHash
|
|
873
|
+
WHERE co.trailerType = 'coauthor'
|
|
874
|
+
),
|
|
875
|
+
commit_shares AS (
|
|
876
|
+
SELECT date_trunc(?, to_timestamp(committerTime)) AS date,
|
|
877
|
+
author,
|
|
878
|
+
1.0 / COUNT(*) OVER (PARTITION BY commitHash) AS commitShare,
|
|
879
|
+
committerTime
|
|
880
|
+
FROM commit_people
|
|
833
881
|
)
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
882
|
+
SELECT strftime(date, ?) as timestring,
|
|
883
|
+
strftime(date, '%Y-%m-%d') AS bucket_lookup,
|
|
884
|
+
author,
|
|
885
|
+
SUM(commitShare) AS count,
|
|
886
|
+
MIN(committerTime) AS ct
|
|
887
|
+
FROM commit_shares
|
|
888
|
+
GROUP BY date, author
|
|
889
|
+
ORDER BY date ASC;`:`SELECT strftime(date, ?) as timestring,
|
|
890
|
+
strftime(date, '%Y-%m-%d') AS bucket_lookup,
|
|
891
|
+
author,
|
|
892
|
+
count(DISTINCT commitHash) AS count,
|
|
893
|
+
MIN(committerTime) AS ct FROM (
|
|
894
|
+
SELECT date_trunc(?, to_timestamp(c.committerTime)) AS date,
|
|
895
|
+
c.committerTime, c.hash as commitHash, COALESCE(cg.displayName, c.author) AS author,
|
|
896
|
+
COALESCE(r.toName, f.filePath) as resolvedPath
|
|
897
|
+
FROM commits c
|
|
898
|
+
JOIN fileChanges f ON c.hash = f.commitHash
|
|
899
|
+
LEFT JOIN (SELECT displayName, email, name FROM contributorGroups) cg
|
|
900
|
+
ON (c.author = cg.name AND c.authorEmail = cg.email)
|
|
901
|
+
LEFT JOIN temporaryRenames r ON f.filePath = r.fromName AND (
|
|
902
|
+
c.committerTime BETWEEN r.timestamp AND r.timestampEnd
|
|
903
|
+
)
|
|
904
|
+
)
|
|
905
|
+
WHERE resolvedPath = ? OR resolvedPath LIKE ?
|
|
906
|
+
GROUP BY date, author
|
|
907
|
+
ORDER BY date ASC;`,o=(await this.usingPreparedStatement(a,async e=>(r?(e.bindVarchar(1,n),e.bindVarchar(2,`${n}/%`),e.bindVarchar(3,t),e.bindVarchar(4,i)):(e.bindVarchar(1,i),e.bindVarchar(2,t),e.bindVarchar(3,n),e.bindVarchar(4,`${n}/%`)),(await e.runAndReadAll()).getRowObjects()),`getCommitCountPerTimeForClickedObject`)).map(e=>({lookup:e.bucket_lookup,author:e.author,count:Number(e.count)}));return this.mapCommitCountRowsToIntervals(o,e,t)}async updateColorSeed(e){await this.run(`DELETE FROM metadata
|
|
837
908
|
WHERE field = 'colorSeed';
|
|
838
909
|
INSERT INTO metadata (field, intValue, stringValue)
|
|
839
|
-
VALUES ('colorSeed', null, '${e}');`),I.debug(`inserted seed`,e)}async getGitTruckVersion(){let e=await this.query(`SELECT stringValue from metadata WHERE field = 'version';`);return e.length===0?null:e[0].stringValue}async getColorSeed(){let e=await this.query(`SELECT stringValue FROM metadata WHERE field = 'colorSeed';`);return e.length<1?null:(I.debug(`retrieved seed`,e[0].stringValue),e[0].stringValue)}async getLastRunInfo(){let e=await this.query(`SELECT intValue as time, stringValue as hash FROM metadata WHERE field = 'finished' ORDER BY intValue DESC LIMIT 1;`);return e[0]?{time:Number(e[0].time),hash:e[0].hash}:{time:0,hash:``}}async addCommits(e){await this.usingTableAppender(`commits`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);t.appendVarchar(n),t.appendVarchar(r.author.name),t.appendVarchar(r.author.email),t.appendUInteger(r.committerTime),t.appendUInteger(r.authorTime),t.endRow()}}),await this.usingTableAppender(`commitTrailers`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);for(let e of r.coauthors)t.appendVarchar(n),t.appendVarchar(e.name),t.appendVarchar(e.email),t.appendVarchar(`coauthor`),t.endRow()}}),await this.usingTableAppender(`fileChanges`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);for(let e of r.fileChanges)t.appendVarchar(r.hash),t.appendUInteger(e.insertions),t.appendUInteger(e.deletions),t.appendVarchar(e.path),t.endRow()}})}};function cv(e){let t=e.matchAll(/Co-authored-by: (?<name>.*) <(?<email>.*)>/gim),n=t.next().value,r=[];for(;n!==void 0;)r.push({name:n.groups.name.trimEnd(),email:n.groups.email}),n=t.next().value;return r}var lv=class e{useCache=!0;catFileCache=new Map;repositoryPath;branch;constructor({repositoryPath:e,branch:t}){this.repositoryPath=e,this.branch=t}static hasGitDirectory(e){return f(u(e,`.git`))}static async isValidGitRepo(t){let n=this.hasGitDirectory(t);if(!n)return!1;let[,r]=await $(e.getCommitHashOfBranchHead({repositoryPath:t}));return n&&!r}static async isValidRevision({revision:t,repositoryPath:n}){let r=l(n,`.git`),[,i]=await $(e._revParse(r,t));return!i}static async getCommitHashOfBranchHead({repositoryPath:t,branch:n}){if(!n){let[r,i]=await $(e._getRepositoryHead(t));if(i)throw i;n=r}let r=l(t,`.git`);if(!f(r))throw Error(`No git folder exists at `+r);let i=await e._revParse(r,n);return I.debug(`${n} -> [commit] ${i}`),i}static getCachePath(e,t){return u(y.tmpdir(),`git-truck`,e,`${t}.json`)}async getRepositoryHead(){return await e._getRepositoryHead(this.repositoryPath)}async gitLogSpecificCommits(e){let t=[`log`,`--no-walk`,`--numstat`,`--format="author <|%aN|> email <|%aE|> date <|%ct %at|> message <|%s|> body <|%b|> hash <|%H|>"`,...e];return(await Xv(this.repositoryPath,`git`,t)).trim()}static async _getRepositoryHead(e){let[t,n]=await $(p.readFile(l(e,`.git`,`HEAD`),`utf-8`));if(n)throw n;return t.trim().trim().replace(`ref: refs/heads/`,``)}async lsTree(t){return await e._lsTree(this.repositoryPath,t)}static async _lsTree(e,t){return(await Xv(e,`git`,[`ls-tree`,`-rlt`,t])).trim()}async revParse(t){return await e._revParse(this.repositoryPath,t)}static async _revParse(e,t){return(await Xv(e,`git`,[`rev-list`,`-n`,`1`,t])).trim()}static async getRepoMetadata(t){let n=iy(t),r=ry(t),i=await e.getLastChanged(t);if(!i)return{status:`Error`,errorMessage:`Not a valid git repository`,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:iy(r),lastChanged:0};let a=e.parseRefs(await e._getRefs(t)),[o,s]=await $(e.getCommitHashOfBranchHead({repositoryPath:t}));return s?{status:`Error`,errorMessage:s.message,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:iy(r),lastChanged:i}:{status:`Success`,isAnalyzed:!1,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:iy(r),currentHead:o,refs:a,lastChanged:i}}static async getLastChanged(t){let n=await e.readFileSafe(l(t,`.git`,`HEAD`));if(!n)return null;let r=n.trim();if(r.startsWith(`ref:`)){let n=l(t,`.git`,r.slice(5).trim()),i=await e.readFileSafe(n);if(i){let n=e.readCommitTimestamp(t,i.trim());if(n!==null)return n}}else{let n=e.readCommitTimestamp(t,r);if(n!==null)return n}let[i]=await $(Xv(t,`git`,[`log`,`-1`,`--pretty=%at`]));if(!i)return null;let a=parseInt(i.trim());return isNaN(a)?null:a}static async readFileSafe(e){let[t]=await $(k(e,`utf-8`));return t}static readCommitTimestamp(e,t){try{let n=l(e,`.git`,`objects`,t.slice(0,2),t.slice(2));if(!f(n))return null;let r=a(m(n)).toString(`utf-8`).match(/^author .*? (\d+) [+-]\d{4}$/m);return r?Number(r[1]):null}catch{return null}}static parseRefs(e){let t={Branches:{},Tags:{}},n=e.matchAll(/^(?<hash>.*) refs\/(?<ref_type>.*?)\/(?<path>.*)$/gm),r=n.next();for(;r.value;){let e=r.value.groups;if(!e)break;r=n.next();let i=e.hash,a=e.ref_type,o=e.path;switch(a){case`heads`:t.Branches[o]=i;break;case`remotes`:break;case`tags`:t.Tags[o]=i;break;default:break}}return t.Branches=Object.fromEntries(Object.entries(t.Branches).sort(([e],[t])=>ev(e,t))),t.Tags=Object.fromEntries(Object.entries(t.Tags).sort(([e],[t])=>tv(e,t)*-1)),t}async gitLog(e,t){let n=[`log`,`--skip=${e}`,`--max-count=${t}`,this.branch,`--summary`,`--numstat`,`--format="author <|%aN|> email <|%aE|> date <|%ct %at|> message <|%s|> body <|%b|> hash <|%H|>"`];return(await Xv(this.repositoryPath,`git`,n)).trim()}async gitLogSimple(e,t,n,r){let i=[`log`,`--skip=${e}`,`--max-count=${t}`,this.branch,`--summary`,`--numstat`,`--format="<|%aN|><|%aE|><|%ct %at|><|%(trailers)|><|%H|>"`];return(await Xv(this.repositoryPath,`git`,i,n,r)).trim()}setUseCache(e){this.useCache=e}async commitCountSinceCommit(e,t){let n=Number(await Xv(this.repositoryPath,`git`,[`rev-list`,`--count`,`${e}..${t}`]));return isNaN(n)?0:n}async getRefs(){return await e._getRefs(this.repositoryPath)}static async _getRefs(e){return await Xv(e,`git`,[`show-ref`])}async catFile(e){return await Xv(this.repositoryPath,`git`,[`cat-file`,`-p`,e])}async catFileCached(e){if(this.useCache){let t=this.catFileCache.get(e);if(t)return t}let t=await this.catFile(e);return this.catFileCache.set(e,t),t}async getCommitCount(){let e=await Xv(this.repositoryPath,`git`,[`rev-list`,`--count`,this.branch]);return Number(e)}async getDefaultGitSettingValue(e){return await Xv(this.repositoryPath,`git`,[`config`,e])}async resetGitSetting(e,t){t?(await Xv(this.repositoryPath,`git`,[`config`,e,t]),I.debug(`Reset ${e} to ${t}`)):(await Xv(this.repositoryPath,`git`,[`config`,`--unset`,e]),I.debug(`Unset ${e}`))}async setGitSetting(e,t){await Xv(this.repositoryPath,`git`,[`config`,e,t]),I.debug(`Set ${e} to ${t}`)}};const uv=/"author\s+<\|(?<author>.*?)\|>\s+email\s+<\|(?<authorEmail>.*?)\|>\s+date\s+<\|(?<dateCommitter>\d+)\s(?<dateAuthor>\d+)\|>\s+message\s+<\|(?<message>[\s\S]*?)\|>\s+body\s+<\|(?<body>[\s\S]*?)\|>\s+hash\s+<\|(?<hash>.+?)\|>"\s*(?<contributions>(?:(?:\d+|-)\s+(?:\d+|-)\s+.+\s?)*)(?<modes>(?:\s.+\s*)*)/gmu,dv=/"<\|(?<author>.*?)\|><\|(?<authorEmail>.*?)\|><\|(?<dateCommitter>\d+)\s(?<dateAuthor>\d+)\|>\s*<\|(?<trailers>[\s\S]*?)\|><\|(?<hash>.+?)\|>"\s*(?<contributions>(?:(?:\d+|-)\s+(?:\d+|-)\s+.+\s?)*)(?<modes>(?:\s.+\s*)*)/gmu,fv=/(?<insertions>\d+|-)\s+(?<deletions>\d+|-)\s+(?<file>.+)/gm,pv=/^\S+? (?<type>\S+) (?<hash>\S+)\s+(?<size>\S+)\s+(?<path>.+)/gm,mv=/\s(?<mode>\w+)\s\w+\s\d+\s(?<file>.+)/gmu,hv=Error(`request for lock canceled`);var gv=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},_v=class{constructor(e,t=hv){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=yv(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return gv(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),vv(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function vv(e,t){let n=yv(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function yv(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var bv=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},xv=class{constructor(e){this._semaphore=new _v(1,e)}acquire(){return bv(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}},Sv=class{mutex;constructor(){this.mutex=new xv}isLocked(){return this.mutex.isLocked()}async withDisposable(e){let t=await this.mutex.acquire();try{await e?.()}catch(e){throw t(),e}return{[Symbol.dispose]:()=>{t()}}}};function Cv(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}var wv=class e{static separator=`---`;static metadataDB;static mutex=new Sv;static getPath(){return i(t.tmpdir(),`git-truck-cache`,`metadata.json`)}static getInstance(){return this.metadataDB||=new e,this.metadataDB}static async resetInstance(){try{var t=Cv();t.u(await e.mutex.withDisposable()),await g.rm(this.getPath(),{recursive:!0,force:!0}),e.metadataDB=new e}catch(e){t.e=e}finally{t.d()}}async readMetadata(){try{var t=Cv();return t.u(await e.mutex.withDisposable()),await this.readMetadataUnlocked()}catch(e){t.e=e}finally{t.d()}}async readMetadataUnlocked(){try{return JSON.parse(await g.readFile(e.getPath(),`utf8`))}catch{return{completions:{},authorcolors:{}}}}async setMetadataUnlocked(t){let n=JSON.stringify(t);await g.mkdir(r(e.getPath()),{recursive:!0}),await g.writeFile(e.getPath(),n,`utf8`)}async setCompletion({repositoryPath:t,branch:n},r){try{var i=Cv();i.u(await e.mutex.withDisposable()),await this.setCompletionUnlocked({repositoryPath:t,branch:n},r)}catch(e){i.e=e}finally{i.d()}}async setCompletionUnlocked({repositoryPath:t,branch:n},r){let i=await this.readMetadataUnlocked();i.completions[e.getCompletionKey({repositoryPath:t,branch:n})]={hash:r,time:Math.floor(Date.now()/1e3)},await this.setMetadataUnlocked(i)}async addContributorColor(t,n){try{var r=Cv();r.u(await e.mutex.withDisposable()),await this.addContributorColorUnlocked(t,n)}catch(e){r.e=e}finally{r.d()}}async addContributorColorUnlocked(e,t){let n=await this.readMetadataUnlocked();t===``?delete n.authorcolors[e]:n.authorcolors[e]=t,await this.setMetadataUnlocked(n)}async getContributorColors(){return(await this.readMetadata()).authorcolors}async getLastRun({repositoryPath:t,branch:n}){return(await this.readMetadata()).completions[e.getCompletionKey({repositoryPath:t,branch:n})]}async getCompletedRepos(){let t=[],n=await this.readMetadata();for(let[r,i]of Object.entries(n.completions)){let[n,a]=r.split(e.separator);t.push({repositoryPath:n,branch:a,time:i.time,hash:i.hash})}return t}static getCompletionKey({repositoryPath:t,branch:n}){return`${t}${e.separator}${n}`}},Tv=N(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\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}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,w=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,T=e=>e.split(s).filter(Boolean);var E=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_`+y;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_`+b;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ee=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new E(e,t,i,n,r,s)};var D=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),w(e.pattern)){let t=ee(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?T(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let O=(e,t)=>{throw new t(e)},k=(e,t,n)=>C(e)?e?k.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),te=e=>c.test(e);k.isNotRelative=te,k.convert=e=>e;var A=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new D(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&k.convert(e);return k(i,e,this._strictPathCheck?O:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let ne=e=>new A(e),re=e=>k(e&&k.convert(e),e,m),j=()=>{k.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;k.isNotRelative=t=>e.test(t)||te(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=ne,ne.default=ne,t.exports.isPathValid=re,f(t.exports,Symbol.for(`setupWindows`),j)})),Ev=N((e=>{
|
|
910
|
+
VALUES ('colorSeed', null, '${e}');`),I.debug(`inserted seed`,e)}async getGitTruckVersion(){let e=await this.query(`SELECT stringValue from metadata WHERE field = 'version';`);return e.length===0?null:e[0].stringValue}async getColorSeed(){let e=await this.query(`SELECT stringValue FROM metadata WHERE field = 'colorSeed';`);return e.length<1?null:(I.debug(`retrieved seed`,e[0].stringValue),e[0].stringValue)}async getLastRunInfo(){let e=await this.query(`SELECT intValue as time, stringValue as hash FROM metadata WHERE field = 'finished' ORDER BY intValue DESC LIMIT 1;`);return e[0]?{time:Number(e[0].time),hash:e[0].hash}:{time:0,hash:``}}async addCommits(e){await this.usingTableAppender(`commits`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);t.appendVarchar(n),t.appendVarchar(r.author.name),t.appendVarchar(r.author.email),t.appendUInteger(r.committerTime),t.appendUInteger(r.authorTime),t.endRow()}}),await this.usingTableAppender(`commitTrailers`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);for(let e of r.coauthors)t.appendVarchar(n),t.appendVarchar(e.name),t.appendVarchar(e.email),t.appendVarchar(`coauthor`),t.endRow()}}),await this.usingTableAppender(`fileChanges`,async t=>{for(let[n,r]of e){if(!r)throw Error(`Commit with hash ${n} is undefined`);for(let e of r.fileChanges)t.appendVarchar(r.hash),t.appendUInteger(e.insertions),t.appendUInteger(e.deletions),t.appendVarchar(e.path),t.endRow()}})}};function cv(e){let t=e.matchAll(/Co-authored-by: (?<name>.*) <(?<email>.*)>/gim),n=t.next().value,r=[];for(;n!==void 0;)r.push({name:n.groups.name.trimEnd(),email:n.groups.email}),n=t.next().value;return r}var lv=class e{useCache=!0;catFileCache=new Map;repositoryPath;branch;constructor({repositoryPath:e,branch:t}){this.repositoryPath=e,this.branch=t}static hasGitDirectory(e){return f(u(e,`.git`))}static async isValidGitRepo(t){let n=this.hasGitDirectory(t);if(!n)return!1;let[,r]=await $(e.getCommitHashOfBranchHead({repositoryPath:t}));return n&&!r}static async isValidRevision({revision:t,repositoryPath:n}){let r=l(n,`.git`),[,i]=await $(e._revParse(r,t));return!i}static async getCommitHashOfBranchHead({repositoryPath:t,branch:n}){if(!n){let[r,i]=await $(e._getRepositoryHead(t));if(i)throw i;n=r}let r=l(t,`.git`);if(!f(r))throw Error(`No git folder exists at `+r);let i=await e._revParse(r,n);return I.debug(`${n} -> [commit] ${i}`),i}static getCachePath(e,t){return u(y.tmpdir(),`git-truck`,e,`${t}.json`)}async getRepositoryHead(){return await e._getRepositoryHead(this.repositoryPath)}async gitLogSpecificCommits(e){let t=[`log`,`--no-walk`,`--numstat`,`--format="author <|%aN|> email <|%aE|> date <|%ct %at|> message <|%s|> body <|%b|> hash <|%H|>"`,...e];return(await Zv(this.repositoryPath,`git`,t)).trim()}static async _getRepositoryHead(e){let[t,n]=await $(p.readFile(l(e,`.git`,`HEAD`),`utf-8`));if(n)throw n;return t.trim().trim().replace(`ref: refs/heads/`,``)}async lsTree(t){return await e._lsTree(this.repositoryPath,t)}static async _lsTree(e,t){return(await Zv(e,`git`,[`ls-tree`,`-rlt`,t])).trim()}async revParse(t){return await e._revParse(this.repositoryPath,t)}static async _revParse(e,t){return(await Zv(e,`git`,[`rev-list`,`-n`,`1`,t])).trim()}static async getRepoMetadata(t){let n=ay(t),r=iy(t),i=await e.getLastChanged(t);if(!i)return{status:`Error`,errorMessage:`Not a valid git repository`,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:ay(r),lastChanged:0};let a=e.parseRefs(await e._getRefs(t)),[o,s]=await $(e.getCommitHashOfBranchHead({repositoryPath:t}));return s?{status:`Error`,errorMessage:s.message,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:ay(r),lastChanged:i}:{status:`Success`,isAnalyzed:!1,repositoryName:n,repositoryPath:t,parentDirPath:r,parentDirName:ay(r),currentHead:o,refs:a,lastChanged:i}}static async getLastChanged(t){let n=await e.readFileSafe(l(t,`.git`,`HEAD`));if(!n)return null;let r=n.trim();if(r.startsWith(`ref:`)){let n=l(t,`.git`,r.slice(5).trim()),i=await e.readFileSafe(n);if(i){let n=e.readCommitTimestamp(t,i.trim());if(n!==null)return n}}else{let n=e.readCommitTimestamp(t,r);if(n!==null)return n}let[i]=await $(Zv(t,`git`,[`log`,`-1`,`--pretty=%at`]));if(!i)return null;let a=parseInt(i.trim());return isNaN(a)?null:a}static async readFileSafe(e){let[t]=await $(k(e,`utf-8`));return t}static readCommitTimestamp(e,t){try{let n=l(e,`.git`,`objects`,t.slice(0,2),t.slice(2));if(!f(n))return null;let r=a(m(n)).toString(`utf-8`).match(/^author .*? (\d+) [+-]\d{4}$/m);return r?Number(r[1]):null}catch{return null}}static parseRefs(e){let t={Branches:{},Tags:{}},n=e.matchAll(/^(?<hash>.*) refs\/(?<ref_type>.*?)\/(?<path>.*)$/gm),r=n.next();for(;r.value;){let e=r.value.groups;if(!e)break;r=n.next();let i=e.hash,a=e.ref_type,o=e.path;switch(a){case`heads`:t.Branches[o]=i;break;case`remotes`:break;case`tags`:t.Tags[o]=i;break;default:break}}return t.Branches=Object.fromEntries(Object.entries(t.Branches).sort(([e],[t])=>ev(e,t))),t.Tags=Object.fromEntries(Object.entries(t.Tags).sort(([e],[t])=>tv(e,t)*-1)),t}async gitLog(e,t){let n=[`log`,`--skip=${e}`,`--max-count=${t}`,this.branch,`--summary`,`--numstat`,`--format="author <|%aN|> email <|%aE|> date <|%ct %at|> message <|%s|> body <|%b|> hash <|%H|>"`];return(await Zv(this.repositoryPath,`git`,n)).trim()}async gitLogSimple(e,t,n,r){let i=[`log`,`--skip=${e}`,`--max-count=${t}`,this.branch,`--summary`,`--numstat`,`--format="<|%aN|><|%aE|><|%ct %at|><|%(trailers)|><|%H|>"`];return(await Zv(this.repositoryPath,`git`,i,n,r)).trim()}setUseCache(e){this.useCache=e}async commitCountSinceCommit(e,t){let n=Number(await Zv(this.repositoryPath,`git`,[`rev-list`,`--count`,`${e}..${t}`]));return isNaN(n)?0:n}async getRefs(){return await e._getRefs(this.repositoryPath)}static async _getRefs(e){return await Zv(e,`git`,[`show-ref`])}async catFile(e){return await Zv(this.repositoryPath,`git`,[`cat-file`,`-p`,e])}async catFileCached(e){if(this.useCache){let t=this.catFileCache.get(e);if(t)return t}let t=await this.catFile(e);return this.catFileCache.set(e,t),t}async getCommitCount(){let e=await Zv(this.repositoryPath,`git`,[`rev-list`,`--count`,this.branch]);return Number(e)}async getDefaultGitSettingValue(e){return await Zv(this.repositoryPath,`git`,[`config`,e])}async resetGitSetting(e,t){t?(await Zv(this.repositoryPath,`git`,[`config`,e,t]),I.debug(`Reset ${e} to ${t}`)):(await Zv(this.repositoryPath,`git`,[`config`,`--unset`,e]),I.debug(`Unset ${e}`))}async setGitSetting(e,t){await Zv(this.repositoryPath,`git`,[`config`,e,t]),I.debug(`Set ${e} to ${t}`)}};const uv=/"author\s+<\|(?<author>.*?)\|>\s+email\s+<\|(?<authorEmail>.*?)\|>\s+date\s+<\|(?<dateCommitter>\d+)\s(?<dateAuthor>\d+)\|>\s+message\s+<\|(?<message>[\s\S]*?)\|>\s+body\s+<\|(?<body>[\s\S]*?)\|>\s+hash\s+<\|(?<hash>.+?)\|>"\s*(?<contributions>(?:(?:\d+|-)\s+(?:\d+|-)\s+.+\s?)*)(?<modes>(?:\s.+\s*)*)/gmu,dv=/"<\|(?<author>.*?)\|><\|(?<authorEmail>.*?)\|><\|(?<dateCommitter>\d+)\s(?<dateAuthor>\d+)\|>\s*<\|(?<trailers>[\s\S]*?)\|><\|(?<hash>.+?)\|>"\s*(?<contributions>(?:(?:\d+|-)\s+(?:\d+|-)\s+.+\s?)*)(?<modes>(?:\s.+\s*)*)/gmu,fv=/(?<insertions>\d+|-)\s+(?<deletions>\d+|-)\s+(?<file>.+)/gm,pv=/^\S+? (?<type>\S+) (?<hash>\S+)\s+(?<size>\S+)\s+(?<path>.+)/gm,mv=/\s(?<mode>\w+)\s\w+\s\d+\s(?<file>.+)/gmu,hv=Error(`request for lock canceled`);var gv=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},_v=class{constructor(e,t=hv){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=yv(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return gv(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),vv(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function vv(e,t){let n=yv(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function yv(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var bv=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},xv=class{constructor(e){this._semaphore=new _v(1,e)}acquire(){return bv(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}},Sv=class{mutex;constructor(){this.mutex=new xv}isLocked(){return this.mutex.isLocked()}async withDisposable(e){let t=await this.mutex.acquire();try{await e?.()}catch(e){throw t(),e}return{[Symbol.dispose]:()=>{t()}}}};function Cv(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}var wv=class e{static separator=`---`;static metadataDB;static mutex=new Sv;static getPath(){return i(t.tmpdir(),`git-truck-cache`,`metadata.json`)}static getInstance(){return this.metadataDB||=new e,this.metadataDB}static async resetInstance(){try{var t=Cv();t.u(await e.mutex.withDisposable()),await g.rm(this.getPath(),{recursive:!0,force:!0}),e.metadataDB=new e}catch(e){t.e=e}finally{t.d()}}async readMetadata(){try{var t=Cv();return t.u(await e.mutex.withDisposable()),await this.readMetadataUnlocked()}catch(e){t.e=e}finally{t.d()}}async readMetadataUnlocked(){try{return JSON.parse(await g.readFile(e.getPath(),`utf8`))}catch{return{completions:{},authorcolors:{}}}}async setMetadataUnlocked(t){let n=JSON.stringify(t);await g.mkdir(r(e.getPath()),{recursive:!0}),await g.writeFile(e.getPath(),n,`utf8`)}async setCompletion({repositoryPath:t,branch:n},r){try{var i=Cv();i.u(await e.mutex.withDisposable()),await this.setCompletionUnlocked({repositoryPath:t,branch:n},r)}catch(e){i.e=e}finally{i.d()}}async setCompletionUnlocked({repositoryPath:t,branch:n},r){let i=await this.readMetadataUnlocked();i.completions[e.getCompletionKey({repositoryPath:t,branch:n})]={hash:r,time:Math.floor(Date.now()/1e3)},await this.setMetadataUnlocked(i)}async addContributorColor(t,n){try{var r=Cv();r.u(await e.mutex.withDisposable()),await this.addContributorColorUnlocked(t,n)}catch(e){r.e=e}finally{r.d()}}async addContributorColorUnlocked(e,t){let n=await this.readMetadataUnlocked();t===``?delete n.authorcolors[e]:n.authorcolors[e]=t,await this.setMetadataUnlocked(n)}async getContributorColors(){return(await this.readMetadata()).authorcolors}async getLastRun({repositoryPath:t,branch:n}){return(await this.readMetadata()).completions[e.getCompletionKey({repositoryPath:t,branch:n})]}async getCompletedRepos(){let t=[],n=await this.readMetadata();for(let[r,i]of Object.entries(n.completions)){let[n,a]=r.split(e.separator);t.push({repositoryPath:n,branch:a,time:i.time,hash:i.hash})}return t}static getCompletionKey({repositoryPath:t,branch:n}){return`${t}${e.separator}${n}`}},Tv=N(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\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}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,w=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,T=e=>e.split(s).filter(Boolean);var E=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_`+y;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_`+b;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ee=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new E(e,t,i,n,r,s)};var D=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),w(e.pattern)){let t=ee(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?T(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let O=(e,t)=>{throw new t(e)},k=(e,t,n)=>C(e)?e?k.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),te=e=>c.test(e);k.isNotRelative=te,k.convert=e=>e;var A=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new D(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&k.convert(e);return k(i,e,this._strictPathCheck?O:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let ne=e=>new A(e),re=e=>k(e&&k.convert(e),e,m),j=()=>{k.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;k.isNotRelative=t=>e.test(t)||te(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=ne,ne.default=ne,t.exports.isPathValid=re,f(t.exports,Symbol.for(`setupWindows`),j)})),Ev=N((e=>{
|
|
840
911
|
/**
|
|
841
912
|
* @license React
|
|
842
913
|
* react.production.js
|
|
@@ -846,7 +917,7 @@ Documentation: https://github.com/git-truck/git-truck
|
|
|
846
917
|
* This source code is licensed under the MIT license found in the
|
|
847
918
|
* LICENSE file in the root directory of this source tree.
|
|
848
919
|
*/
|
|
849
|
-
var t={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},n=Object.assign,r={};function i(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}i.prototype.isReactComponent={},i.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function a(){}a.prototype=i.prototype;function o(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}var s=o.prototype=new a;s.constructor=o,n(s,i.prototype),s.isPureReactComponent=!0,Array.isArray})),Dv=N(((e,t)=>{t.exports=Ev()})),Ov=ue(Tv(),1);Dv();function kv(e){return e===null||Array.isArray(e)&&e.length===0}function Av(e,t,n){if(typeof e==`string`)n.set(t,e);else{n.delete(t);for(let r of e)n.append(t,r);n.has(t)||n.set(t,``)}return n}function jv(e,{urlKeys:t={}}={}){function n(r,{strict:i=!1}={}){if(r instanceof Promise)return r.then(e=>n(e,{strict:i}));let a=Mv(r),o={};for(let[n,r]of Object.entries(e)){let e=t[n]??n,s=r.type===`multi`?a.getAll(e):a.get(e);if(kv(s)){o[n]=r.defaultValue??null;continue}let c;try{c=r.parse(s)}catch(e){if(i)throw Error(`[nuqs] Error while parsing query \`${s}\` for key \`${n}\`: ${e}`);c=null}if(i&&s&&c===null)throw Error(`[nuqs] Failed to parse query \`${s}\` for key \`${n}\` (got null)`);o[n]=c??r.defaultValue??null}return o}return n}function Mv(e){try{if(e instanceof Request)return e.url?new URL(e.url).searchParams:new URLSearchParams;if(e instanceof URL)return e.searchParams;if(e instanceof URLSearchParams)return e;if(typeof e==`object`){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r);return t}if(typeof e==`string`)return URL.hasOwnProperty(`canParse`)&&URL.canParse(e)?new URL(e).searchParams:new URLSearchParams(e)}catch{}return new URLSearchParams}function Nv(){if(typeof window>`u`||!window.GestureEvent)return 50;try{let e=navigator.userAgent?.match(/version\/([\d\.]+) safari/i);return parseFloat(e[1])>=17?120:320}catch{return 320}}Nv();const Pv=Iv();function Fv(e,...t){Pv&&console.warn(e,...t)}function Iv(){if(typeof window>`u`)return(process.env.DEBUG||``).includes(`nuqs`);try{let e=`nuqs-localStorage-test`;if(typeof localStorage>`u`)return!1;localStorage.setItem(e,e);let t=localStorage.getItem(e)===e;return localStorage.removeItem(e),t&&(localStorage.getItem(`debug`)||``).includes(`nuqs`)}catch{return!1}}function Lv(e,t,n){try{return e(t)}catch(e){return Fv("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":``),t,e,n),null}}function Rv(e){function t(t){if(t===void 0)return null;let n=``;if(Array.isArray(t)){if(t[0]===void 0)return null;n=t[0]}return typeof t==`string`&&(n=t),Lv(e.parse,n)}return{type:`single`,eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide(n){return t(n)??e}}},withOptions(e){return{...this,...e}}}}const zv=Rv({parse:e=>e,serialize:String}),Bv=Rv({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>``+Math.round(e)});Rv({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>``+Math.round(e+1)}),Rv({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(t.length&1?`0`:``)+t}}),Rv({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String}),Rv({parse:e=>e.toLowerCase()===`true`,serialize:String});function Vv(e,t){return e.valueOf()===t.valueOf()}Rv({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>``+e.valueOf(),eq:Vv}),Rv({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:Vv}),Rv({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:Vv});function Hv(e){return Rv({parse:t=>{let n=t;return e.includes(n)?n:null},serialize:String})}function Uv(e){if(e.size===0)return``;let t=[];for(let[n,r]of e.entries()){let e=n.replace(/#/g,`%23`).replace(/&/g,`%26`).replace(/\+/g,`%2B`).replace(/=/g,`%3D`).replace(/\?/g,`%3F`);t.push(`${e}=${Wv(r)}`)}return`?`+t.join(`&`)}function Wv(e){return e.replace(/%/g,`%25`).replace(/\+/g,`%2B`).replace(/ /g,`+`).replace(/#/g,`%23`).replace(/&/g,`%26`).replace(/"/g,`%22`).replace(/'/g,`%27`).replace(/`/g,`%60`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/[\x00-\x1F]/g,e=>encodeURIComponent(e))}function Gv(e,{clearOnDefault:t=!0,urlKeys:n={},processUrlSearchParams:r}={}){function i(i,a={}){let[o,s]=Kv(i)?qv(i):[``,new URLSearchParams],c=Kv(i)?a:i;if(c===null){for(let t in e){let e=n[t]??t;s.delete(e)}return r&&(s=r(s)),o+Uv(s)}for(let r in e){let i=e[r],a=c[r];if(!i||a===void 0)continue;let o=n[r]??r,l=i.defaultValue!==void 0&&a!==null&&(i.eq??((e,t)=>e===t))(a,i.defaultValue);a===null||(i.clearOnDefault??t??!0)&&l?s.delete(o):s=Av(i.serialize(a),o,s)}return r&&(s=r(s)),o+Uv(s)}return i}function Kv(e){return typeof e==`string`||e instanceof URLSearchParams||e instanceof URL}function qv(e){if(typeof e==`string`){let[t=``,...n]=e.split(`?`);return[t,new URLSearchParams(n.join(`?`))]}else if(e instanceof URLSearchParams)return[``,new URLSearchParams(e)];else return[e.origin+e.pathname,new URLSearchParams(e.searchParams)]}const Jv={path:zv.withOptions({shallow:!1}),objectPath:zv,zoomPath:zv.withOptions({shallow:!1}),branch:zv.withOptions({shallow:!1}),timeUnit:Hv(Q_).withOptions({shallow:!1}),start:Bv.withOptions({shallow:!1}),end:Bv.withOptions({shallow:!1})};Gv(Jv),jv(Jv);var Yv=class{status=`Initialized`;gitService;db;progress=[0];totalCommitCount=0;progressRevision=0;fileTreeAsOf=null;fileTreeResult=null;timeIntervalMutex=new Sv;currentTimeInterval=null;prevResult=null;prevArgs=null;prevInvokeReason=`unknown`;repositoryPath;repositoryName;branch;constructor({db:e,gitService:t,repositoryPath:n,branch:r}){this.repositoryPath=n,this.repositoryName=iy(n),this.branch=r,this.gitService=t,this.db=e}updateProgress(e){this.progress[e]++,this.progressRevision++}abort(){let e=this.status;return this.status=`Aborted`,this.progressRevision++,e}throwIfAborted(){if(this.status===`Aborted`)throw Error(`Instance aborted`)}setAnalyzationStatus(e){this.status!==`Aborted`&&(this.status=e,this.progressRevision++)}async gathererWorker(e,t,n){let r=7e4;for(let i=e;i<=t;i+=r){let a=Math.min(i+r,t),o=new Map,s=[];I.debug(`thread ${n} gathering ${i}-${a}`),await this.gatherCommitsInRange(i,a,o,s,n),await this.db.addRenames(s),await this.db.addCommits(o),this.progress[n]=a-e}}async updateTimeInterval(e,t){if(this.currentTimeInterval?.start===e&&this.currentTimeInterval.end===t)return;await this.db.updateTimeInterval(e,t);let n=this.fileTreeAsOf;this.fileTreeAsOf=await this.db.getLatestCommitHash(t),n&&n!==this.fileTreeAsOf&&(this.fileTreeResult=null),this.currentTimeInterval={start:e,end:t}}invalidateTimeInterval(){this.currentTimeInterval=null}async withTimeInterval(e,t){return await this.timeIntervalMutex.withDisposable(()=>this.updateTimeInterval(e,t))}async analyzeTree(){this.throwIfAborted(),this.fileTreeAsOf||=await this.db.getLatestCommitHash();let e=(await this.gitService.lsTree(this.fileTreeAsOf)).matchAll(pv).toArray().flatMap(e=>{if(!e.groups)return[];let t=e.groups,n=t.path.split(`/`).at(-1),r=Number(t.size===`-`?0:t.size);return{type:t.type,hash:t.hash,byteSize:Number.isFinite(r)?r:0,path:this.repositoryName+`/`+t.path,name:n}});I.time(`calculate tree sizes`);let t=new Map([[this.repositoryName,0]]);for(let n of e)n.type===`tree`&&t.set(n.path,0);for(let n of e){if(n.type!==`blob`)continue;let e=n.path.lastIndexOf(`/`);for(;e!==-1;){let r=n.path.slice(0,e);if(t.set(r,(t.get(r)??0)+n.byteSize),r===this.repositoryName)break;e=r.lastIndexOf(`/`)}}I.timeEnd(`calculate tree sizes`);let n={type:`tree`,path:this.repositoryName,name:this.repositoryName,hash:this.fileTreeAsOf,byteSize:t.get(this.repositoryName)??0},r=[n,...e.map(e=>e.type===`tree`?{...e,byteSize:t.get(e.path)??0}:e)],i=e.filter(e=>e.type===`blob`).length,a={...n,children:[]};this.throwIfAborted(),await this.db.replaceFiles(r);let o=new Map([[a.path,a]]);for(let t of e){let e=`${t.path}`,n=e.slice(e.lastIndexOf(`/`)+1),r=e.slice(0,e.lastIndexOf(`/`)),i=o.get(r)??a;switch(t.type){case`tree`:{if(!t.hash)throw Error(`oh no missing hash`);let r={type:`tree`,hash:t.hash,path:e,name:n,byteSize:t.byteSize,children:[]};i.children.push(r),o.set(e,r);break}case`blob`:{let r={type:`blob`,hash:t.hash,path:e,name:n,extension:n.substring(n.lastIndexOf(`.`)+1),byteSize:t.byteSize};i.children.push(r);break}}}return this.treeCleanup(a),this.fileTreeResult={rootTree:a,fileCount:i},this.fileTreeResult}async getFileTree(){return this.fileTreeResult??await this.analyzeTree()}filterHiddenFilesFromTree(e,t){let n=t.flatMap(e=>{let t=`${this.repositoryName}/`;return e.startsWith(t)?[e,e.slice(t.length)]:[e]}),r=(0,Ov.default)().add(n),i=e=>{let t=e.path===this.repositoryName?``:e.path.slice(this.repositoryName.length+1);if(t&&r.ignores(t))return null;if(e.type===`blob`)return e;let n=0,a=[];for(let t of e.children){let e=i(t);e&&(n+=e.byteSize,a.push(e))}return a.length===0&&e.path!==this.repositoryName?null:{...e,byteSize:n,children:a}},a=i(e);return!a||a.type!==`tree`?{rootTree:{...e,byteSize:0,children:[]},fileCount:0}:{rootTree:a,fileCount:this.countFiles(a)}}countFiles(e){let t=0;for(let n of e.children)n.type===`blob`?t+=1:t+=this.countFiles(n);return t}treeCleanup(e){for(let t of e.children)if(t.type===`tree`){let e=t;this.treeCleanup(e)}if(e.children=e.children.filter(e=>e.type===`blob`?!0:e.children.length!==0),e.children.length===1&&e.children[0].type===`tree`){let t=e.children[0];e.children=t.children,e.name=`${e.name}/${t.name}`,e.path=`${e.path}/${t.name}`}}async gatherCommitsFromGitLog(e,t,n){let r=e.matchAll(dv),i=[];for(let e of r){this.throwIfAborted();let r=e.groups??{},a=r.author,o=r.authorEmail,s=Number(r.dateCommitter),c=Number(r.dateAuthor),l=r.hash,u=r.contributions,d=r.modes,f=cv(r.trailers),p=[];if(d){let e=d.matchAll(mv);for(let t of e){let e=t.groups?.file.trim(),n=t.groups?.mode.trim();!e||!n||(n===`delete`||n===`create`)&&i.push({path:e,timestamp:s,timestampAuthor:c,type:n})}}if(u){let e=u.matchAll(fv);for(let t of e){let e=t.groups?.file.trim(),r=t.groups?.insertions===`-`;if(!e)throw Error(`file not found`);let i=e.includes(`=>`),a=e;i&&(a=iv(e,s,c,n,this.repositoryName));let o=r?1:Number(t.groups?.insertions??`0`),l=r?0:Number(t.groups?.deletions??`0`);p.push({isBinary:r,insertions:o,deletions:l,path:this.repositoryName+`/`+a,mode:`modify`})}}t.set(l,{author:{name:a,email:o},committerTime:s,authorTime:c,hash:l,coauthors:f,fileChanges:p})}n.push(...i.map(e=>e.type===`delete`?{fromName:e.path,toName:null,timestamp:e.timestamp,timestampAuthor:e.timestampAuthor}:{fromName:null,toName:e.path,timestamp:e.timestamp,timestampAuthor:e.timestampAuthor}))}async getFullCommits(e){let t=[],n=e.matchAll(uv);for(let e of n){this.throwIfAborted();let n=e.groups??{},r=n.author,i=n.authorEmail,a=n.message,o=n.body,s=Number(n.dateCommitter),c=Number(n.dateAuthor),l=n.hash,u=n.contributions,d=cv(o),f=[];if(u){let e=u.matchAll(fv);for(let t of e){let e=t.groups?.file.trim(),n=t.groups?.insertions===`-`;if(!e)throw Error(`file not found`);let r=n?1:Number(t.groups?.insertions??`0`),i=n?0:Number(t.groups?.deletions??`0`);f.push({isBinary:n,insertions:r,deletions:i,path:e,mode:`modify`})}}t.push({author:{name:r,email:i},committerTime:s,authorTime:c,hash:l,fileChanges:f,message:a,body:o,coauthors:d})}return t}async gatherCommitsInRange(e,t,n,r,i){this.throwIfAborted();let a=await this.gitService.gitLogSimple(e,t-e,this,i);await this.gatherCommitsFromGitLog(a,n,r),I.debug(`done gathering`)}flattenChains(e){return e.flatMap(e=>{let t=e[0].toName;return e.map(e=>({...e,toName:t}))})}async updateRenames(){let e=await this.db.getCurrentRenameIntervals(),t=await this.db.getFiles(),n=this.generateRenameChains(e,t),r=this.flattenChains(n);await this.db.replaceTemporaryRenames(r)}generateRenameChains(e,t){let n=new Map,r=[];for(let e of t)n.set(e,[{fromName:e,toName:e,timestamp:0,timestampEnd:4e9}]);for(let t of e){if(t.toName===null)continue;let e=n.get(t.toName);if(e){let i=e[e.length-1];i.timestamp=t.timestampEnd,t.fromName===null?(i.timestamp=t.timestampEnd,r.push(e)):(e.push(t),n.set(t.fromName,e)),n.delete(t.toName)}}return r.push(...n.values()),r}getThreadCount(e){let t=8e8,n=process.platform===`linux`||process.platform===`win32`?x()-t:Math.floor(S()/2)-t,r=Math.min(Math.max(b().length-2,2),4);if(n<1)return r;let i=Math.max(1300*e,4e8),a=Math.floor(n/i);return Math.max(2,Math.min(r,a))}calculateSections(e,t){let n=[];if(t===2){let t=Math.floor(e*53/100);n.push([0,t]),n.push([t,e])}else if(t===3){let t=Math.floor(e*35/100),r=Math.floor(e*33/100);n.push([0,t]),n.push([t,t+r]),n.push([t+r,e])}else if(t===4){let t=Math.floor(e*27/100),r=Math.floor(e*26/100),i=Math.floor(e*24/100);n.push([0,t]),n.push([t,t+r]),n.push([t+r,t+r+i]),n.push([t+r+i,e])}else throw Error(`Invalid threadCount. Only 2, 3, or 4 are allowed.`);return n}async loadRepoData(){this.setAnalyzationStatus(`Initialized`);let e=await this.gitService.getCommitCount(),t=await wv.getInstance().getLastRun({repositoryPath:this.repositoryPath,branch:this.branch});if(!await this.db.commitTableEmpty())if(t){let t=await this.db.getLatestCommitHash();e=await this.gitService.commitCountSinceCommit(t,this.branch),I.debug(`Repo has been analyzed previously, only analyzing ${e} commits`)}else I.warn(`Incomplete database found. Clearing and running complete analysis.`),await this.db.clearAllTables();if(e<1)return;let[n]=await $(this.gitService.getDefaultGitSettingValue(`core.quotepath`));await $(this.gitService.setGitSetting(`core.quotePath`,`off`));let[r]=await $(this.gitService.getDefaultGitSettingValue(`diff.renames`));await $(this.gitService.setGitSetting(`diff.renames`,`true`));let[i]=await $(this.gitService.getDefaultGitSettingValue(`diff.renameLimit`));await $(this.gitService.setGitSetting(`diff.renameLimit`,`1000000`)),this.totalCommitCount=e;let a=this.getThreadCount(e);this.progress=Array(a).fill(0),this.setAnalyzationStatus(`ProcessingCommitHistory`);let o=this.calculateSections(e,a),s=Array.from({length:a},async(e,t)=>{let n=o[t][0],r=o[t][1];I.debug(`start thread `+n+`-`+r+`, `+t),await this.gathererWorker(n,r,t),I.debug(`finished thread: `+t)});await Promise.all(s),await this.db.createIndexes(),await this.db.checkpoint(),n&&await $(this.gitService.resetGitSetting(`core.quotepath`,n)),r&&await $(this.gitService.resetGitSetting(`diff.renames`,r)),i&&await $(this.gitService.resetGitSetting(`diff.renameLimit`,i)),await wv.getInstance().setCompletion({repositoryPath:this.repositoryPath,branch:this.branch},await this.db.getLatestCommitHash()),this.invalidateTimeInterval(),this.setAnalyzationStatus(`CommitHistoryProcessed`)}};function Xv(e,t,n,r,i){I.debug(`exec ${e} $ ${t} ${n.join(` `)}`);let a=Error(`Command failed: `+t+` `+n.join(` `));return new Promise((o,s)=>{let l=c.resolve(e),u=ee(t,n,{cwd:l}),d=[],f=[];u.on(`error`,e=>{a.message+=`\nFailed to start process: ${e.message}`,s(a)}),u.stdout.on(`data`,e=>{d.push(e),r&&i!==void 0&&r.updateProgress(i)}),u.stderr.on(`data`,e=>f.push(e)),u.on(`close`,e=>{let r=Buffer.concat(d).toString().trim(),i=Buffer.concat(f).toString().trim();if(e===0){o(r);return}a.message=`Command failed: ${t} ${n.join(` `)}\ncwd: ${l}\n\n${i||`Exited with code ${e}`}`,s(a)})})}function Zv(e){let t=[];for(let n=0;n<e;n++){let r=`${` `.repeat(e-n-1)}🚛\n`;t.push(r)}return t}function Qv(){return fi()===null?(0,$r.createSpinner)(``,{interval:1e3/20,frames:Zv(20)}):null}let $v=null;async function ey({job:e=async()=>null,beforeMsg:t=``,afterMsg:n=``,errorMsg:r=``,ms:i=null}){$v=Qv();let a=(e,t=!1)=>{if(fi()!==ri.SILENT){if($v===null)return I.info(e);$v.success({text:e}),t||$v.start()}},o=e=>{$v?($v.update({text:e,frames:Zv(e.length)}),$v.start()):I.info(e)},s=e=>$v===null?I.error(e):$v.error({text:e.message});t.length>0&&o(t);try{let t=ne.now(),r=await e(),o=ne.now();return a(`${n} ${Qr.default.gray(`${av(i||o-t)}`)}`,!0),[r,null]}catch(e){let t=Error(r,{cause:e});return s(t),[null,t]}}let ty=null;async function ny(){if(!ty){I.info(`Fetching latest version from npm registry...`);let[e]=await $(fetch(`https://registry.npmjs.org/-/package/git-truck/dist-tags`).then(e=>e.json()).then(e=>e.latest));ty=e}return ty}const ry=e=>ay(c.dirname(e)),iy=e=>{let t=c.resolve(e);return c.basename(t)||t};function ay(e){return ov(c.resolve(e))}var oy=class{static CACHE_FOLDER=i(t.tmpdir(),`git-truck-cache`);static instancesSingleton=new Map;static mutex=new Sv;static getInstanceIsAborted({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);return n?n.status===`Aborted`:!1}static async abortInstance({repositoryPath:e,branch:t}){try{var n=Cv();n.u(await this.mutex.withDisposable());let r=this.instancesSingleton.get(e)?.get(t);if(r){let n=r.abort();return await this.closeInstance({repositoryPath:e,branch:t}),n!==`CommitHistoryProcessed`&&await this.clearCache({repositoryPath:e,branch:t}),!0}return!1}catch(e){n.e=e}finally{n.d()}}static getInstanceProgress({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);return n?{status:n.status,totalCommitCount:n.totalCommitCount,progress:n.progress,progressPercentage:this.calculateProgressPercentage(n.progress,n.totalCommitCount),progressRevision:n.progressRevision}:null}static calculateProgressPercentage(e,t){return t>0?Math.min(e.reduce((e,t)=>e+t,0)/t*100,100):0}static async getInstance({repositoryPath:e,branch:t}){try{var n=Cv();return n.u(await this.mutex.withDisposable()),await this.getOrCreateInstanceUnlocked({repositoryPath:e,branch:t})}catch(e){n.e=e}finally{n.d()}}static async getOrCreateInstanceUnlocked({repositoryPath:e,branch:t}){this.instancesSingleton||=new Map;let n=this.instancesSingleton.get(e)?.get(t);if(n&&n.status!==`Aborted`)return n;let r=new Yv({db:await this.initOrRecreateDatabase({repositoryPath:e,branch:t}),gitService:new lv({repositoryPath:e,branch:t}),repositoryPath:e,branch:t}),i=this.instancesSingleton.get(e);return i?i.set(t,r):this.instancesSingleton.set(e,new Map([[t,r]])),r}static async closeInstance({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);n&&(this.instancesSingleton.get(e)?.delete(t),this.instancesSingleton.get(e)?.size===0&&this.instancesSingleton.delete(e),await n.db.close())}static async clearAllCaches(){try{var e=Cv();e.u(await this.mutex.withDisposable()),await this.closeAllDBInstancesUnlocked(),await this.clearAllCachesUnlocked(),await wv.resetInstance()}catch(t){e.e=t}finally{e.d()}}static async closeAllDBInstances(){try{var e=Cv();e.u(await this.mutex.withDisposable()),await this.closeAllDBInstancesUnlocked()}catch(t){e.e=t}finally{e.d()}}static async closeAllDBInstancesUnlocked(){let e=Array.from(this.instancesSingleton.values()).flatMap(e=>Array.from(e.values()).flatMap(e=>(e.abort(),e.db.close())));await Promise.all(e),this.instancesSingleton=new Map}static getDBPath({repositoryPath:e,branch:t}){let n=encodeURIComponent(e),r=encodeURIComponent(t);return i(this.CACHE_FOLDER,n,`${r}.db`)}static async clearAllCachesUnlocked(){h(this.CACHE_FOLDER)&&await j.rm(this.CACHE_FOLDER,{recursive:!0,force:!0})}static async clearCache({repositoryPath:e,branch:t}){let n=this.getDBPath({repositoryPath:e,branch:t});await Promise.allSettled([j.rm(n,{force:!0}),j.rm(`${n}.wal`,{force:!0})]);let i=r(n);(await j.readdir(i).catch(()=>[])).length===0&&await j.rmdir(i).catch(()=>{})}static async initDuckDBInstance(e){let t=r(e);return h(t)||await j.mkdir(t,{recursive:!0}),await re.create(e,{temp_directory:t})}static async initOrRecreateDatabase({repositoryPath:e,branch:t}){let n=this.getDBPath({repositoryPath:e,branch:t}),r=await this.initDuckDBInstance(n),i=await r.connect(),a=(await i.runAndReadAll(`SHOW TABLES`)).getRowObjects(),o=a.length===0,s=a.some(e=>e.name===`metadata`)?(await i.runAndReadAll(`SELECT stringValue FROM metadata WHERE field = 'version';`).catch(()=>{}))?.getRowObjects()[0]?.stringValue?.toString()??null:null;s&&I.debug(`Found existing database with git-truck version ${s}`);let c=s?(0,la.diff)(s,Un)===`major`:!0;if(a.length>0&&c){I.warn(`Database at path ${n} is stale (db: ${s}, installed: ${Un}), resetting...`),await this.closeInstance({repositoryPath:e,branch:t}),i.closeSync(),r.closeSync(),await this.clearCache({repositoryPath:e,branch:t}),r=await this.initDuckDBInstance(n),i=await r.connect(),I.info(`Database reset complete. Verifying...`);let a=(await i.runAndReadAll(`SHOW TABLES`)).getRowObjects();if(a.length>0)throw Error(`Failed to clear stale database, tables still exist after clearing: ${JSON.stringify(a)}`);I.info(`Done clearing stale database!`),o=!0}else I.info(`Database at path ${n} is up to date`);let l=await new sv({instance:r,connection:i}).init();return o&&(await this.insertGitTruckVersion(i),await this.insertCommonIgnoredFiles(l)),l}static async insertGitTruckVersion(e){if((await(await e.run(`SELECT stringValue FROM metadata WHERE field = 'version';`)).getRowObjects()).length>0)throw Error(`DB has already been populated with version metadata`);await e.run(`INSERT INTO metadata (field, stringValue) VALUES ('version', '${Un}');`)}static async insertCommonIgnoredFiles(e){await e.addHiddenFile(`package-lock.json`),await e.addHiddenFile(`bun.lock`),await e.addHiddenFile(`bun.lockb`),await e.addHiddenFile(`yarn.lock`)}};const sy=ti();sy.help&&(console.log(ni()),process.exit(0)),console.log(`Git Truck version ${Un}${await gy()}\n`),sy.version&&process.exit(0);const cy=n.dirname(o(import.meta.url)),ly=n.join(cy,`build/server/index.js`),uy=n.join(cy,`build/client`),dy=n.join(cy,`build/client/assets`);let fy;const py=process.env.PORT?Number.parseInt(process.env.PORT,10):NaN;Number.isInteger(py)&&py>=1&&py<=65535?fy=py:(process.env.PORT&&I.warn(`Invalid PORT environment variable "${process.env.PORT}". Falling back to an available port.`),fy=await $n({port:[...er(3e3,4e3)]}));const my=(0,Hn.default)();my.use(`/assets`,Hn.static(dy,{immutable:!0,maxAge:`1y`})),my.use(Hn.static(uy,{maxAge:`1h`})),my.use(await import(s(ly).href).then(e=>e.app));const hy=process.env.HOST?my.listen(fy,process.env.HOST,vy):my.listen(fy,vy);process.once(`SIGTERM`,_y),process.once(`SIGINT`,_y),process.on(`unhandledRejection`,e=>{let t=Error(`Unhandled Rejection`,{cause:e instanceof Error?e:void 0});console.error(`UNHANDLED:`,t)});async function gy(){let[e]=await $(ny());return e?tv(e,Un)===1?Un.startsWith(`0.0.0`)?` (experimental build)`:` [!] Update available: ${e}
|
|
920
|
+
var t={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},n=Object.assign,r={};function i(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}i.prototype.isReactComponent={},i.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function a(){}a.prototype=i.prototype;function o(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}var s=o.prototype=new a;s.constructor=o,n(s,i.prototype),s.isPureReactComponent=!0,Array.isArray})),Dv=N(((e,t)=>{t.exports=Ev()})),Ov=ue(Tv(),1);Dv();function kv(e){return e===null||Array.isArray(e)&&e.length===0}function Av(e,t,n){if(typeof e==`string`)n.set(t,e);else{n.delete(t);for(let r of e)n.append(t,r);n.has(t)||n.set(t,``)}return n}function jv(e,{urlKeys:t={}}={}){function n(r,{strict:i=!1}={}){if(r instanceof Promise)return r.then(e=>n(e,{strict:i}));let a=Mv(r),o={};for(let[n,r]of Object.entries(e)){let e=t[n]??n,s=r.type===`multi`?a.getAll(e):a.get(e);if(kv(s)){o[n]=r.defaultValue??null;continue}let c;try{c=r.parse(s)}catch(e){if(i)throw Error(`[nuqs] Error while parsing query \`${s}\` for key \`${n}\`: ${e}`);c=null}if(i&&s&&c===null)throw Error(`[nuqs] Failed to parse query \`${s}\` for key \`${n}\` (got null)`);o[n]=c??r.defaultValue??null}return o}return n}function Mv(e){try{if(e instanceof Request)return e.url?new URL(e.url).searchParams:new URLSearchParams;if(e instanceof URL)return e.searchParams;if(e instanceof URLSearchParams)return e;if(typeof e==`object`){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r);return t}if(typeof e==`string`)return URL.hasOwnProperty(`canParse`)&&URL.canParse(e)?new URL(e).searchParams:new URLSearchParams(e)}catch{}return new URLSearchParams}function Nv(){if(typeof window>`u`||!window.GestureEvent)return 50;try{let e=navigator.userAgent?.match(/version\/([\d\.]+) safari/i);return parseFloat(e[1])>=17?120:320}catch{return 320}}Nv();const Pv=Iv();function Fv(e,...t){Pv&&console.warn(e,...t)}function Iv(){if(typeof window>`u`)return(process.env.DEBUG||``).includes(`nuqs`);try{let e=`nuqs-localStorage-test`;if(typeof localStorage>`u`)return!1;localStorage.setItem(e,e);let t=localStorage.getItem(e)===e;return localStorage.removeItem(e),t&&(localStorage.getItem(`debug`)||``).includes(`nuqs`)}catch{return!1}}function Lv(e,t,n){try{return e(t)}catch(e){return Fv("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":``),t,e,n),null}}function Rv(e){function t(t){if(t===void 0)return null;let n=``;if(Array.isArray(t)){if(t[0]===void 0)return null;n=t[0]}return typeof t==`string`&&(n=t),Lv(e.parse,n)}return{type:`single`,eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide(n){return t(n)??e}}},withOptions(e){return{...this,...e}}}}const zv=Rv({parse:e=>e,serialize:String}),Bv=Rv({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>``+Math.round(e)});Rv({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>``+Math.round(e+1)}),Rv({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(t.length&1?`0`:``)+t}}),Rv({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});const Vv=Rv({parse:e=>e.toLowerCase()===`true`,serialize:String});function Hv(e,t){return e.valueOf()===t.valueOf()}Rv({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>``+e.valueOf(),eq:Hv}),Rv({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:Hv}),Rv({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:Hv});function Uv(e){return Rv({parse:t=>{let n=t;return e.includes(n)?n:null},serialize:String})}function Wv(e){if(e.size===0)return``;let t=[];for(let[n,r]of e.entries()){let e=n.replace(/#/g,`%23`).replace(/&/g,`%26`).replace(/\+/g,`%2B`).replace(/=/g,`%3D`).replace(/\?/g,`%3F`);t.push(`${e}=${Gv(r)}`)}return`?`+t.join(`&`)}function Gv(e){return e.replace(/%/g,`%25`).replace(/\+/g,`%2B`).replace(/ /g,`+`).replace(/#/g,`%23`).replace(/&/g,`%26`).replace(/"/g,`%22`).replace(/'/g,`%27`).replace(/`/g,`%60`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/[\x00-\x1F]/g,e=>encodeURIComponent(e))}function Kv(e,{clearOnDefault:t=!0,urlKeys:n={},processUrlSearchParams:r}={}){function i(i,a={}){let[o,s]=qv(i)?Jv(i):[``,new URLSearchParams],c=qv(i)?a:i;if(c===null){for(let t in e){let e=n[t]??t;s.delete(e)}return r&&(s=r(s)),o+Wv(s)}for(let r in e){let i=e[r],a=c[r];if(!i||a===void 0)continue;let o=n[r]??r,l=i.defaultValue!==void 0&&a!==null&&(i.eq??((e,t)=>e===t))(a,i.defaultValue);a===null||(i.clearOnDefault??t??!0)&&l?s.delete(o):s=Av(i.serialize(a),o,s)}return r&&(s=r(s)),o+Wv(s)}return i}function qv(e){return typeof e==`string`||e instanceof URLSearchParams||e instanceof URL}function Jv(e){if(typeof e==`string`){let[t=``,...n]=e.split(`?`);return[t,new URLSearchParams(n.join(`?`))]}else if(e instanceof URLSearchParams)return[``,new URLSearchParams(e)];else return[e.origin+e.pathname,new URLSearchParams(e.searchParams)]}const Yv={path:zv.withOptions({shallow:!1}),objectPath:zv,zoomPath:zv.withOptions({shallow:!1}),branch:zv.withOptions({shallow:!1}),timeUnit:Uv(Q_).withOptions({shallow:!1}),start:Bv.withOptions({shallow:!1}),end:Bv.withOptions({shallow:!1}),includeCoauthors:Vv.withDefault(!1).withOptions({shallow:!1})};Kv(Yv),jv(Yv);var Xv=class{status=`Initialized`;gitService;db;progress=[0];totalCommitCount=0;progressRevision=0;fileTreeAsOf=null;fileTreeResult=null;timeIntervalMutex=new Sv;currentTimeInterval=null;prevResult=null;prevArgs=null;prevInvokeReason=`unknown`;repositoryPath;repositoryName;branch;constructor({db:e,gitService:t,repositoryPath:n,branch:r}){this.repositoryPath=n,this.repositoryName=ay(n),this.branch=r,this.gitService=t,this.db=e}updateProgress(e){this.progress[e]++,this.progressRevision++}abort(){let e=this.status;return this.status=`Aborted`,this.progressRevision++,e}throwIfAborted(){if(this.status===`Aborted`)throw Error(`Instance aborted`)}setAnalyzationStatus(e){this.status!==`Aborted`&&(this.status=e,this.progressRevision++)}async gathererWorker(e,t,n){let r=7e4;for(let i=e;i<=t;i+=r){let a=Math.min(i+r,t),o=new Map,s=[];I.debug(`thread ${n} gathering ${i}-${a}`),await this.gatherCommitsInRange(i,a,o,s,n),await this.db.addRenames(s),await this.db.addCommits(o),this.progress[n]=a-e}}async updateTimeInterval(e,t){if(this.currentTimeInterval?.start===e&&this.currentTimeInterval.end===t)return;await this.db.updateTimeInterval(e,t);let n=this.fileTreeAsOf;this.fileTreeAsOf=await this.db.getLatestCommitHash(t),n&&n!==this.fileTreeAsOf&&(this.fileTreeResult=null),this.currentTimeInterval={start:e,end:t}}invalidateTimeInterval(){this.currentTimeInterval=null}async withTimeInterval(e,t){return await this.timeIntervalMutex.withDisposable(()=>this.updateTimeInterval(e,t))}async analyzeTree(){this.throwIfAborted(),this.fileTreeAsOf||=await this.db.getLatestCommitHash();let e=(await this.gitService.lsTree(this.fileTreeAsOf)).matchAll(pv).toArray().flatMap(e=>{if(!e.groups)return[];let t=e.groups,n=t.path.split(`/`).at(-1),r=Number(t.size===`-`?0:t.size);return{type:t.type,hash:t.hash,byteSize:Number.isFinite(r)?r:0,path:this.repositoryName+`/`+t.path,name:n}});I.time(`calculate tree sizes`);let t=new Map([[this.repositoryName,0]]);for(let n of e)n.type===`tree`&&t.set(n.path,0);for(let n of e){if(n.type!==`blob`)continue;let e=n.path.lastIndexOf(`/`);for(;e!==-1;){let r=n.path.slice(0,e);if(t.set(r,(t.get(r)??0)+n.byteSize),r===this.repositoryName)break;e=r.lastIndexOf(`/`)}}I.timeEnd(`calculate tree sizes`);let n={type:`tree`,path:this.repositoryName,name:this.repositoryName,hash:this.fileTreeAsOf,byteSize:t.get(this.repositoryName)??0},r=[n,...e.map(e=>e.type===`tree`?{...e,byteSize:t.get(e.path)??0}:e)],i=e.filter(e=>e.type===`blob`).length,a={...n,children:[]};this.throwIfAborted(),await this.db.replaceFiles(r);let o=new Map([[a.path,a]]);for(let t of e){let e=`${t.path}`,n=e.slice(e.lastIndexOf(`/`)+1),r=e.slice(0,e.lastIndexOf(`/`)),i=o.get(r)??a;switch(t.type){case`tree`:{if(!t.hash)throw Error(`oh no missing hash`);let r={type:`tree`,hash:t.hash,path:e,name:n,byteSize:t.byteSize,children:[]};i.children.push(r),o.set(e,r);break}case`blob`:{let r={type:`blob`,hash:t.hash,path:e,name:n,extension:n.substring(n.lastIndexOf(`.`)+1),byteSize:t.byteSize};i.children.push(r);break}}}return this.treeCleanup(a),this.fileTreeResult={rootTree:a,fileCount:i},this.fileTreeResult}async getFileTree(){return this.fileTreeResult??await this.analyzeTree()}filterHiddenFilesFromTree(e,t){let n=t.flatMap(e=>{let t=`${this.repositoryName}/`;return e.startsWith(t)?[e,e.slice(t.length)]:[e]}),r=(0,Ov.default)().add(n),i=e=>{let t=e.path===this.repositoryName?``:e.path.slice(this.repositoryName.length+1);if(t&&r.ignores(t))return null;if(e.type===`blob`)return e;let n=0,a=[];for(let t of e.children){let e=i(t);e&&(n+=e.byteSize,a.push(e))}return a.length===0&&e.path!==this.repositoryName?null:{...e,byteSize:n,children:a}},a=i(e);return!a||a.type!==`tree`?{rootTree:{...e,byteSize:0,children:[]},fileCount:0}:{rootTree:a,fileCount:this.countFiles(a)}}countFiles(e){let t=0;for(let n of e.children)n.type===`blob`?t+=1:t+=this.countFiles(n);return t}treeCleanup(e){for(let t of e.children)if(t.type===`tree`){let e=t;this.treeCleanup(e)}if(e.children=e.children.filter(e=>e.type===`blob`?!0:e.children.length!==0),e.children.length===1&&e.children[0].type===`tree`){let t=e.children[0];e.children=t.children,e.name=`${e.name}/${t.name}`,e.path=`${e.path}/${t.name}`}}async gatherCommitsFromGitLog(e,t,n){let r=e.matchAll(dv),i=[];for(let e of r){this.throwIfAborted();let r=e.groups??{},a=r.author,o=r.authorEmail,s=Number(r.dateCommitter),c=Number(r.dateAuthor),l=r.hash,u=r.contributions,d=r.modes,f=cv(r.trailers),p=[];if(d){let e=d.matchAll(mv);for(let t of e){let e=t.groups?.file.trim(),n=t.groups?.mode.trim();!e||!n||(n===`delete`||n===`create`)&&i.push({path:e,timestamp:s,timestampAuthor:c,type:n})}}if(u){let e=u.matchAll(fv);for(let t of e){let e=t.groups?.file.trim(),r=t.groups?.insertions===`-`;if(!e)throw Error(`file not found`);let i=e.includes(`=>`),a=e;i&&(a=iv(e,s,c,n,this.repositoryName));let o=r?1:Number(t.groups?.insertions??`0`),l=r?0:Number(t.groups?.deletions??`0`);p.push({isBinary:r,insertions:o,deletions:l,path:this.repositoryName+`/`+a,mode:`modify`})}}t.set(l,{author:{name:a,email:o},committerTime:s,authorTime:c,hash:l,coauthors:f,fileChanges:p})}n.push(...i.map(e=>e.type===`delete`?{fromName:e.path,toName:null,timestamp:e.timestamp,timestampAuthor:e.timestampAuthor}:{fromName:null,toName:e.path,timestamp:e.timestamp,timestampAuthor:e.timestampAuthor}))}async getFullCommits(e){let t=[],n=e.matchAll(uv);for(let e of n){this.throwIfAborted();let n=e.groups??{},r=n.author,i=n.authorEmail,a=n.message,o=n.body,s=Number(n.dateCommitter),c=Number(n.dateAuthor),l=n.hash,u=n.contributions,d=cv(o),f=[];if(u){let e=u.matchAll(fv);for(let t of e){let e=t.groups?.file.trim(),n=t.groups?.insertions===`-`;if(!e)throw Error(`file not found`);let r=n?1:Number(t.groups?.insertions??`0`),i=n?0:Number(t.groups?.deletions??`0`);f.push({isBinary:n,insertions:r,deletions:i,path:e,mode:`modify`})}}t.push({author:{name:r,email:i},committerTime:s,authorTime:c,hash:l,fileChanges:f,message:a,body:o,coauthors:d})}return t}async gatherCommitsInRange(e,t,n,r,i){this.throwIfAborted();let a=await this.gitService.gitLogSimple(e,t-e,this,i);await this.gatherCommitsFromGitLog(a,n,r),I.debug(`done gathering`)}flattenChains(e){return e.flatMap(e=>{let t=e[0].toName;return e.map(e=>({...e,toName:t}))})}async updateRenames(){let e=await this.db.getCurrentRenameIntervals(),t=await this.db.getFiles(),n=this.generateRenameChains(e,t),r=this.flattenChains(n);await this.db.replaceTemporaryRenames(r)}generateRenameChains(e,t){let n=new Map,r=[];for(let e of t)n.set(e,[{fromName:e,toName:e,timestamp:0,timestampEnd:4e9}]);for(let t of e){if(t.toName===null)continue;let e=n.get(t.toName);if(e){let i=e[e.length-1];i.timestamp=t.timestampEnd,t.fromName===null?(i.timestamp=t.timestampEnd,r.push(e)):(e.push(t),n.set(t.fromName,e)),n.delete(t.toName)}}return r.push(...n.values()),r}getThreadCount(e){let t=8e8,n=process.platform===`linux`||process.platform===`win32`?x()-t:Math.floor(S()/2)-t,r=Math.min(Math.max(b().length-2,2),4);if(n<1)return r;let i=Math.max(1300*e,4e8),a=Math.floor(n/i);return Math.max(2,Math.min(r,a))}calculateSections(e,t){let n=[];if(t===2){let t=Math.floor(e*53/100);n.push([0,t]),n.push([t,e])}else if(t===3){let t=Math.floor(e*35/100),r=Math.floor(e*33/100);n.push([0,t]),n.push([t,t+r]),n.push([t+r,e])}else if(t===4){let t=Math.floor(e*27/100),r=Math.floor(e*26/100),i=Math.floor(e*24/100);n.push([0,t]),n.push([t,t+r]),n.push([t+r,t+r+i]),n.push([t+r+i,e])}else throw Error(`Invalid threadCount. Only 2, 3, or 4 are allowed.`);return n}async loadRepoData(){this.setAnalyzationStatus(`Initialized`);let e=await this.gitService.getCommitCount(),t=await wv.getInstance().getLastRun({repositoryPath:this.repositoryPath,branch:this.branch});if(!await this.db.commitTableEmpty())if(t){let t=await this.db.getLatestCommitHash();e=await this.gitService.commitCountSinceCommit(t,this.branch),I.debug(`Repo has been analyzed previously, only analyzing ${e} commits`)}else I.warn(`Incomplete database found. Clearing and running complete analysis.`),await this.db.clearAllTables();if(e<1)return;let[n]=await $(this.gitService.getDefaultGitSettingValue(`core.quotepath`));await $(this.gitService.setGitSetting(`core.quotePath`,`off`));let[r]=await $(this.gitService.getDefaultGitSettingValue(`diff.renames`));await $(this.gitService.setGitSetting(`diff.renames`,`true`));let[i]=await $(this.gitService.getDefaultGitSettingValue(`diff.renameLimit`));await $(this.gitService.setGitSetting(`diff.renameLimit`,`1000000`)),this.totalCommitCount=e;let a=this.getThreadCount(e);this.progress=Array(a).fill(0),this.setAnalyzationStatus(`ProcessingCommitHistory`);let o=this.calculateSections(e,a),s=Array.from({length:a},async(e,t)=>{let n=o[t][0],r=o[t][1];I.debug(`start thread `+n+`-`+r+`, `+t),await this.gathererWorker(n,r,t),I.debug(`finished thread: `+t)});await Promise.all(s),await this.db.createIndexes(),await this.db.checkpoint(),n&&await $(this.gitService.resetGitSetting(`core.quotepath`,n)),r&&await $(this.gitService.resetGitSetting(`diff.renames`,r)),i&&await $(this.gitService.resetGitSetting(`diff.renameLimit`,i)),await wv.getInstance().setCompletion({repositoryPath:this.repositoryPath,branch:this.branch},await this.db.getLatestCommitHash()),this.invalidateTimeInterval(),this.setAnalyzationStatus(`CommitHistoryProcessed`)}};function Zv(e,t,n,r,i){I.debug(`exec ${e} $ ${t} ${n.join(` `)}`);let a=Error(`Command failed: `+t+` `+n.join(` `));return new Promise((o,s)=>{let l=c.resolve(e),u=ee(t,n,{cwd:l}),d=[],f=[];u.on(`error`,e=>{a.message+=`\nFailed to start process: ${e.message}`,s(a)}),u.stdout.on(`data`,e=>{d.push(e),r&&i!==void 0&&r.updateProgress(i)}),u.stderr.on(`data`,e=>f.push(e)),u.on(`close`,e=>{let r=Buffer.concat(d).toString().trim(),i=Buffer.concat(f).toString().trim();if(e===0){o(r);return}a.message=`Command failed: ${t} ${n.join(` `)}\ncwd: ${l}\n\n${i||`Exited with code ${e}`}`,s(a)})})}function Qv(e){let t=[];for(let n=0;n<e;n++){let r=`${` `.repeat(e-n-1)}🚛\n`;t.push(r)}return t}function $v(){return fi()===null?(0,$r.createSpinner)(``,{interval:1e3/20,frames:Qv(20)}):null}let ey=null;async function ty({job:e=async()=>null,beforeMsg:t=``,afterMsg:n=``,errorMsg:r=``,ms:i=null}){ey=$v();let a=(e,t=!1)=>{if(fi()!==ri.SILENT){if(ey===null)return I.info(e);ey.success({text:e}),t||ey.start()}},o=e=>{ey?(ey.update({text:e,frames:Qv(e.length)}),ey.start()):I.info(e)},s=e=>ey===null?I.error(e):ey.error({text:e.message});t.length>0&&o(t);try{let t=ne.now(),r=await e(),o=ne.now();return a(`${n} ${Qr.default.gray(`${av(i||o-t)}`)}`,!0),[r,null]}catch(e){let t=Error(r,{cause:e});return s(t),[null,t]}}let ny=null;async function ry(){if(!ny){I.info(`Fetching latest version from npm registry...`);let[e]=await $(fetch(`https://registry.npmjs.org/-/package/git-truck/dist-tags`).then(e=>e.json()).then(e=>e.latest));ny=e}return ny}const iy=e=>oy(c.dirname(e)),ay=e=>{let t=c.resolve(e);return c.basename(t)||t};function oy(e){return ov(c.resolve(e))}var sy=class{static CACHE_FOLDER=i(t.tmpdir(),`git-truck-cache`);static instancesSingleton=new Map;static mutex=new Sv;static getInstanceIsAborted({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);return n?n.status===`Aborted`:!1}static async abortInstance({repositoryPath:e,branch:t}){try{var n=Cv();n.u(await this.mutex.withDisposable());let r=this.instancesSingleton.get(e)?.get(t);if(r){let n=r.abort();return await this.closeInstance({repositoryPath:e,branch:t}),n!==`CommitHistoryProcessed`&&await this.clearCache({repositoryPath:e,branch:t}),!0}return!1}catch(e){n.e=e}finally{n.d()}}static getInstanceProgress({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);return n?{status:n.status,totalCommitCount:n.totalCommitCount,progress:n.progress,progressPercentage:this.calculateProgressPercentage(n.progress,n.totalCommitCount),progressRevision:n.progressRevision}:null}static calculateProgressPercentage(e,t){return t>0?Math.min(e.reduce((e,t)=>e+t,0)/t*100,100):0}static async getInstance({repositoryPath:e,branch:t}){try{var n=Cv();return n.u(await this.mutex.withDisposable()),await this.getOrCreateInstanceUnlocked({repositoryPath:e,branch:t})}catch(e){n.e=e}finally{n.d()}}static async getOrCreateInstanceUnlocked({repositoryPath:e,branch:t}){this.instancesSingleton||=new Map;let n=this.instancesSingleton.get(e)?.get(t);if(n&&n.status!==`Aborted`)return n;let r=new Xv({db:await this.initOrRecreateDatabase({repositoryPath:e,branch:t}),gitService:new lv({repositoryPath:e,branch:t}),repositoryPath:e,branch:t}),i=this.instancesSingleton.get(e);return i?i.set(t,r):this.instancesSingleton.set(e,new Map([[t,r]])),r}static async closeInstance({repositoryPath:e,branch:t}){let n=this.instancesSingleton.get(e)?.get(t);n&&(this.instancesSingleton.get(e)?.delete(t),this.instancesSingleton.get(e)?.size===0&&this.instancesSingleton.delete(e),await n.db.close())}static async clearAllCaches(){try{var e=Cv();e.u(await this.mutex.withDisposable()),await this.closeAllDBInstancesUnlocked(),await this.clearAllCachesUnlocked(),await wv.resetInstance()}catch(t){e.e=t}finally{e.d()}}static async closeAllDBInstances(){try{var e=Cv();e.u(await this.mutex.withDisposable()),await this.closeAllDBInstancesUnlocked()}catch(t){e.e=t}finally{e.d()}}static async closeAllDBInstancesUnlocked(){let e=Array.from(this.instancesSingleton.values()).flatMap(e=>Array.from(e.values()).flatMap(e=>(e.abort(),e.db.close())));await Promise.all(e),this.instancesSingleton=new Map}static getDBPath({repositoryPath:e,branch:t}){let n=encodeURIComponent(e),r=encodeURIComponent(t);return i(this.CACHE_FOLDER,n,`${r}.db`)}static async clearAllCachesUnlocked(){h(this.CACHE_FOLDER)&&await j.rm(this.CACHE_FOLDER,{recursive:!0,force:!0})}static async clearCache({repositoryPath:e,branch:t}){let n=this.getDBPath({repositoryPath:e,branch:t});await Promise.allSettled([j.rm(n,{force:!0}),j.rm(`${n}.wal`,{force:!0})]);let i=r(n);(await j.readdir(i).catch(()=>[])).length===0&&await j.rmdir(i).catch(()=>{})}static async initDuckDBInstance(e){let t=r(e);return h(t)||await j.mkdir(t,{recursive:!0}),await re.create(e,{temp_directory:t})}static async initOrRecreateDatabase({repositoryPath:e,branch:t}){let n=this.getDBPath({repositoryPath:e,branch:t}),r=await this.initDuckDBInstance(n),i=await r.connect(),a=(await i.runAndReadAll(`SHOW TABLES`)).getRowObjects(),o=a.length===0,s=a.some(e=>e.name===`metadata`)?(await i.runAndReadAll(`SELECT stringValue FROM metadata WHERE field = 'version';`).catch(()=>{}))?.getRowObjects()[0]?.stringValue?.toString()??null:null;s&&I.debug(`Found existing database with git-truck version ${s}`);let c=s?(0,la.diff)(s,Un)===`major`:!0;if(a.length>0&&c){I.warn(`Database at path ${n} is stale (db: ${s}, installed: ${Un}), resetting...`),await this.closeInstance({repositoryPath:e,branch:t}),i.closeSync(),r.closeSync(),await this.clearCache({repositoryPath:e,branch:t}),r=await this.initDuckDBInstance(n),i=await r.connect(),I.info(`Database reset complete. Verifying...`);let a=(await i.runAndReadAll(`SHOW TABLES`)).getRowObjects();if(a.length>0)throw Error(`Failed to clear stale database, tables still exist after clearing: ${JSON.stringify(a)}`);I.info(`Done clearing stale database!`),o=!0}else I.info(`Database at path ${n} is up to date`);let l=await new sv({instance:r,connection:i}).init();return o&&(await this.insertGitTruckVersion(i),await this.insertCommonIgnoredFiles(l)),l}static async insertGitTruckVersion(e){if((await(await e.run(`SELECT stringValue FROM metadata WHERE field = 'version';`)).getRowObjects()).length>0)throw Error(`DB has already been populated with version metadata`);await e.run(`INSERT INTO metadata (field, stringValue) VALUES ('version', '${Un}');`)}static async insertCommonIgnoredFiles(e){await e.addHiddenFile(`package-lock.json`),await e.addHiddenFile(`bun.lock`),await e.addHiddenFile(`bun.lockb`),await e.addHiddenFile(`yarn.lock`)}};const cy=ti();cy.help&&(console.log(ni()),process.exit(0)),console.log(`Git Truck version ${Un}${await _y()}\n`),cy.version&&process.exit(0);const ly=n.dirname(o(import.meta.url)),uy=n.join(ly,`build/server/index.js`),dy=n.join(ly,`build/client`),fy=n.join(ly,`build/client/assets`);let py;const my=process.env.PORT?Number.parseInt(process.env.PORT,10):NaN;Number.isInteger(my)&&my>=1&&my<=65535?py=my:(process.env.PORT&&I.warn(`Invalid PORT environment variable "${process.env.PORT}". Falling back to an available port.`),py=await $n({port:[...er(3e3,4e3)]}));const hy=(0,Hn.default)();hy.use(`/assets`,Hn.static(fy,{immutable:!0,maxAge:`1y`})),hy.use(Hn.static(dy,{maxAge:`1h`})),hy.use(await import(s(uy).href).then(e=>e.app));const gy=process.env.HOST?hy.listen(py,process.env.HOST,yy):hy.listen(py,yy);process.once(`SIGTERM`,vy),process.once(`SIGINT`,vy),process.on(`unhandledRejection`,e=>{let t=Error(`Unhandled Rejection`,{cause:e instanceof Error?e:void 0});console.error(`UNHANDLED:`,t)});async function _y(){let[e]=await $(ry());return e?tv(e,Un)===1?Un.startsWith(`0.0.0`)?` (experimental build)`:` [!] Update available: ${e}
|
|
850
921
|
|
|
851
922
|
To update, run:
|
|
852
923
|
npm install -g git-truck@latest
|
|
@@ -854,4 +925,4 @@ npm install -g git-truck@latest
|
|
|
854
925
|
See what's changed here:
|
|
855
926
|
${nv({currentVersion:Un,latestVersion:e})}
|
|
856
927
|
|
|
857
|
-
`:` (latest)`:` (offline)`}async function
|
|
928
|
+
`:` (latest)`:` (offline)`}async function vy(){let e=sy.closeAllDBInstances();I.info(`Shutting down server`),gy.close(console.error),I.info(`Web server shut down`),await ty({job:()=>e,beforeMsg:`Stopping Git Truck...`,afterMsg:`Successfully stopped Git Truck`,errorMsg:`Failed to stop Git Truck`}),process.exit(0)}async function yy(){let e=`http://localhost:${py}`,t=new URL(process.env.PORTLESS_URL||e);t.searchParams.set(`path`,cy.path),t.pathname=await lv.isValidGitRepo(oy(cy.path))?`/view`:`/browse`,cy.headless,console.log(`Application available at ${t}`),cy.headless||(I.debug(`Opening ${t.toString()}`),await ty({job:()=>Ur(t.toString()),beforeMsg:`Opening Git Truck in your browser`,afterMsg:`Opened Git Truck in your browser`,errorMsg:`Failed to open Git Truck in your browser. To continue, open this link manually:\n\n${t}\n`}))}export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-truck",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Visualizing a Git repository",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@react-router/node": "7.15.1",
|
|
73
73
|
"@rolldown/plugin-babel": "0.2.2",
|
|
74
74
|
"@tailwindcss/vite": "4.3.0",
|
|
75
|
-
"@types/bun": "1.3.
|
|
75
|
+
"@types/bun": "1.3.14",
|
|
76
76
|
"@types/byte-size": "8.1.2",
|
|
77
77
|
"@types/d3": "7.4.3",
|
|
78
78
|
"@types/d3-hierarchy": "3.1.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-GK6fC0y1.js";import{S as t,_t as n,n as r,vt as i}from"./clear-cache-BdU23_cx.js";var a=`/assets/crashedTruck_48x-DZ8PrkDC.gif`,o=i(),s=e();function c(e){let i=(0,o.c)(18),a,c,l,u,d;i[0]===e?(a=i[1],c=i[2],l=i[3],u=i[4],d=i[5]):({open:a,className:l,size:u,as:d,...c}=e,i[0]=e,i[1]=a,i[2]=c,i[3]=l,i[4]=u,i[5]=d);let f=l===void 0?``:l,p=u===void 0?1:u,m=d===void 0?`button`:d,h;i[6]===f?h=i[7]:(h=r(`cursor-pointer`,f),i[6]=f,i[7]=h);let g=c.children,_;i[8]===a?_=i[9]:(_=r(`chevron transition-transform`,{"rotate-180":a}),i[8]=a,i[9]=_);let v;i[10]!==p||i[11]!==_?(v=(0,s.jsx)(n,{path:t,size:p,className:_}),i[10]=p,i[11]=_,i[12]=v):v=i[12];let y;return i[13]!==m||i[14]!==c||i[15]!==h||i[16]!==v?(y=(0,s.jsxs)(m,{className:h,...c,children:[g,v]}),i[13]=m,i[14]=c,i[15]=h,i[16]=v,i[17]=y):y=i[17],y}export{a as n,c as t};
|