Skip to content

Commit 3023bac

Browse files
committed
feat: add 'undo commit' quick select
1 parent 83040e4 commit 3023bac

3 files changed

Lines changed: 19 additions & 77 deletions

File tree

README.md

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ This is the full setup, for only starship scroll down to the starship section.
6161
- [Installation](#installation)
6262
- [Usage](#usage)
6363
- [Customization](#customization)
64-
- [Usage in scripts](#usage-in-scripts)
65-
- [Troubleshooting](#troubleshooting)
6664
- [What is and what will be (features)](#what-is-and-what-will-be)
67-
- [Completions](#completions)
6865
- [Contributing](#contributing)
6966
- [Thanks](#thanks)
7067

@@ -111,63 +108,15 @@ For more info run `gith help` or check out the [help articles](https://gith.feat
111108
Gith tries to use intuitive, natural language commands,
112109
combined with the usual git commands, for example `gith tag` or `gith update remote url`.
113110

111+
You can also get completions for fish, base or zsh: [Completions](https://gith.featurebase.app/help/articles/8096273)
112+
114113
## Customization
115114

116115
You can set your preferred flavor and accent in the Options.
117116
Just run `gith` and select "Options".
118117

119-
When running gith the first time, a config file storing your settings will be created at
120-
`XDG_CONFIG_HOME/gith/config.json` if `XDG_CONFIG_HOME` is set,
121-
otherwise at `~/.config/gith/config.json`.
122-
123-
You can also manually edit the config file, although editing with gith ensures that no invalid configurations are used.
124-
125-
**If you have anything you'd like to configure in the settings or options, don't hesitate to open an issue or [Feature Request](https://gith.featurebase.app/).**
126-
127118
For more info check out the [help articles](https://gith.featurebase.app/help).
128119

129-
## Usage in scripts
130-
131-
You are able to easily change flavor and accent of gith in scripts:
132-
133-
```bash
134-
gith config update --flavor=Latte --accent=Red
135-
```
136-
137-
Useful for example if you want a script to switch between
138-
light and dark mode in all your catppuccin themed apps.
139-
140-
> [!NOTE]
141-
> Run `gith config help` for more info
142-
143-
## Troubleshooting
144-
145-
**I update gith via `go install github.com/a3chron/gith@latest`, but nothing changes / version stays the same**
146-
147-
> [!NOTE]
148-
> If you get any output when running `go install github.com/a3chron/gith@latest`,
149-
> you probably just discovered some other bug.
150-
> Consider opening an issue at [Featurebase](https://gith.featurebase.app/) or GitHub.
151-
152-
Sometimes it takes some time for the go proxy server to recognize a new release,
153-
so it is possible that the latest release for the proxy server is still the old one.
154-
155-
In that case, just request a lookup for the specific version, for example `v0.6.0` if this is the latest release:
156-
157-
```bash
158-
go install github.com/a3chron/gith@v0.6.0
159-
```
160-
161-
You should now see the output:
162-
163-
```bash
164-
go: downloading github.com/a3chron/gith v0.6.0
165-
```
166-
167-
> [!NOTE]
168-
> You can check for the latest release on [github](https://github.com/a3chron/gith/releases/latest)
169-
> or by simply running `gith version check`
170-
171120
## What is and what will be
172121

173122
**You can view the Roadmap / upvote Feature Requests and Bugs at [Featurebase](https://gith.featurebase.app/).**
@@ -188,7 +137,7 @@ go: downloading github.com/a3chron/gith v0.6.0
188137

189138
- [ ] Commit
190139

191-
- [x] Undo Last Commit
140+
- [x] Undo Last Commit _-- supports quick select --_
192141

193142
- [x] Commit staged changes _-- supports quick select --_
194143

@@ -234,29 +183,6 @@ go: downloading github.com/a3chron/gith v0.6.0
234183

235184
- [x] Change UI accent color
236185

237-
## Completions
238-
239-
For package installation the completions will be installed automatically.
240-
When installing via `go install` you can get completions for the few commands there are by running the following command:
241-
242-
**fish**
243-
244-
```bash
245-
gith completion fish > ~/.config/fish/completions/gith.fish
246-
```
247-
248-
**bash**
249-
250-
```bash
251-
gith completion bash > ~/.local/share/bash-completion/completions/gith
252-
```
253-
254-
**Zsh**
255-
256-
```bash
257-
gith completion zsh > ~/.local/share/zsh/site-functions/_gith
258-
```
259-
260186
## Contributing
261187

262188
Contributions are welcome, please use [conventional commits](https://www.conventionalcommits.org/) for a constant commit message style.

internal/app.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
138138
m.ActionModel.SelectedAction = "Commit"
139139
m.CommitModel.SelectedAction = "Commit All"
140140

141+
case "undo-commit":
142+
m.Level = 3
143+
m.Selected = 2 // quick fix because handleEnterKey sets step to selected (add extra handleSelect function, see other modules)
144+
m.CurrentStep = StepCommitAction
145+
m.ActionModel.SelectedAction = "Commit"
146+
m.CommitModel.SelectedAction = "Undo Last Commit"
147+
return m.handleEnterKey()
148+
141149
case "add-remote":
142150
m.Level = 3
143151
m.Selected = 0

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,15 @@ func handleCliArgs() error {
237237
return runQuick("commit-all", 3)
238238
case "staged":
239239
return runQuick("commit-staged", 3)
240+
} // TODO: all error here if none matched
241+
242+
case "undo":
243+
if len(os.Args) != 3 || os.Args[2] != "commit" {
244+
fmt.Fprintf(os.Stderr, "Usage: gith undo commit\n")
245+
os.Exit(1)
240246
}
247+
248+
return runQuick("undo-commit", 2)
241249
}
242250

243251
fmt.Fprintf(os.Stderr, "unknown command: %s\nUse 'gith help' for usage information", strings.Join(os.Args[1:], " "))

0 commit comments

Comments
 (0)