bisgit 0.0.0 → 0.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/README.md CHANGED
@@ -1,3 +1,46 @@
1
1
  # Bisgit
2
2
 
3
- <img alt="biscuit with jelly" src="./public/bisgit.png" width="200px" />
3
+ <img alt="biscuit with jelly" src="https://github.com/alexanderdombroski/bisgit/blob/main/public/bisgit.png" width="200px" />
4
+
5
+ Full Tui coming soon
6
+
7
+ ## Commands
8
+
9
+ ### Commit Tooling
10
+
11
+ - `git sha <commit>` copies the shortend sha to clipboard (uses HEAD as default)
12
+ - `git amend` commits with `--no-edit` and `--amend`. Accepts extra flags too.
13
+ - `git fixup <commit>` commits staged changes as aa rebase, and starts an interactive rebase on the target commit if it would not fail.
14
+ - `git savepoint` makes a WIP commit with current timestamp.
15
+
16
+ ### Merge Helpers
17
+
18
+ - `git backmerge <branch>` updates a branch and then merges it into the current branch.
19
+ - `git conflict <branch>` shows all conflicts that would occur in a merge.
20
+ - `git abort` and `git continue` are useful in conflict resolution situations.
21
+ - `git lines <branch> <ignore-file> <ignore-file> ...*` shows the number of lines changed.
22
+
23
+ ### Branching
24
+
25
+ - `git autoprune` deletes any already merged branches.
26
+ - `git rebranch` If conflicts won't exist, create new branch from main and cherry-pick all commits from $
27
+ - `git track <branch>` copies a remote branch to a local one and sets the origin upstream.
28
+ - `git yank` is a force pull for the current branch. It commits a WIP commit and/or backup branch if commits don't exist in remote. Then it resets the local branch to match the remote. Useful way to handle a collaborator's force push.
29
+
30
+ ### Github
31
+
32
+ - `git code-review <pr>` checks out a pr and creates a diff similar to github's code review diff viewer.
33
+ - `git whoami` shows github username.
34
+ - `git languages` prints the percentages of languages for this repo.
35
+ - `git coauthor <username>` commits with a co-authorship description.
36
+
37
+ ### Utility
38
+
39
+ - `git pwd` shows repo root path.
40
+ - `git wipe` clears all uncommitted trackable files
41
+ - `git files <commit>` shows the files edited by the given commit.
42
+ - `git churn` shows you the 25 most edited files.
43
+ - `git exclude` and `git include` allows you to ignore files locally without modifying the .gitignore file.
44
+ - `git remote-default` shows whether the remote default branch is 'main', 'master', etc.
45
+
46
+ I turned many of my git aliases into commands. The original aliases are found this [gist](https://gist.github.com/alexanderdombroski/ddac491daeff48c5f1346ba2960462fa).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{exec as d,spawn as l}from"node:child_process";import{promisify as g}from"node:util";function f(e,i,r){let n=l(e,i,r??{});r?.silent||(n.stdout?.on("data",o=>{console.log(String(o))}),n.stderr?.on("data",o=>{console.error(String(o))})),n.on("close",o=>{r?.triggerExit&&process.exit(o)})}var w=g(d);async function x(e,i,r={}){let{promise:n,resolve:o,reject:c}=Promise.withResolvers(),t=l(e,i,r),p="",a="";return t.stdout?.on("data",s=>p+=s),t.stderr?.on("data",s=>a+=s),t.on("close",s=>o({code:s,stdout:p,stderr:a})),t.on("error",s=>c(s)),n}async function h(e,i="inherit"){let{promise:r,resolve:n,reject:o}=Promise.withResolvers(),c=l("git",["-c","color.ui=always",...e],{stdio:i});return c.on("close",t=>{t===0?n({code:t}):o({code:t})}),c.on("error",o),r}export{f as a,w as b,x as c,h as d};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{b as h,c as V}from"./chunk-5WTQIRZS.js";import{a as P,b as n,c as g,d as l}from"./chunk-HCUVDNFV.js";import A from"node:path";import{normalize as z}from"node:path";async function u(){let{stdout:t}=await n("git branch --show-current");return t.trim()}async function K(t){t??=await u();let{stdout:e}=await n(`git config --get branch.${t}.remote`);return e.trim()}async function B(t,e){try{let{stdout:r}=await n(`git rev-list --count ${t}/${e}..${e}`);return parseInt(r.trim(),10)}catch(r){return console.error("Error getting commits ahead:",r),NaN}}async function k(t,e){try{let{stdout:r}=await n(`git rev-list --count ${e}..${t}/${e}`);return parseInt(r.trim(),10)}catch(r){return console.error("Error getting commits behind:",r),NaN}}async function D(t){let{stdout:e}=await n(`git rev-parse --git-path ${t}`);return z(e.trim())}async function J(){let{stdout:t}=await n("git rev-parse --git-dir");return z(t.trim())}async function Z(t){let{code:e}=await g("git",["remote","get-url",t],{stdio:"ignore"});return e===0}async function Q(){let{stdout:t}=await n("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function H(t,e){let r="git fetch";t&&(r+=` ${t}`),e&&(r+=` ${e}`),await n(r)}async function w(){let{stdout:t}=await g("git",["status","--porcelain"]);return!t?.trim()}async function G(){let{stdout:t}=await g("git",["status","--porcelain"]);return t?.trim()?.split(/\r?\n/)}async function $(t,e){let{stdout:r}=await n(`git merge-base ${t} ${e}`);return r.trim()}async function X(t,e){let r=await $(t,e),{stdout:o}=await g("git",["merge-tree",r,e,t]);return!o?.split(/\r?\n/)?.includes("+=======")}async function tt(t){let{stdout:e}=await n(`git rev-parse ${t}`);return e.trim()}async function N(t,e,r){let{stdout:o}=await n(`git rev-list ${r?"--reverse":""} ${t}..${e}`);return o.trim().split(/\r?\n/)}async function et(){let{stdout:t}=await n("git for-each-ref --format='%(refname:short)' refs/heads");return t.trim().split(/\r?\n/)}import Ft from"fs/promises";async function d(t){try{return await Ft.access(t),!0}catch{return!1}}async function rt(){let t=await G(),e=/^(UU|DU|UD)/;return!!t?.some(r=>e.test(r))}async function W(){let t=await J(),[e,r,o,i,s]=await Promise.all([await d(A.join(t,"MERGE_HEAD")),await d(A.join(t,"rebase-merge")),await d(A.join(t,"rebase-apply")),await d(A.join(t,"CHERRY_PICK_HEAD")),await d(A.join(t,"REVERT_HEAD"))]);return{merge:e,rebaseMerge:r,rebaseApply:o,cherryPick:i,revert:s}}async function ot(){let{merge:t,rebaseMerge:e,rebaseApply:r,cherryPick:o,revert:i}=await W(),s="";if(t)s="merge";else if(e||r)s="rebase";else if(o)s="cherry-pick";else if(i)s="revert";else{let a=await rt()?"Conflicts exist, but likely are from a stash and are not abortable. Resolve them manually.":"Nothing to abort.";console.log(a);return}console.log(`Aborting the ${s}`),await l([s,"--abort"])}function it(){P("git",["commit","--amend","--no-edit",...h()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as Vt}from"ink";import{spawnSync as nt}from"node:child_process";function E(t,e,r){let{status:o}=nt(t,e,{stdio:"ignore"});o!==0&&(r&&console.error(r),process.exit(1))}var st=()=>E("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),v=()=>E("git",["rev-parse","HEAD"],"Need to create first commit."),y=(t="origin")=>E("git",["remote","get-url",t],`Need to add remote '${t}'.`),U=t=>E("git",["show-ref","--branches",t],`Branch '${t}' isn't tracked locally and may not exist.`),R=async()=>{await w()||(console.error("You should stash or commit your changes first."),process.exit(1))},F=async t=>{await d(t)||(console.error(`${t} must exist for this operation and it doesn't for some reason`),process.exit(1))},at=async()=>{await Q()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},ct=t=>E("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${t}@{u}`],`branch '${t}' has no upstream`);function b(t="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(t),process.exit(1)}async function M(){let{status:t}=nt("git",["diff","--staged","--quiet"],{stdio:"ignore"});t===0&&(console.error("You have no staged changes"),process.exit(1))}import{render as _t}from"ink";import{Suspense as Mt,use as Lt,useEffect as Tt}from"react";import{Text as mt,useApp as It}from"ink";import Ut from"ink-spinner";import{jsx as L,jsxs as jt}from"react/jsx-runtime";function c(t){let{msg:e}=t;return L(Mt,{fallback:jt(mt,{children:[L(Ut,{type:"dots"}),"\xA0",e]}),children:L(Ot,{...t})})}function Ot({msg:t,promise:e}){let r=Lt(e),{exit:o}=It();return Tt(()=>{o()},[r]),L(mt,{children:`\u2714 ${typeof r=="string"?r:t}`})}import{jsx as Yt}from"react/jsx-runtime";async function lt(){let t=process.argv[3],e=process.argv[4]??await u();if(U(t),U(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let r=await K(t);y(r),_t(Yt(c,{msg:"Updating target branch and merging",promise:(async()=>{try{await S(r,t)}catch{console.error(`Error when updating branch ${t} with remote ${r}. Fix divergent branches before merging into ${e}`);return}await u()!==e&&await n(`git switch ${e}`),P("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function S(t,e){await H(t,e);let[r,o,i]=await Promise.all([B(t,e),k(t,e),u()]);if(o!==0){if(r===0&&i!==e){await n(`git fetch ${t} ${e}:${e}`);return}if(await n(`git switch ${e}`),r===0){await n(`git merge ${t}/${e}`);return}await l(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}async function q(){v(),y();let{stdout:t,code:e}=await g("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(e===0)return ft(t.trim());await n("git remote set-head origin -a");let{stdout:r}=await n("git rev-parse --abbrev-ref origin/HEAD");return ft(r.trim())}async function pt(){let{remote:t,branch:e}=await q();console.log(`Remote default branch is '${t}/${e}'`)}async function ft(t){let e=t.split("/"),r=t.split("/").map((o,i)=>e.slice(0,i+1).join("/"));for(let o of r)if(await Z(o)){let i=t.slice(o.length+1);return{remote:o,branch:i}}throw new Error("Failed to get default remote")}import{jsx as Kt}from"react/jsx-runtime";var zt=["master","main","development","lingoport"];async function gt(){await R();let{branch:t,remote:e}=await q();await n(`git switch ${t}`);let r=(async()=>{await l(["fetch","--prune","--prune-tags"]),await S(e,t)})();Vt(Kt(c,{msg:"Fetching and pruning remote references",promise:r})),await r;let o=await et();for(let i of o){if(i===t||zt.includes(i))continue;let s=await $(i,t),{code:a}=await g("git",["diff","--quiet",s,i]);a===0&&await l(["branch","-D",i])}}import{spawn as Jt}from"node:child_process";import{createInterface as Zt}from"node:readline/promises";async function ut(){v;let e=[...(await Qt()).entries()].sort(([,o],[,i])=>i-o).slice(0,25),r=e[0][1].toString().length;console.info(e.map(([o,i])=>`${String(i).padEnd(r)} ${o}:`).join(`
3
+ `))}async function Qt(){let{promise:t,resolve:e,reject:r}=Promise.withResolvers(),o=new Map,i=Jt("git",["log","--all","-M","-C","--name-only","--format=format:"]),s=Zt({input:i.stdout,crlfDelay:1/0});return s.on("line",a=>{let m=a.trim();m&&o.set(m,(o.get(m)??0)+1)}),s.on("close",()=>e(o)),i.on("error",r),t}import{render as Xt}from"ink";import{jsx as ee}from"react/jsx-runtime";async function ht(){await M();let t=b("Error: missing github username argument"),e=(async()=>{let i=await te(t);return i.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),i})();Xt(ee(c,{msg:"Fetching name and email",promise:e}));let{name:r,email:o}=await e;l(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${r} <${o}>`])}async function te(t){let{stdout:e}=await n(`gh api users/${t}`);return JSON.parse(e.trim())}import{render as O}from"ink";import{isDeepStrictEqual as re}from"node:util";import{jsx as j}from"react/jsx-runtime";async function wt(){let t=b("Error: missing id of PR to checkout");await R();let e=(async()=>Promise.all([n(`gh co ${t}`),n(`gh pr view ${t} --json baseRefName -q .baseRefName`)]))();O(j(c,{msg:`Checking out pr #${t}`,promise:e}));let[,{stdout:r}]=await e,o=r.trim(),i=(async()=>{await n(`git switch ${o}`),await n("git pull"),await n("git switch -")})();O(j(c,{msg:`Updating ${o} branch merge destination`,promise:i})),await i;let s=(async()=>{let p=await $(o,"HEAD");return await n(`git reset ${p} --soft`),await oe("HEAD")})();O(j(c,{msg:"Creating an editable, explorable, local PR experience",promise:s}));let[a,m]=await Promise.all([s,ie(t)]),{files:f,additions:x,deletions:I}=m;if(re(a,m))return console.info(`Files: ${f}, +${x} -${I}`);console.info("The PR stat doesn't match the local stat."),console.info("LOCAL"),console.table(a),console.info("GITHUB"),console.table(m),console.info("One option to fix (there'll likely be conflicts):"),console.info("1. git stash -u"),console.info(`2. git merge ${o}`),console.info("3. git stash pop")}async function oe(t){let{stdout:e}=await n(`git diff --shortstat ${t}`),r=/(\d+)\s+files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/,o=e.trim().match(r);if(!o)throw new Error(`Couldn't generate short stat for ref(s): ${t}`);let[,i,s,a]=o;return{files:parseInt(i,10),additions:s?parseInt(s,10):0,deletions:a?parseInt(a,10):0}}async function ie(t){let{stdout:e}=await n(`gh pr view ${t} --json deletions,files,additions`),r=JSON.parse(e.trim());return r.files=r.files.length,r}import{spawn as ne}from"node:child_process";import{createInterface as se}from"node:readline/promises";import _ from"chalk";async function dt(){let t=b("Error: missing target branch argument"),e=await $("HEAD",t),{promise:r,resolve:o,reject:i}=Promise.withResolvers(),s=ne("git",["merge-tree",e,"HEAD",t]),a=se({input:s.stdout,crlfDelay:1/0}),m=!1,f=0;a.on("line",p=>{p=p.trimEnd(),p==="+<<<<<<< .our"?(m=!0,console.info(_.red(p)),f+=1):p==="+>>>>>>> .their"?(m=!1,console.info(_.green(p))):p==="+======="?console.info(_.yellow(p)):m&&console.info(p)}),a.on("close",()=>o(f)),s.on("error",i);let x=await r,I=x?`\u274C ${x} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(I)}async function yt(){let{merge:t,rebaseMerge:e,rebaseApply:r,cherryPick:o,revert:i}=await W(),s="";if(t)s="merge";else if(e||r)s="rebase";else if(o)s="cherry-pick";else if(i)s="revert";else{console.log("Nothing to continue.");return}console.log(`Continuing the ${s}`),await l([s,"--continue"])}import{appendFileSync as ce}from"node:fs";import{readFile as ae}from"node:fs/promises";async function T(t){return(await ae(t,"utf-8")).split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#"))}async function bt(){let t=await D("info/exclude");await F(t);let e=await T(t);h().forEach(r=>{e.includes(r)?console.info(`Already Exists: '${r}'`):(ce(t,`${r}
4
+ `),console.info(`Added '${r}'`))}),console.info(`
5
+ See file at ${t}`)}function $t(){P("git",["show","--name-only","--pretty=format:",...h()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{spawn as me}from"node:child_process";async function xt(){let t=b("Error: missing valid target ref argument");await M();let e=await tt(t);await l(["commit",`--fixup=${e}`]);let o=(await N(`${e}^`,"HEAD",!0)).map(s=>le(s));(await Promise.all(o)).every(Boolean)||(console.warn("Rebase conflict would occur!"),await n("git reset HEAD~1 --soft"),process.exit(1)),await n(`git rebase -i --autosquash ${e}^`)}async function le(t){let{stdout:e}=await n(`git diff ${t}^ ${t}`),{promise:r,resolve:o,reject:i}=Promise.withResolvers(),s=me("git",["apply","--check","--3way","-q"],{stdio:["pipe","ignore","ignore"]});return s.on("close",a=>{o(a===0)}),s.on("error",i),s.stdin.write(e),s.stdin.end(),r}import{readFile as fe,writeFile as pe}from"node:fs/promises";async function Pt(){let t=await D("info/exclude");await F(t);let e=await T(t),r=h();r.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let i=(await fe(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),s=i.filter(a=>!r.includes(a));await pe(t,s.join(`
6
+ `)),console.info(`
7
+ Removed ${i.length-s.length} entries from ${t}`)}import{render as ge}from"ink";import{jsx as de}from"react/jsx-runtime";async function vt(){let t=(async()=>{let i=await ue();return await he(i)})();ge(de(c,{msg:"Fetching repo languages",promise:t}));let e=await t,r=Object.values(e).reduce((i,s)=>i+s,0),o=Object.entries(e).map(([i,s])=>`${i}: ${Math.round(s/r*100)}% - ${we(s)}`);console.log(o.join(`
8
+ `))}async function ue(){let{stdout:t}=await n("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function he(t){let{stdout:e}=await n(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function we(t,e=2){if(t===0)return"0 B";let r=1024,o=e<0?0:e,i=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],s=Math.floor(Math.log(t)/Math.log(r));return`${parseFloat((t/Math.pow(r,s)).toFixed(o))} ${i[s]}`}import{execSync as ye}from"node:child_process";function be(){return ye("git rev-parse --show-toplevel",{encoding:"utf-8"}).trim()}function Rt(){let t=be();console.log(t)}import{render as Dt}from"ink";function Ct(){return new Date().toLocaleString("en-US",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(",","")}async function C(){let t=Ct();await n("git add -A"),await l(["commit","-m",`"WIP ${t}"`])}import{nanoid as $e}from"nanoid";import xe from"chalk";import{jsx as At}from"react/jsx-runtime";async function Et(){let{remote:t,branch:e}=await q(),r=process.argv[3]??e;await w()||await C(),await X(r,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let o=await u(),i=(async()=>{await S(t,r)})();Dt(At(c,{msg:`Updating branch ${r}`,promise:i})),await i;let s=`${$e(8)}`,a=(async()=>{await n(`git switch ${o}`),await n(`git branch ${s}`),await n(`git switch ${r}`),await n(`git branch -D ${o}`),await n(`git switch -c ${o}`);let m=await N(r,s,!0);for(let f of m)try{await n(`git cherry-pick ${f}`)}catch{let x=xe.yellow(`git branch -D ${o} && git branch -m ${s} ${o}`);throw new Error(`\u274C cherry pick failed at ${f}
9
+ Run this to restore backup branch
10
+ > ${x}`)}await n(`git branch -D ${s}`)})();Dt(At(c,{msg:`Rewriting branch ${o}`,promise:a})),await a,console.info(`Successfully recreated branch ${o} from ${r}`)}import{execSync as Pe}from"node:child_process";async function St(){v();let t=ve(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function ve(t="HEAD"){return Pe(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as Re}from"ink";import{jsx as Ce}from"react/jsx-runtime";async function qt(){let{remote:t,branch:e}=await V();y(t),await R();let r=H(t,e);Re(Ce(c,{msg:`Fetching branch ${e} from ${t}`,promise:r})),await r,await l(["switch","-c",e,"--track",`${t}/${e}`])}async function Bt(){let[t,e]=await Promise.allSettled([await Ae("user.name"),await De()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function De(){let{stdout:t}=await n("gh api user --jq .login");return t.trim()}async function Ae(t){let{stdout:e}=await n(`git config ${t}`);return e.trim()}import{render as Ge}from"ink";import{Text as Ee,useApp as Se,useInput as qe}from"ink";import{useState as Be}from"react";import{Fragment as He,jsx as ke,jsxs as kt}from"react/jsx-runtime";function Ht({prompt:t,msg:e,onConfirm:r}){let[o,i]=Be(""),{exit:s}=Se();return qe((a,m)=>{if(o)return;let f=a.toLowerCase();f==="y"?i("Yes"):(f==="n"||m.return)&&(i("No"),s())}),kt(He,{children:[kt(Ee,{children:[t," [y/N] ",o]}),o==="Yes"&&ke(c,{msg:e,promise:r()})]})}import{jsx as Ne}from"react/jsx-runtime";async function Gt(){if(st(),await w())return console.log("Already a clean working tree");let t=await G();if(!t)throw new Error("git status cmd failed");let e=new Y(t);e.displayReport(),Ge(Ne(Ht,{prompt:"Approve these changes?",msg:"Running git reset && git clean",onConfirm:async()=>(await n("git reset --hard"),await n("git clean -f"),`Altered ${e.willDelete.length+e.willRecreate.length+e.willRevert.length} files.`)}))}var Y=class{willDelete=[];willRecreate=[];willRevert=[];constructor(e){e.forEach(r=>{if(r){let o=r.slice(0,2).trim(),i=r.slice(3);o.includes("?")||o.includes("A")?this.willDelete.push(i):o==="DU"||o==="D"?this.willRecreate.push(i):this.willRevert.push(i)}}),this.willDelete.sort(),this.willRecreate.sort(),this.willRevert.sort()}displayReport(){this.displaySection("Will Recreate:",this.willRecreate),this.displaySection("Will Revert:",this.willRevert),this.displaySection("Will Delete:",this.willDelete)}displaySection(e,r){r.length&&console.log(`${e}
11
+ ${r.map(o=>`- ${o}
12
+ `)}`)}};import{nanoid as We}from"nanoid";import{render as Fe}from"ink";import{jsx as Me}from"react/jsx-runtime";async function Nt(){await at();let t=process.argv[3]??"origin";y(t);let e=await u();ct(e);let r="",i=(async()=>{let s=[n(`git fetch ${t} ${e} --force`)];await w()||s.push(C()),await Promise.all(s);let[a,m]=await Promise.all([B(t,e),k(t,e)]);if(!(a===0&&m===0)){if(a!==0){let f=`${e}-${We(8)}`;r=`Created branch ${f}`,await n(`git branch ${f}`)}await n(`git reset --hard ${t}/${e}`)}})();Fe(Me(c,{msg:`Force pull reseting ${e} -> ${t}`,promise:i})),await i,r&&console.info(r)}var Wt={abort:ot,amend:it,autoprune:gt,backmerge:lt,churn:ut,coauthor:ht,"code-review":wt,conflict:dt,continue:yt,exclude:bt,files:$t,fixup:xt,include:Pt,languages:vt,pwd:Rt,rebranch:Et,"remote-default":pt,savepoint:C,sha:St,track:qt,whoami:Bt,wipe:Gt,yank:Nt};async function Zi(t){return await Wt[t]?.(),Object.hasOwn(Wt,t)}export{Zi as runCommand};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as r}from"./chunk-5RER3IEO.js";var i=["init","clone","add","status","diff","commit","restore","reset","branch","checkout","switch","merge","log","stash","tag","worktree","fetch","pull","push","remote","submodule","show","apply","cherry-pick","rebase","revert","bisect","blame","grep","clean","fsck","reflog","bundle","daemon","cat-file","check-ignore","checkout-index","commit-tree","count-objects","diff-index","for-each-ref","hash-object","ls-files","ls-tree","merge-base","read-tree","rev-list","rev-parse","show-ref","symbolic-ref","update-index","update-ref","verify-pack","write-tree","column"];function t(e){return i.includes(e)}var n=["auth","browse","codespace","gist","issue","org","pr","project","release","repo","cache","run","workflow","agent-task","alias","api","attestation","completion","config","extension","gpg-key","label","preview","ruleset","search","secret","ssh-key","status","variable"];function s(e){return n.includes(e)}var o=e=>{r(e,process.argv.slice(2),{stdio:"inherit",silent:!0})};async function f(e){return t(e)?(o("git"),!0):s(e)?(o("gh"),!0):!1}export{f as runWrapper};
2
+ import{a as r}from"./chunk-HCUVDNFV.js";var i=["init","clone","add","status","diff","commit","restore","reset","branch","checkout","switch","merge","log","stash","tag","worktree","fetch","pull","push","remote","submodule","show","apply","cherry-pick","rebase","revert","bisect","blame","grep","clean","fsck","reflog","bundle","daemon","cat-file","check-ignore","checkout-index","commit-tree","count-objects","diff-index","for-each-ref","hash-object","ls-files","ls-tree","merge-base","read-tree","rev-list","rev-parse","show-ref","symbolic-ref","update-index","update-ref","verify-pack","write-tree","column"];function t(e){return i.includes(e)}var n=["auth","browse","codespace","gist","issue","org","pr","project","release","repo","cache","run","workflow","agent-task","alias","api","attestation","completion","config","extension","gpg-key","label","preview","ruleset","search","secret","ssh-key","status","variable"];function s(e){return n.includes(e)}var o=e=>{r(e,process.argv.slice(2),{stdio:"inherit",silent:!0})};async function f(e){return t(e)?(o("git"),!0):s(e)?(o("gh"),!0):!1}export{f as runWrapper};
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as t}from"./chunks/chunk-5WTQIRZS.js";async function e(){let n=t();if(!n){let{renderApp:i}=await import("./chunks/demo-PL6P4QST.js");return i()}let{runCommand:o}=await import("./chunks/commands-V2SGZOKB.js");if(await o(n))return;let{runWrapper:r}=await import("./chunks/wrapper-UX2PKFOA.js");await r(n)||(console.error("unknown command"),process.exit(1))}e().catch(n=>{typeof n=="object"&&(n=JSON.stringify(n,void 0,2)),console.error(`An error occurred: ${n}`),process.exit(1)});
2
+ import{a as n}from"./chunks/chunk-5WTQIRZS.js";async function a(){let r=n();if(!r){let{renderApp:e}=await import("./chunks/demo-PL6P4QST.js");return e()}let{runCommand:o}=await import("./chunks/commands-AR5RPPHV.js");if(await o(r))return;let{runWrapper:t}=await import("./chunks/wrapper-5X5SODCK.js");await t(r)||(console.error("unknown command"),process.exit(1))}a().catch(r=>{console.error(`An error occurred: ${r.stderr??r.message}`),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bisgit",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "Git CLI tool to simplify common advanced git workflows",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -33,8 +33,8 @@
33
33
  "build": "node esbuild.mjs --watch",
34
34
  "package": "rm -rf dist && node esbuild.mjs --production",
35
35
  "profile": "npm-run-all -p profile:*",
36
- "profile:size": "esbuild-visualizer --metadata ./profile/meta.json --filename ./profile/visualizer.html && open ./profile/visualizer.html",
37
- "profile:lazy": "esbuild-lazy-analyzer --metafile ./profile/meta.json --outmeta ./profile/lazy.json --outreport ./profile/lazy.html && open ./profile/lazy.html",
36
+ "profile:size": "esbuild-visualizer --metadata ./profile/meta.json --filename ./profile/visualizer.html && open ./profile/visualizer.html",
37
+ "profile:lazy": "esbuild-lazy-analyzer --metafile ./profile/meta.json --outmeta ./profile/lazy.json --outreport ./profile/lazy.html && open ./profile/lazy.html",
38
38
  "gi": "npm run package && node dist/main.js",
39
39
  "lint": "eslint src",
40
40
  "check-types": "tsc --noEmit",
@@ -56,9 +56,11 @@
56
56
  "prettier": "^3.7.4"
57
57
  },
58
58
  "dependencies": {
59
+ "chalk": "^5.6.2",
59
60
  "clipboardy": "^5.0.2",
60
61
  "ink": "^6.6.0",
61
62
  "ink-spinner": "^5.0.0",
63
+ "nanoid": "^5.1.6",
62
64
  "react": "^19.2.3",
63
65
  "react-devtools-core": "^6.1.5"
64
66
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{spawn as l}from"node:child_process";function p(r,s,o){let n=l(r,s,o??{});o?.silent||(n.stdout?.on("data",t=>{console.log(String(t))}),n.stderr?.on("data",t=>{console.error(String(t))})),n.on("close",t=>{o?.triggerExit&&process.exit(t)})}async function a(r,s="inherit"){let{promise:o,resolve:n,reject:t}=Promise.withResolvers(),i=l("git",["-c","color.ui=always",...r],{stdio:s});return i.on("close",e=>{e===0?n({code:e}):t({code:e})}),i.on("error",t),o}export{p as a,a as b};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as e,c as v}from"./chunk-5WTQIRZS.js";import{a as n,b as s}from"./chunk-5RER3IEO.js";function P(){n("git",["commit","--amend","--no-edit",...e()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{exec as X}from"node:child_process";import{exec as O}from"node:child_process";import{normalize as U}from"node:path";import{promisify as z}from"node:util";var c=z(O);async function f(){let{stdout:t}=await c("git branch --show-current");return t.trim()}async function A(t){t??=await f();let{stdout:r}=await c(`git config --get branch.${t}.remote`);return r.trim()}async function b(t,r){try{let{stdout:o}=await c(`git rev-list --count ${t}/${r}..${r}`);return parseInt(o.trim(),10)}catch(o){return console.error("Error getting commits ahead:",o),NaN}}async function R(t,r){try{let{stdout:o}=await c(`git rev-list --count ${r}..${t}/${r}`);return parseInt(o.trim(),10)}catch(o){return console.error("Error getting commits behind:",o),NaN}}async function u(t){let{stdout:r}=await c(`git rev-parse --git-path ${t}`);return U(r.trim())}import{spawnSync as V}from"node:child_process";import K from"fs/promises";async function q(t){try{return await K.access(t),!0}catch{return!1}}function x(t,r,o){V(t,r,{stdio:"ignore"}).status!==0&&(o&&console.error(o),process.exit(1))}var l=()=>x("git",["rev-parse","HEAD"],"Need to create first commit."),m=(t="origin")=>x("git",["remote","get-url",t],`Need to add remote '${t}'.`),y=t=>x("git",["show-ref","--branches",t],`Branch '${t}' isn't tracked locally and may not exist.`);var d=async t=>{await q(t)||(console.error(`${t} must exist for this operation and it doesn't for some reason`),process.exit(1))};import{render as _}from"ink";import{Suspense as Y,use as Z}from"react";import{Text as C}from"ink";import j from"ink-spinner";import{jsx as h,jsxs as Q}from"react/jsx-runtime";function S(t){let{msg:r}=t;return h(Y,{fallback:Q(C,{children:[h(j,{type:"dots"}),"\xA0",r]}),children:h(J,{...t})})}function J({msg:t,promise:r}){return Z(r),h(C,{children:`\u2714 ${t}`})}import{promisify as M}from"node:util";import{jsx as rt}from"react/jsx-runtime";var p=M(X);async function E(){let t=process.argv[3],r=process.argv[4]??await f();if(y(t),y(r),t===r)return console.log(`No reason to merge '${t}' into '${r}'`);let o=await A(t);m(o),_(rt(S,{msg:"Updating target branch and merging",promise:(async()=>{try{await tt(o,t)}catch{console.error(`Error when updating branch ${t} with remote ${o}. Fix divergent branches before merging into ${r}`);return}await f()!==r&&await p(`git switch ${r}`),n("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function tt(t,r){await p(`git fetch ${t} ${r}`);let[o,g,a]=await Promise.all([b(t,r),R(t,r),f()]);if(g!==0){if(o===0&&a!==r){await p(`git fetch ${t} ${r}:${r}`);return}if(await p(`git switch ${r}`),o===0){await p(`git merge ${t}/${r}`);return}await s(["merge",`${t}/${r}`],["ignore","ignore","inherit"])}}import{appendFileSync as et}from"node:fs";import{readFile as ot}from"node:fs/promises";async function w(t){return(await ot(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function D(){let t=await u("info/exclude");await d(t);let r=await w(t);e().forEach(o=>{r.includes(o)?console.info(`Already Exists: '${o}'`):(et(t,`${o}
3
- `),console.info(`Added '${o}'`))}),console.info(`
4
- See file at ${t}`)}function F(){n("git",["show","--name-only","--pretty=format:",...e()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{readFile as it,writeFile as nt}from"node:fs/promises";async function B(){let t=await u("info/exclude");await d(t);let r=await w(t),o=e();o.filter(i=>!r.includes(i)).forEach(i=>console.info(`No match: '${i}'`));let a=(await it(t,"utf-8")).split(/\r?\n/).map(i=>i.trim()),$=a.filter(i=>!o.includes(i));await nt(t,$.join(`
5
- `)),console.info(`
6
- Removed ${a.length-$.length} entries from ${t}`)}import{execSync as st}from"node:child_process";function mt(){return st("git rev-parse --show-toplevel",{encoding:"utf-8"}).trim()}function N(){let t=mt();console.log(t)}import{execSync as k,spawnSync as at}from"node:child_process";function ct(){l(),m();let t=at("git",["rev-parse","--abbrev-ref","origin/HEAD"],{encoding:"utf-8"});return t.status===0?t.stdout.trim():(k("git remote set-head origin -a",{stdio:"ignore"}),k("git rev-parse --abbrev-ref origin/HEAD",{encoding:"utf-8"}).trim())}function G(){let t=ct();console.log(`Remote default branch is '${t}'`)}import{exec as ft}from"node:child_process";function W(){return new Date().toLocaleString("en-US",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(",","")}import{promisify as pt}from"node:util";var gt=pt(ft);async function I(){let t=W();await gt("git add -A"),await s(["commit","-m",`"WIP ${t}"`])}import{execSync as ut}from"node:child_process";import lt from"clipboardy";async function T(){l();let t=dt(process.argv[3]);await lt.write(t),console.log(`'${t}' copied to clipboard`)}function dt(t="HEAD"){return ut(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}async function L(){let{remote:t,branch:r}=await v();m(t),await s(["switch","-c",r,"--track",`${t}/${r}`])}var H={amend:P,backmerge:E,exclude:D,files:F,include:B,pwd:N,"remote-default":G,savepoint:I,sha:T,track:L};async function Ir(t){return await H[t]?.(),Object.hasOwn(H,t)}export{Ir as runCommand};