gitpick 6.1.0-canary.20 → 6.1.0-canary.21
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/README.md +5 -4
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,17 +164,18 @@ npx gitpick https://codeberg.org/owner/repo # Codeberg
|
|
|
164
164
|
|
|
165
165
|
## ⚡ Fast Mode (`--fast`)
|
|
166
166
|
|
|
167
|
-
By default GitPick uses `git clone`, so a pick is byte-for-byte what a checkout gives you. Pass `--fast` (or set `GITPICK_FAST=1` for a whole CI fleet) to fetch through the host's **archive / raw HTTP endpoints** instead
|
|
167
|
+
By default GitPick uses `git clone`, so a pick is byte-for-byte what a checkout gives you. Pass `--fast` (or set `GITPICK_FAST=1` for a whole CI fleet) to fetch through the host's **archive / raw HTTP endpoints** instead: no `git` process, typically **2-4x faster**, and (in a 100-repo differential test) byte-identical to a clone.
|
|
168
168
|
|
|
169
169
|
```sh
|
|
170
170
|
npx gitpick owner/repo --fast # download + extract the tarball
|
|
171
171
|
GITPICK_FAST=1 npx gitpick owner/repo # opt in fleet-wide
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
Three cases where a `--fast` pick can differ from a clone (all are how every archive-based tool, e.g. `degit`, behaves, which is why it's opt-in):
|
|
175
175
|
|
|
176
|
-
- **`.gitattributes` `export-ignore` / `export-subst
|
|
177
|
-
- **`core.autocrlf` on Windows
|
|
176
|
+
- **`.gitattributes` `export-ignore` / `export-subst`**: host archives honor these (they omit paths / expand keywords); a clone does not. Common in PHP/Composer repos.
|
|
177
|
+
- **`core.autocrlf` on Windows**: archives store blobs verbatim (LF); a clone would CRLF-normalize.
|
|
178
|
+
- **Symlink-hostile Windows**: `--fast` warns and skips a symlink it can't create; a clone may fail or write git's text stub instead.
|
|
178
179
|
|
|
179
180
|
`--recursive` (submodules) always uses a clone.
|
|
180
181
|
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ Skipping commit: nothing was cloned to commit.`));return}let u=i.commit||`chore:
|
|
|
19
19
|
`;let s=f.length>r?D(`${l+1}-${Math.min(l+r,f.length)}/${f.length}`)+D(` • `):``,d=D(`↑↓:navigate esc/q:back`);i+=` ${s}${d}\n`,u.write(i)}function S(e){let t=e.toString();if(t===``){g=!1,_=null,d.removeListener(`data`,S),p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]);return}if(t===`\x1B`||t===`q`||t===`Q`||t===`\r`){g=!1,_=null,d.removeListener(`data`,S),d.on(`data`,x),y();return}(t===`\x1B[A`||t===`k`)&&c>0&&c--,(t===`\x1B[B`||t===`j`)&&c<f.length-1&&c++,b()}g=!0,_=b,d.on(`data`,S),b()}function x(e){let t=cr(o),n=t.length+1,r=e.toString();if(r===``||r===`q`||r===`Q`){p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a([]);return}if(r===`c`||r===`C`){p(),process.removeListener(`exit`,m),process.removeListener(`SIGINT`,h),a(dr(o));return}if((r===`\x1B[A`||r===`k`)&&c>0&&c--,(r===`\x1B[B`||r===`j`)&&c<n-1&&c++,c===0&&(r===` `||r===`\r`)||r===`.`){let e=o.every(e=>e.selected);for(let t of o)K(t,!e)}if(r===` `&&c>0){let e=t[c-1];if(e){let t=!e.node.selected;if(K(e.node,t),t&&e.node.type===`symlink`&&e.node.linkTarget){let t=q(o,lr(e.node.path,e.node.linkTarget));t&&K(t,!0)}ur(o)}}if(r===`\r`&&c>0){let e=t[c-1];if(e&&e.node.type===`tree`)e.node.expanded=!e.node.expanded;else if(e&&e.node.type===`symlink`&&e.node.linkTarget.endsWith(`/`)){let t=lr(e.node.path,e.node.linkTarget),n=t.split(`/`);for(let e=1;e<=n.length;e++){let t=q(o,n.slice(0,e).join(`/`));t&&t.type===`tree`&&(t.expanded=!0)}let r=q(o,t);if(r){r.type===`tree`&&(r.expanded=!0);let e=cr(o).findIndex(e=>e.node===r);e>=0&&(c=e+1)}}else if(e&&i&&(e.node.type===`blob`||e.node.type===`symlink`)){b(e.node);return}}if((r===`\x1B[C`||r===`l`)&&c>0){let e=t[c-1];e&&e.node.type===`tree`&&(e.node.expanded=!0)}if((r===`\x1B[D`||r===`h`)&&c>0){let e=t[c-1];e&&e.node.type===`tree`&&(e.node.expanded=!1)}y()}d.on(`data`,x),y()})}function mr(e){if(typeof e==`number`||/^\d+$/.test(e))return typeof e==`number`?e:parseInt(e,10);let t=/(\d+)([hms])/g,n=0,r;for(;(r=t.exec(e))!==null;){let e=parseInt(r[1],10);switch(r[2]){case`h`:n+=e*36e5;break;case`m`:n+=e*6e4;break;case`s`:n+=e*1e3;break}}return n}const Y=async e=>{let t=(await C(`git`,[`ls-remote`,e])).stdout,n=t.match(/(.+)\s+HEAD/)?.[1],r=t.match(RegExp(`${n}\\s+refs/heads/(.+)`))?.[1];if(!r)throw Error(`Could not determine default branch!`);return r},hr=[{prefix:`git@github.com:`,host:`github.com`},{prefix:`https://github.com/`,host:`github.com`},{prefix:`https://raw.githubusercontent.com/`,host:`github.com`},{prefix:`git@gitlab.com:`,host:`gitlab.com`},{prefix:`https://gitlab.com/`,host:`gitlab.com`},{prefix:`git@bitbucket.org:`,host:`bitbucket.org`},{prefix:`https://bitbucket.org/`,host:`bitbucket.org`},{prefix:`git@codeberg.org:`,host:`codeberg.org`},{prefix:`https://codeberg.org/`,host:`codeberg.org`}];async function gr(e,{branch:t,target:n}){let r=e.match(/^https:\/\/([^@]+)@(github\.com|gitlab\.com|bitbucket\.org|codeberg\.org)/),i=``;if(r)i=r[1],e=e.replace(`${r[1]}@`,``);else{let t={"github.com":process.env.GITHUB_TOKEN||process.env.GH_TOKEN||``,"gitlab.com":process.env.GITLAB_TOKEN||``,"bitbucket.org":process.env.BITBUCKET_TOKEN||``,"codeberg.org":process.env.CODEBERG_TOKEN||``};for(let{prefix:n,host:r}of hr)if(e.startsWith(n)){i=t[r];break}!i&&!e.startsWith(`https://`)&&!e.startsWith(`git@`)&&(i=t[`github.com`])}let a=`github.com`;for(let{prefix:t,host:n}of hr)if(e.startsWith(t)){a=n,e=e.replace(t,``);break}let o=e.split(`/`),s=o[0],c=o[1]?.endsWith(`.git`)?o[1].slice(0,-4):o[1],l=`https://${i&&i+`@`}${a}/${s}/${c}`,u,d,f;if(a===`github.com`)o[2]===`refs`&&[`heads`,`tags`].includes(o[3])?(u=`raw`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`refs`&&o[3]===`remotes`?(u=`raw`,d=t||`${o[4]}/${o[5]}`,f=o.slice(6).join(`/`)):o[2]===`blob`?(u=`blob`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`tree`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`commit`?(u=`repository`,d=t||o[3],f=``):(u=`repository`,d=t||await Y(l),f=``);else if(a===`gitlab.com`)o[2]===`-`&&o[3]===`blob`?(u=`blob`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`-`&&o[3]===`tree`?(u=`tree`,d=t||o[4],f=o.slice(5).join(`/`)):(u=`repository`,d=t||await Y(l),f=``);else if(a===`bitbucket.org`)o[2]===`src`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):(u=`repository`,d=t||await Y(l),f=``);else if(a===`codeberg.org`)[`src`,`raw`,`media`].includes(o[2])&&[`branch`,`tag`,`commit`].includes(o[3])?(u=o[2]===`src`?`tree`:`blob`,d=t||o[4],f=o.slice(5).join(`/`)):(u=`repository`,d=t||await Y(l),f=``);else{let e=a;throw Error(`Unsupported host: ${e}`)}let p=n||(u===`blob`?`.`:f.split(`/`).pop()||c),m=!t&&(u===`tree`||u===`blob`)?[d,...f?f.split(`/`):[]]:void 0;return{token:i,host:a,owner:s,repository:c,type:u,branch:d,path:f,target:p,refSegments:m}}const _r=n.join(t.homedir(),`.cache`,`gitpick`),vr=n.join(_r,`update-check.json`);function yr(){try{return JSON.parse(e.readFileSync(vr,`utf-8`))}catch{return null}}function br(t){try{e.mkdirSync(_r,{recursive:!0}),e.writeFileSync(vr,JSON.stringify(t))}catch{}}function xr(){return new Promise(e=>{let t=m.get(`https://registry.npmjs.org/gitpick/latest`,{headers:{Accept:`application/json`},timeout:3e3},t=>{if(t.statusCode!==200)return t.resume(),e(null);let n=``;t.on(`data`,e=>n+=e),t.on(`end`,()=>{try{e(JSON.parse(n).version||null)}catch{e(null)}})});t.on(`error`,()=>e(null)),t.on(`timeout`,()=>{t.destroy(),e(null)})})}function Sr(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]||0)>(r[e]||0))return!0;if((n[e]||0)<(r[e]||0))return!1}return!1}function X(e,t){if(t)return;let n=yr();n&&Sr(n.latestVersion,e)&&console.log(D(`\n Update available: ${A(e)} → ${j(E(n.latestVersion))}\n Run ${j(`npm i -g gitpick`)} to update\n`))}function Cr(){let e=yr();e&&Date.now()-e.lastCheck<864e5||setTimeout(async()=>{let e=await xr();e&&br({lastCheck:Date.now(),latestVersion:e})},0)}const wr=Symbol(`singleComment`),Tr=Symbol(`multiComment`),Z=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),Er=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function Dr(e){if(typeof e!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let t=!1,n=!1,r=0,i=``,a=``,o=-1;for(let s=0;s<e.length;s++){let c=e[s],l=e[s+1];if(!n&&c===`"`&&(Er(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=wr,s++;else if(n===wr&&c+l===`\r
|
|
20
20
|
`){s++,n=!1,i+=Z(e,r,s),r=s;continue}else if(n===wr&&c===`
|
|
21
21
|
`)n=!1,i+=Z(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=Tr,s++;continue}else if(n===Tr&&c+l===`*/`){s++,n=!1,i+=Z(e,r,s+1),r=s+1;continue}else n||(o===-1?c===`,`&&(a+=i+e.slice(r,s),i=``,r=s,o=s):c===`}`||c===`]`?(i+=e.slice(r,s),a+=Z(i,0,1)+i.slice(1),i=``,r=s,o=-1):c!==` `&&c!==` `&&c!==`\r`&&c!==`
|
|
22
|
-
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===wr?Z(e,r):e.slice(r);return a+i+s}const Or=[`.gitpick.json`,`.gitpick.jsonc`],kr=async()=>{let t;for(let r of Or){let i=n.resolve(r);if(e.existsSync(i)){t=i;break}}if(!t)return!1;let r=await e.promises.readFile(t,`utf-8`),i=JSON.parse(Dr(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${n.basename(t)} must be an array of strings`);for(let e of i)await C(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var Ar=`gitpick`,Q=`6.1.0-canary.
|
|
22
|
+
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===wr?Z(e,r):e.slice(r);return a+i+s}const Or=[`.gitpick.json`,`.gitpick.jsonc`],kr=async()=>{let t;for(let r of Or){let i=n.resolve(r);if(e.existsSync(i)){t=i;break}}if(!t)return!1;let r=await e.promises.readFile(t,`utf-8`),i=JSON.parse(Dr(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${n.basename(t)} must be an array of strings`);for(let e of i)await C(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var Ar=`gitpick`,Q=`6.1.0-canary.21`;const jr=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Mr=`
|
|
23
23
|
With ${E(`${jr(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub, GitLab, Bitbucket and Codeberg!
|
|
24
24
|
|
|
25
25
|
$ gitpick ${A(`<url>`)} ${k(`[target]`)} ${j(`[options]`)}
|