bisgit 0.0.0 → 0.2.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
+ - `gi sha <commit>` copies the shortend sha to clipboard (uses HEAD as default)
12
+ - `gi amend` commits with `--no-edit` and `--amend`. Accepts extra flags too.
13
+ - `gi fixup <commit>` commits staged changes as aa rebase, and starts an interactive rebase on the target commit if it would not fail.
14
+ - `gi savepoint` makes a WIP commit with current timestamp.
15
+
16
+ ### Merge Helpers
17
+
18
+ - `gi backmerge <branch>` updates a branch and then merges it into the current branch.
19
+ - `gi conflict <branch>` shows all conflicts that would occur in a merge.
20
+ - `gi abort` and `gi continue` are useful in conflict resolution situations.
21
+ <!-- - `gi lines <branch> <ignore-file> <ignore-file> ...*` shows the number of lines changed. -->
22
+
23
+ ### Branching
24
+
25
+ - `gi autoprune` deletes any already merged branches.
26
+ - `gi rebranch` If conflicts won't exist, create new branch from main and cherry-pick all commits from $
27
+ - `gi track <branch>` copies a remote branch to a local one and sets the origin upstream.
28
+ - `gi 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
+ - `gi code-review <pr>` checks out a pr and creates a diff similar to github's code review diff viewer.
33
+ - `gi whoami` shows github username.
34
+ - `gi languages` prints the percentages of languages for this repo.
35
+ - `gi coauthor <username>` commits with a co-authorship description.
36
+
37
+ ### Utility
38
+
39
+ - `gi pwd` shows repo root path.
40
+ - `gi wipe` clears all uncommitted trackable files
41
+ - `gi files <commit>` shows the files edited by the given commit.
42
+ - `gi churn` shows you the 25 most edited files.
43
+ - `gi exclude` and `gi include` allows you to ignore files locally without modifying the .gitignore file.
44
+ - `gi 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{useStdout as h}from"ink";function i(){let{stdout:t}=h();return{width:t.columns,height:t.rows}}import{Box as d,Text as c}from"ink";import{jsx as r,jsxs as u}from"react/jsx-runtime";function a(t){let{title:o,footer:e,children:s,width:m}=t,{width:p}=i(),n=(m??p)-6;return u(d,{flexDirection:"column",children:[o&&r(c,{children:"\u256D\u2500\u2500\u2500\u2500"+o+"\u2500".repeat(n-o.length)+"\u256E"}),r(d,{flexDirection:"column",...t,borderStyle:"round",borderTop:!o,borderBottom:!e,paddingLeft:1,children:s}),e&&r(c,{children:"\u2570"+"\u2500".repeat(n-e.length)+e+"\u2500\u2500\u2500\u2500\u256F"})]})}export{i as a,a as b};
@@ -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};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as S,b as g}from"./chunk-EXTT6F3H.js";import{b as T}from"./chunk-HCUVDNFV.js";import{use as b}from"react";import{Box as a,Text as u,useInput as I}from"ink";import{useState as y}from"react";function D(t,e){let[r,l]=y(0),[m,d]=y(0),x=Math.max(0,t.length-e),p=t.length-1,h=()=>{d(w=>{let c=Math.min(w+1,p);return l(n=>c>=n+e?Math.min(n+1,x):n),c})},f=()=>{d(w=>{let c=Math.max(w-1,0);return l(n=>c<n?Math.max(n-1,0):n),c})},s=t.slice(r,r+e),i=t[m];return{scrollDown:h,scrollUp:f,outList:s,selectedIndex:m,selectedValue:i}}import{Fragment as v,jsx as o,jsxs as B}from"react/jsx-runtime";var L=(async()=>{let{stdout:t}=await T("git log --oneline -n 30");return t.trim().split(/\r?\n/).map(W)})(),M=(async()=>{let{stdout:t}=await T("git show HEAD --name-only");return t.trim()})();function A(){let{height:t,width:e}=S(),r=t-5,l=Math.floor(e/2),m=b(L),{scrollUp:d,scrollDown:x,outList:p,selectedValue:h}=D(m,r-2);I((s,i)=>{i.upArrow&&d(),i.downArrow&&x()});let f=b(M);return o(v,{children:B(a,{children:[o(g,{overflowY:"hidden",height:r,title:"Log",width:l,children:p.map(({sha:s,message:i})=>B(a,{flexDirection:"row",flexWrap:"nowrap",children:[o(a,{minWidth:2,children:s===h.sha?o(u,{children:"> "}):null}),o(a,{minWidth:8,children:o(u,{color:"yellow",children:s})}),o(a,{children:o(u,{wrap:"truncate-end",children:i})})]},s))}),o(g,{title:"Commit Details",width:l,children:o(u,{children:f})})]})})}function W(t){let e=t.indexOf(" ");return{sha:t.slice(0,e),message:t.slice(e+1)}}export{A as default};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{b as s}from"./chunk-EXTT6F3H.js";import{render as R}from"ink";import{createContext as m,useContext as x,useState as l}from"react";import{jsx as a}from"react/jsx-runtime";var y=m(void 0),o=({children:n})=>{let[r,i]=l({}),t=(u,f)=>{i(K=>({...K,[u]:f}))};return a(y.Provider,{value:{keybindings:r,setKeybinding:t},children:n})},p=()=>{let n=x(y);if(!n)throw new Error("useKeybindings must be used within a KeybindingsProvider");return n};import{lazy as v,Suspense as S,useEffect as k}from"react";import{Text as g,Box as P,useInput as C}from"ink";import h from"ink-spinner";import{jsx as e,jsxs as c}from"react/jsx-runtime";var T=v(()=>import("./log-HEHMTDVZ.js"));function w(){return e(s,{children:c(g,{children:[e(h,{}),"\xA0Loading"]})})}function b(){C((i,t)=>{i==="q"&&process.exit()});let{keybindings:n,setKeybinding:r}=p();return k(()=>r("q","quit"),[]),e(o,{children:c(P,{flexDirection:"column",children:[e(S,{fallback:e(w,{}),children:e(T,{})}),e(s,{flexDirection:"row",borderStyle:"round",title:"Key Shortcuts",children:Object.entries(n).map(([i,t])=>e(g,{children:`[${i}]: ${t}`},t))})]})})}import{jsx as d}from"react/jsx-runtime";function q(){return d(o,{children:d(b,{})})}var J=()=>R(d(q,{}),{patchConsole:!0});export{J as renderApp};
@@ -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/pages-G4MRQPYC.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.2.0",
4
4
  "description": "Git CLI tool to simplify common advanced git workflows",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -29,13 +29,13 @@
29
29
  "type": "module",
30
30
  "scripts": {
31
31
  "start": "node dist/main.js",
32
- "dev": "node esbuild.mjs && node dist/main.js",
32
+ "dev": "node --watch dist/main.js",
33
+ "gi": "npm run package && node dist/main.js",
33
34
  "build": "node esbuild.mjs --watch",
34
35
  "package": "rm -rf dist && node esbuild.mjs --production",
35
36
  "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",
38
- "gi": "npm run package && node dist/main.js",
37
+ "profile:size": "esbuild-visualizer --metadata ./profile/meta.json --filename ./profile/visualizer.html && open ./profile/visualizer.html",
38
+ "profile:lazy": "esbuild-lazy-analyzer --metafile ./profile/meta.json --outmeta ./profile/lazy.json --outreport ./profile/lazy.html && open ./profile/lazy.html",
39
39
  "lint": "eslint src",
40
40
  "check-types": "tsc --noEmit",
41
41
  "prepare": "husky"
@@ -43,8 +43,8 @@
43
43
  "devDependencies": {
44
44
  "@types/node": "^25.0.3",
45
45
  "@types/react": "^19.2.7",
46
- "@typescript-eslint/eslint-plugin": "^8.51.0",
47
- "@typescript-eslint/parser": "^8.51.0",
46
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
47
+ "@typescript-eslint/parser": "^8.52.0",
48
48
  "esbuild": "^0.27.2",
49
49
  "esbuild-lazy-analyzer": "^1.4.0",
50
50
  "esbuild-visualizer": "^0.7.0",
@@ -53,13 +53,15 @@
53
53
  "husky": "^9.1.7",
54
54
  "lint-staged": "^16.2.7",
55
55
  "npm-run-all": "^4.1.5",
56
- "prettier": "^3.7.4"
56
+ "prettier": "^3.7.4",
57
+ "react-devtools-core": "^6.1.5"
57
58
  },
58
59
  "dependencies": {
60
+ "chalk": "^5.6.2",
59
61
  "clipboardy": "^5.0.2",
60
62
  "ink": "^6.6.0",
61
63
  "ink-spinner": "^5.0.0",
62
- "react": "^19.2.3",
63
- "react-devtools-core": "^6.1.5"
64
+ "nanoid": "^5.1.6",
65
+ "react": "^19.2.3"
64
66
  }
65
67
  }
@@ -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};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{useState as x}from"react";import{Text as e,Box as c,useInput as p,render as i}from"ink";import{jsx as t,jsxs as n}from"react/jsx-runtime";var f=()=>{let[o,s]=x(0);return p((r,m)=>{r==="q"&&process.exit(),r==="+"&&s(o+1),r==="-"&&s(o-1)}),n(c,{flexDirection:"column",children:[t(e,{children:"\u{1F44B} Welcome to the Demo Ink App!"}),t(e,{children:"---------------------------------"}),n(e,{children:["Count: ",o]}),t(e,{children:'Press "+" to increase, "-" to decrease'}),t(e,{children:'Press "q" to quit'})]})},d=()=>i(t(f,{}));export{d as renderApp};