Skip to content

Commit cba31d9

Browse files
committed
feat(commands): add add-missing
1 parent a0a3416 commit cba31d9

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ As long as something looks enough like a command, the bartender will <i>probably
2525

2626
# 🍹 Usage
2727

28-
| Command | Description | Aliases | Usage/Examples |
29-
| ----------------------- | ---------------------------------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------- |
30-
| help | Shows the manual, so I can deal with less bullshit from you. | h | `gb help` <br> `gb help [command]` <br> `gb help [alias]` |
31-
| abort | What ya mom should've done years ago. Aborts a stuck process. | ab | `gb abort` |
32-
| discard | Wasted time on something that didn't work? | explode, dc | `gb discard` |
33-
| github | Things related to the Hub- shit. Walked myself right into that one. | gh | `gb github <subcommand>` |
34-
| github actions | Just pushed your changes? Want to watch the deployment fail? | a, action | `gb github actions` <br> `gb github actions [workflow]` <br> `gb github actions [workflow] --branch [branch]` <br> `gb github actions [workflow] -b [branch]` |
35-
| github pull-request | Open a pull request. What did you expect? | pr, pullrequest | `gb github pull-request` <br> `gb github pull-request <target_branch>` <br> `gb github pull-request <target_remote>/[target_branch]` <br> `gb github pull-request <target_remote>/[target_branch]:<from_remote>/[from_branch]` <br> <br>**Examples:** <br> `gb github pull-request dev` <br> `gb github pull-request upstream/main` <br> `gb github pull-request dev:staging` <br> `gb github pull-request dev:upstream/main` <br> `gb github pull-request /main:upstream/` |
36-
| ignore | Ignore your files, like ignoring your problems. | i | `gb ignore [...patterns]` <br> `gb ignore` (view ignored files) |
37-
| pet | Petting me? Seriously? | | `gb pet` |
38-
| unignore | Unignoring your problems now? Good for you. | u | `gb unignore [...patterns]` |
39-
| undo | Uncommits your commits because you have commitment issues. | ud | `gb undo [amount]` |
40-
| unstage | Did you fuckin' stage .env? Remove that! | unadd, !add | `gb unstage [...files]` |
41-
| what | Are you _really_ dumb enough to not know info about the project you're literally working on? | which | `gb what <subcommand>` |
42-
| what branch | Really? Did you **seriously** forget what branch you're working on? _Dumbass_. | which branch | `gb what branch` |
28+
| Command | Description | Aliases | Usage/Examples |
29+
| ----------------------- | ----------------------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------- |
30+
| help | Shows the manual, so I can deal with less bullshit from you. | h | `gb help` <br> `gb help [command]` <br> `gb help [alias]` |
31+
| abort | What ya mom should've done years ago. Aborts a stuck process. | ab | `gb abort` |
32+
| add-missing | Add missing files to the latest commit. You made a broken commit, didn't you? | addmissing, addm | `gb add-missing <...files>` |
33+
| discard | Wasted time on something that didn't work? | explode, dc | `gb discard` |
34+
| github | Things related to the Hub- shit. Walked myself right into that one. | gh | `gb github <subcommand>` |
35+
| github actions | Just pushed your changes? Want to watch the deployment fail? | a, action | `gb github actions` <br> `gb github actions [workflow]` <br> `gb github actions [workflow] --branch [branch]` <br> `gb github actions [workflow] -b [branch]` |
36+
| github pull-request | Open a pull request. What did you expect? | pr, pullrequest | `gb github pull-request` <br> `gb github pull-request <target_branch>` <br> `gb github pull-request <target_remote>/[target_branch]` <br> `gb github pull-request <target_remote>/[target_branch]:<from_remote>/[from_branch]` <br> <br>**Examples:** <br> `gb github pull-request dev` <br> `gb github pull-request upstream/main` <br> `gb github pull-request dev:staging` <br> `gb github pull-request dev:upstream/main` <br> `gb github pull-request /main:upstream/` |
37+
| ignore | Ignore your files, like ignoring your problems. | i | `gb ignore [...patterns]` <br> `gb ignore` (view ignored files) |
38+
| pet | Petting me? Seriously? | | `gb pet` | |
39+
| unignore | Unignoring your problems now? Good for you. | u | `gb unignore [...patterns]` |
40+
| undo | Uncommits your commits because you have commitment issues. | ud | `gb undo [amount]` |
41+
| unstage | Did you fuckin' stage .env? Remove that! | unadd, !add | `gb unstage [...files]` |
42+
| what | Ya *really* dumb enough to not know what you're working on? | which | `gb what <subcommand>` |
43+
| what branch | Figured only you would forget what branch you're working on... | | `gb what branch` |
4344

4445
# ⏱️ Future Plans
4546

src/commands/add-missing.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { $ } from 'bun'
2+
import { args, logger } from '../context'
3+
import { string } from '../strings'
4+
5+
export const execute = async () => {
6+
if (!args.length) return logger.error(string('command.addMissing.noFiles'))
7+
8+
const addResult = await $`git add ${args}`.quiet().nothrow()
9+
if (addResult.exitCode)
10+
return logger.error(string('command.addMissing.addError', addResult.stderr.toString().trim()))
11+
12+
await $`git commit --amend --no-edit`.quiet()
13+
14+
logger.info(string('command.addMissing.action'))
15+
}
16+
17+
export const description = string('command.addMissing.description')
18+
19+
export const aliases = ['addmissing', 'addm']
20+
21+
export const usages = ['<...files>']

src/strings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const STRINGS = {
2626
},
2727
notStuck: "You ain't stuck. What are you trying to abort?",
2828
},
29+
addMissing: {
30+
description: "Add missing files to the latest commit. You made a broken commit, didn't you?",
31+
action: `Now the commit is less broken. They're added. You're welcome.`,
32+
noFiles: 'You want to add what, exactly?',
33+
addError: (err: string) => chalkTemplateStderr`Shit, something went wrong: ${err}`,
34+
},
2935
discard: {
3036
description: "Wasted time on something that didn't work?",
3137
action: [

src/utils/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { $ } from 'bun'
22

33
export async function remoteExists(remote: string) {
44
const result = await $`git config remote.${remote}.url`.nothrow().quiet()
5-
return result.exitCode === 0
5+
return !result.exitCode
66
}
77

88
export async function localBranchExists(branch: string) {
99
const result = await $`git show-ref refs/heads/${branch}`.nothrow().quiet()
10-
return result.exitCode === 0
10+
return !result.exitCode
1111
}
1212

1313
export async function remoteBranchExists(remote: string, branch: string) {

0 commit comments

Comments
 (0)