Compare commits

..

No commits in common. "master" and "v5.0" have entirely different histories.
master ... v5.0

17 changed files with 173 additions and 795 deletions

View file

@ -35,107 +35,6 @@
"doc",
"plugin"
]
},
{
"login": "thecesrom",
"name": "César Román",
"avatar_url": "https://avatars.githubusercontent.com/u/19418023?v=4",
"profile": "https://thecesrom.dev/",
"contributions": [
"code",
"bug"
]
},
{
"login": "ibayramli2001",
"name": "Ilkin Bayramli",
"avatar_url": "https://avatars.githubusercontent.com/u/43158991?v=4",
"profile": "https://github.com/ibayramli2001",
"contributions": [
"platform"
]
},
{
"login": "kopalchakravarty",
"name": "Kopal Chakravarty",
"avatar_url": "https://avatars.githubusercontent.com/u/31576619?v=4",
"profile": "https://github.com/kopalchakravarty",
"contributions": [
"code"
]
},
{
"login": "zora89",
"name": "Zorawar Purohit",
"avatar_url": "https://avatars.githubusercontent.com/u/42845567?v=4",
"profile": "https://www.zorawarpurohit.com",
"contributions": [
"doc"
]
},
{
"login": "nalin-singh",
"name": "Nalin Singh",
"avatar_url": "https://avatars.githubusercontent.com/u/38408670?v=4",
"profile": "https://craftic.webflow.io",
"contributions": [
"code"
]
},
{
"login": "vinayaknayar",
"name": "vinayaknayar",
"avatar_url": "https://avatars.githubusercontent.com/u/98237998?v=4",
"profile": "https://github.com/vinayaknayar",
"contributions": [
"doc"
]
},
{
"login": "RohitSingh107",
"name": "RohitSingh107",
"avatar_url": "https://avatars.githubusercontent.com/u/64142943?v=4",
"profile": "https://github.com/RohitSingh107",
"contributions": [
"platform"
]
},
{
"login": "Theotime812",
"name": "Théotime Maillarbaux",
"avatar_url": "https://avatars.githubusercontent.com/u/45947878?v=4",
"profile": "https://github.com/Theotime812",
"contributions": [
"code",
"bug"
]
},
{
"login": "dr41d45",
"name": "dr41d45",
"avatar_url": "https://avatars.githubusercontent.com/u/47773787?v=4",
"profile": "https://github.com/dr41d45",
"contributions": [
"code"
]
},
{
"login": "T-Joseph-Kim",
"name": "Taebok Joseph Kim",
"avatar_url": "https://avatars.githubusercontent.com/u/116681578?v=4",
"profile": "https://github.com/T-Joseph-Kim",
"contributions": [
"code"
]
},
{
"login": "luxxmr",
"name": "luxxmr",
"avatar_url": "https://avatars.githubusercontent.com/u/185298948?v=4",
"profile": "https://github.com/luxxmr",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
@ -143,7 +42,5 @@
"projectOwner": "Bhupesh-V",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true,
"commitConvention": "angular",
"commitType": "docs"
"skipCi": true
}

6
.github/FUNDING.yml vendored
View file

@ -1,8 +1,8 @@
# These are supported funding model platforms
github: Bhupesh-V
open_collective: ugit
ko_fi: # bhupesh
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
open_collective: # Replace with a single Open Collective username
ko_fi: bhupesh
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
issuehunt: # Replace with a single IssueHunt username

View file

@ -0,0 +1,29 @@
---
name: "\U0001F41B Bug report"
about: Create a report to help us improve ugit
title: ''
labels: 'bug'
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. Ubuntu]
- Bash Version [e.g. 4.4.20]
- FZF Version: [e.g. 0.21.0]
- Git Version: [e.g. 2.31.1]
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,20 @@
---
name: "\U0001F680 Feature request"
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

10
.github/ISSUE_TEMPLATE/---question.md vendored Normal file
View file

@ -0,0 +1,10 @@
---
name: "❓ Question"
about: Ask any questions
title: ''
labels: question
assignees: ''
---

View file

@ -0,0 +1,18 @@
---
name: "\U0001F49F Say thank you"
about: Just say thanks if you liked ugit
title: ''
labels: ''
assignees: ''
---
if you liked **ugit** - please let us know. We'd love to hear from you!
You can help me in any way possible
- [ ] Give the repository a star ⭐️
- [ ] Help out with issues
- [ ] Share ugit with others
Thank you! 💐

View file

@ -1,76 +0,0 @@
name: 🐛 Bug Report
description: Create a report to help us improve ugit
labels: ["bug"]
assignees:
- Bhupesh-V
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see! Any log outputs, demo screenshots
value: "A bug happened!"
validations:
required: true
- type: dropdown
id: ugit-version
attributes:
label: Ugit Version
description: What version of ugit are you running?
options:
- v5.1 (Latest)
- v5.0
- v4.1
- v4.0
- v3.0
- v2.0
- v1.0
validations:
required: true
- type: dropdown
id: bash-version
attributes:
label: Bash Version
description: What version of bash are you running?
options:
- Bash >= 5.0
- Bash >= 4.0
- Bash >= 3.0
validations:
required: true
- type: textarea
id: git-version
attributes:
label: Git Version
description: Please paste the output of `git --version`
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: What OS are you seeing the problem on?
multiple: false
options:
- Linux Based
- MacOS
- Windows
validations:
required: true
- type: textarea
id: terminalName
attributes:
label: Terminal Name
description: Please specify the name of terminal you are using (E.g Kitty, iterm2 etc.)
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Bhupesh-V/ugit/blob/master/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true

View file

@ -1,26 +0,0 @@
name: 🚀 Feature request
description: Suggest an idea for this project
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to request for more features!
- type: textarea
id: got-a-problem
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
validations:
required: true
- type: textarea
id: have-any-solution
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: false
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.

View file

@ -7,8 +7,8 @@ Please include a summary of the change and which issue is fixed. Please also inc
For e.g #45
-->
### Screenshots / Gifs:
<!-- Please any demo video/GIFs to showcase changes -->
### Screenshots / Gifs
<!-- remove above line if not applicable -->
### Changes Include
@ -19,17 +19,8 @@ For e.g #45
- [ ] Tooling ⚙️ (Changes to the build process or auxiliary tools and libraries such as documentation generation)
- [ ] Performance ⚡ (code change that improves performance)
## How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [ ] Test A
- [ ] Test B
### Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] I have performed a self-review of my own code
- [ ] I have checked my code and corrected any misspellings
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

View file

@ -1,26 +0,0 @@
name: Get ugit Download Stats
on:
workflow_dispatch:
schedule:
# everyday 9:30 pm
- cron: '0 16 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Download Count
id: downloads
run: |
echo ::set-output name=download_count::$((curl -sq https://formulae.brew.sh/api/formula/ugit.json | jq '.analytics.install_on_request."365d".ugit' | tr "\012" "+" && (curl -sq https://api.github.com/repos/Bhupesh-V/ugit/releases | jq .[].assets[0].download_count | tr "\012" "+" ; echo "0")) | bc)
- name: Create Awesome Badge
uses: schneegans/dynamic-badges-action@v1.1.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 6b7b8e8576bc1ca237bffd9a344672ab
filename: ugit-downloads.json
label: downloads
message: ${{ steps.downloads.outputs.download_count }}
color: "#820F82"

View file

@ -1,71 +0,0 @@
FROM alpine:3.18 as ugit-ops
RUN apk add --no-cache \
bash \
coreutils \
git \
ncurses \
curl
# Download fzf binary from GitHub, pin to 0.46.0, ugit requires minimum 0.21.0
RUN curl -L -o fzf.tar.gz https://github.com/junegunn/fzf/releases/download/0.46.0/fzf-0.46.0-linux_amd64.tar.gz && \
tar -xzf fzf.tar.gz && \
mv fzf /usr/bin/
# Copy only the ugit script into the container at /app
COPY ugit .
# Set permissions and move the script to path
RUN chmod +x ugit && mv ugit /usr/bin/
# Second stage: Copy only necessary binaries and their dependencies
FROM scratch
LABEL description="Undo your last oopsie in git with ugit"
LABEL maintainer="Bhupesh Varshney <varshneybhupesh@gmail.com>"
COPY --from=ugit-ops /usr/bin/ugit /bin/
COPY --from=ugit-ops /usr/bin/git /usr/bin/
COPY --from=ugit-ops /usr/bin/fzf /usr/bin/
COPY --from=ugit-ops /usr/bin/tput /usr/bin/
COPY --from=ugit-ops /usr/bin/nl /usr/bin/
COPY --from=ugit-ops /usr/bin/awk /usr/bin/
COPY --from=ugit-ops /usr/bin/xargs /usr/bin/
COPY --from=ugit-ops /usr/bin/cut /usr/bin/
COPY --from=ugit-ops /usr/bin/tr /usr/bin/
COPY --from=ugit-ops /bin/bash /bin/
COPY --from=ugit-ops /bin/grep /bin/
# copy lib files
# COPY --from=ugit-ops /usr/lib/libncursesw* /usr/lib/
COPY --from=ugit-ops /usr/lib/libncursesw.so.6 /usr/lib/
# COPY --from=ugit-ops /usr/lib/libpcre* /usr/lib/
COPY --from=ugit-ops /usr/lib/libpcre2-8.so.0 /usr/lib/
# COPY --from=ugit-ops /usr/lib/libreadline* /usr/lib/
COPY --from=ugit-ops /usr/lib/libreadline.so.8 /usr/lib/
COPY --from=ugit-ops /lib/libacl.so.1 /lib/
COPY --from=ugit-ops /lib/libattr.so.1 /lib/
COPY --from=ugit-ops /lib/libc.musl-* /lib/
COPY --from=ugit-ops /lib/ld-musl-* /lib/
COPY --from=ugit-ops /lib/libutmps.so.0.1 /lib/
COPY --from=ugit-ops /lib/libskarnet.so.2.13 /lib/
COPY --from=ugit-ops /lib/libz.so.1 /lib/
# copy terminfo database
COPY --from=ugit-ops /etc/terminfo/x/xterm-256color /usr/share/terminfo/x/
# Gib me all the colors
ENV TERM=xterm-256color
# Let fzf know our deault shell
ENV SHELL=/bin/bash
# Let ugit know we are running in docker
ENV UGIT_RUNNING_IN_DOCKER=true
WORKDIR /app
# Run ugit when the container launches
ENTRYPOINT ["/bin/bash", "/bin/ugit"]

161
README.md
View file

@ -5,20 +5,17 @@
<a href="https://github.com/Bhupesh-V/ugit/actions/workflows/build.yml">
<img alt="build ugit" src="https://github.com/Bhupesh-V/ugit/actions/workflows/build.yml/badge.svg">
</a>
<a href="https://hub.docker.com/r/bhupeshimself/ugit">
<img alt="Docker pulls" src="https://img.shields.io/docker/pulls/bhupeshimself/ugit?logo=docker" target="_blank" />
<a href="https://github.com/Bhupesh-V/ugit/blob/master/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/github/license/Bhupesh-V/ugit" target="_blank" />
</a>
<img alt="total downloads (github + brew)" src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Bhupesh-V/6b7b8e8576bc1ca237bffd9a344672ab/raw/ugit-downloads.json">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/Bhupesh-V/ugit/total?color=orange">
<a href="">
<img alt="platform support linux and macos" src="https://img.shields.io/badge/platform-GNU/Linux %7C MacOS-blue">
</a>
<a href="https://til.bhupesh.me/git/how-to-undo-anything-in-git">
<img alt="git undo text guide" src="https://img.shields.io/badge/guide-git%20undo-orange">
</a>
<a href="https://twitter.com/bhupeshimself">
<img alt="Twitter: bhupeshimself" src="https://img.shields.io/twitter/follow/bhupeshimself.svg?style=social" target="_blank" />
</a><br><br>
<img align="center" title="ugit demo: restore file to a previous commit" alt="ugit demo: restore file gif" src="https://user-images.githubusercontent.com/34342551/135706491-0e987e0c-3a6d-4da6-bd16-d69bb36c42a9.gif"><br>
<img align="center" title="ugit demo: restore file to a previous commit" alt="ugit demo: restore file gif" src="https://user-images.githubusercontent.com/34342551/117250614-19a16380-ae61-11eb-97a9-8ba1695cc50a.gif"><br>
</p>
<h2><details><summary>More Video Demos ✨️</summary>
@ -37,18 +34,17 @@ https://user-images.githubusercontent.com/34342551/121651071-d9fd1580-cab7-11eb-
</details></h2>
## Why use `ugit`?
- You accidentally ran a `git` command you wish to 'undo'.
- You want to save time by not searching for _how to undo ..._
- Your focus is on the problems at hand and not on Git (avoid context switching)
## Why `ugit`
- You did an accidental `git` command you didn't want to.
- You don't want to waste your time searching on _how to undo ..._
- Because `ugit` is cool
### [Motivations behind writing ugit 🙇‍♂️️](https://bhupesh-v.github.io/undo-your-last-git-mistake-with-ugit)
## What's in the box?
## What's in the box
`ugit`/`git-undo` supports undoing the following operations, some are a WIP. If you know of any other operations that can be undone and are not in the list, make sure to raise an issue or make a quick PR 💛️
`ugit`/`git-undo` supports undoing following operations, some are a WIP. If you know of any other operations that can be undone and is not in the list, make sure to send a quick PR 💛️
- [x] Undo `git commit`
- [x] Undo `git add`
@ -63,38 +59,28 @@ https://user-images.githubusercontent.com/34342551/121651071-d9fd1580-cab7-11eb-
- [x] Undo (Restore) a file to a previous version
- [x] Undo `git merge`
- [x] Undo `git cherry-pick`
- [x] Undo `git tag`
- [ ] Undo `git tag` (rename a tag)
- [ ] Undo `git rebase`
- [ ] Undo `git worktree remove` (recover deleted work-tree)
Contribute to the project by helping me with the above-mentioned tasks.
Help me finish above tasks by contributing?
If you have any other ideas/suggestions, do send them across. [**Hop in to ugit discussions 💬️**](https://github.com/Bhupesh-V/ugit/discussions/7)
Have any other ideas/suggestions? [**Hop in to ugit discussions 💬️**](https://github.com/Bhupesh-V/ugit/discussions/7)
## News
## `ugit` in ...
| When | What |
|:--------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 29 Oct, 2022 | ugit crossed 1k stars |
| 02 June, 2022 | [console.dev](https://console.dev/tools/) featured [ugit](https://twitter.com/bhupeshimself/status/1532714651842396161) |
| 18 May, 2022 | I gave a talk about the git tooling ecosystem & `git undo` in [Undo git, say whaat! - **GitHub India Constellation**, May 2022](https://youtu.be/jpR9BMFmh4Y?t=15240) |
| 12 May, 2021 | The [guide was **tweeted by GitHub**](https://twitter.com/github/status/1392207961355862018?s=20) (I was logging my research process there while building ugit) |
| 30 April, 2021 | Featured on [**Changelog News**](https://changelog.com/news/ugit-helps-you-undo-your-last-git-command-with-grace-8X6L) |
### News
## Community
- Featured on [**Changelog News**](https://changelog.com/news/ugit-helps-you-undo-your-last-git-command-with-grace-8X6L#discussion)
- The [guide was **tweeted by GitHub**](https://twitter.com/github/status/1392207961355862018?s=20) (I was logging my research process there while building ugit)
- Alexander Alemayhu made a YouTube tutorial on [Undoing Your Last Git Commit with Ugit](https://www.youtube.com/watch?v=nUnCgKb4tSc)
### Community
- Alexander Alemayhu made a youtube tutorial on [Undoing Your Last Git Commit with Ugit](https://www.youtube.com/watch?v=nUnCgKb4tSc)
## Installation
[Try `ugit` via Docker](https://hub.docker.com/r/bhupeshimself/ugit):
```bash
docker pull bhupeshimself/ugit
docker run --rm -it -v $(pwd):/app bhupeshimself/ugit
```
### Prerequisites
**ugit** dependencies:
@ -104,61 +90,26 @@ docker run --rm -it -v $(pwd):/app bhupeshimself/ugit
- [**fzf**](https://github.com/junegunn/fzf) >= `0.21.0` - [Installation guide](https://github.com/junegunn/fzf#installation)
- GNU utils like `awk`, `grep`, `tput` etc
<br>
### Manual Installation
[![Packaging status](https://repology.org/badge/vertical-allrepos/ugit.svg)](https://repology.org/project/ugit/versions)
1. Install the script using `curl`
### Linux
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
```
Arch Linux users can install [**ugit via AUR**](https://aur.archlinux.org/packages/ugit).
### Mac
```bash
brew install ugit
```
### Windows
To use ugit on Windows you need to install:
1. Git Bash<br>
Git bash comes with git (if you have installed it on your machine then no need). To install git (preferably with scoop):
```
scoop install git
```
2. FZF
**Linux**
```bash
curl -fsSL https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit -o ugit && chmod +x ugit && mv ugit $HOME/.local/bin/
```
scoop install fzf
**Mac**
```bash
curl -fsSL https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit -o ugit && chmod +x ugit && mv ugit /usr/local/bin
```
Alternatively, with Chocolatey:
```
choco install fzf
```
3. To use bash in terminal change your directory to `**git\2.35.3.windows.1\bin\bash**` accordingly.
4. Then either clone the repo,
Or Arch Linux users can install [**ugit via AUR**](https://aur.archlinux.org/packages/ugit).
2. Verify installation
```bash
git clone https://github.com/Bhupesh-V/ugit.git
ugit --version
```
or get it using curl:
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
```
### Fig
[Fig](https://fig.io) adds apps, shortcuts, and autocomplete to your existing terminal.
Install `ugit` in just one click.
<a href="https://fig.io/plugins/other/ugit_Bhupesh-V" target="_blank"><img src="https://fig.io/badges/install-with-fig.svg" /></a>
### ZSH Frameworks
@ -192,15 +143,6 @@ If you're using [oh-my-zsh](github.com/robbyrussell/oh-my-zsh):
`source ~/.zshrc`
### Note on `git-undo` Command Conflict
If you have both `ugit` and `git-extras` (https://github.com/tj/git-extras) installed, be aware that both provide a `git-undo` command. This can lead to conflicts, as only one version of the command will be accessible at a time. To resolve this:
- **Using Homebrew**: Homebrew will notify you of the conflict during installation. You can choose to unlink the conflicting formula or use the --overwrite flag to force the link as follows:
`brew link --overwrite ugit`
- **Manual Installation**: Ensure that the `git-undo` command from the desired package is prioritized in your system's PATH.
## Please read ⚠️
@ -208,14 +150,14 @@ If you have both `ugit` and `git-extras` (https://github.com/tj/git-extras) inst
Git comes with a garbage collector ([in case you didn't know](https://git-scm.com/docs/git-gc)) therefore undoing some commands will become impossible if the entries are deleted from the reflog.
One way to prevent this is to increase default time limits before the reflog entries expire.
Add these configurations in your global `.gitconfig` file:
Add these configuration in your global `.gitconfig` file:
```gitconfig
[gc]
# default 90 days
reflogExpire = 200
```
Used to set how long records in a branch reflog should be preserved.
Used to set how long records in a branches reflog should be preserved.
```gitconfig
[gc]
@ -229,6 +171,14 @@ Used to set how long inaccessible reflog records should be preserved.
You can read my in-process guide on [**How to undo anything in Git**](https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git)
## Author
:bust_in_silhouette: **Bhupesh Varshney**
- Web : [bhupesh-v.github.io](https://bhupesh-v.github.io)
- Twitter : [@bhupeshimself](https://twitter.com/bhupeshimself)
- DEV : [bhupesh](https://dev.to/bhupesh)
## Credit & Thanks
To all the SO threads that I will probably never visit again ;)
@ -255,26 +205,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sharan-aithal"><img src="https://avatars.githubusercontent.com/u/32029982?v=4?s=100" width="100px;" alt="Sharan Aithal"/><br /><sub><b>Sharan Aithal</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://tabulate.tech"><img src="https://avatars.githubusercontent.com/u/58576759?v=4?s=100" width="100px;" alt="Tabulate"/><br /><sub><b>Tabulate</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=TabulateJarl8" title="Code">💻</a> <a href="#platform-TabulateJarl8" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://unixorn.github.io"><img src="https://avatars.githubusercontent.com/u/23920?v=4?s=100" width="100px;" alt="Joe Block"/><br /><sub><b>Joe Block</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Documentation">📖</a> <a href="#plugin-unixorn" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://thecesrom.dev/"><img src="https://avatars.githubusercontent.com/u/19418023?v=4?s=100" width="100px;" alt="César Román"/><br /><sub><b>César Román</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=thecesrom" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/issues?q=author%3Athecesrom" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ibayramli2001"><img src="https://avatars.githubusercontent.com/u/43158991?v=4?s=100" width="100px;" alt="Ilkin Bayramli"/><br /><sub><b>Ilkin Bayramli</b></sub></a><br /><a href="#platform-ibayramli2001" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kopalchakravarty"><img src="https://avatars.githubusercontent.com/u/31576619?v=4?s=100" width="100px;" alt="Kopal Chakravarty"/><br /><sub><b>Kopal Chakravarty</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=kopalchakravarty" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.zorawarpurohit.com"><img src="https://avatars.githubusercontent.com/u/42845567?v=4?s=100" width="100px;" alt="Zorawar Purohit"/><br /><sub><b>Zorawar Purohit</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=zora89" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://craftic.webflow.io"><img src="https://avatars.githubusercontent.com/u/38408670?v=4?s=100" width="100px;" alt="Nalin Singh"/><br /><sub><b>Nalin Singh</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=nalin-singh" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vinayaknayar"><img src="https://avatars.githubusercontent.com/u/98237998?v=4?s=100" width="100px;" alt="vinayaknayar"/><br /><sub><b>vinayaknayar</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=vinayaknayar" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/RohitSingh107"><img src="https://avatars.githubusercontent.com/u/64142943?v=4?s=100" width="100px;" alt="RohitSingh107"/><br /><sub><b>RohitSingh107</b></sub></a><br /><a href="#platform-RohitSingh107" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Theotime812"><img src="https://avatars.githubusercontent.com/u/45947878?v=4?s=100" width="100px;" alt="Théotime Maillarbaux"/><br /><sub><b>Théotime Maillarbaux</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=Theotime812" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/issues?q=author%3ATheotime812" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dr41d45"><img src="https://avatars.githubusercontent.com/u/47773787?v=4?s=100" width="100px;" alt="dr41d45"/><br /><sub><b>dr41d45</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=dr41d45" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/T-Joseph-Kim"><img src="https://avatars.githubusercontent.com/u/116681578?v=4?s=100" width="100px;" alt="Taebok Joseph Kim"/><br /><sub><b>Taebok Joseph Kim</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=T-Joseph-Kim" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luxxmr"><img src="https://avatars.githubusercontent.com/u/185298948?v=4?s=100" width="100px;" alt="luxxmr"/><br /><sub><b>luxxmr</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=luxxmr" title="Documentation">📖</a></td>
</tr>
</tbody>
<tr>
<td align="center"><a href="https://github.com/sharan-aithal"><img src="https://avatars.githubusercontent.com/u/32029982?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sharan Aithal</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=sharan-aithal" title="Documentation">📖</a></td>
<td align="center"><a href="https://tabulate.tech"><img src="https://avatars.githubusercontent.com/u/58576759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tabulate</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=TabulateJarl8" title="Code">💻</a> <a href="#platform-TabulateJarl8" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="http://unixorn.github.io"><img src="https://avatars.githubusercontent.com/u/23920?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joe Block</b></sub></a><br /><a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Code">💻</a> <a href="https://github.com/Bhupesh-V/ugit/commits?author=unixorn" title="Documentation">📖</a> <a href="#plugin-unixorn" title="Plugin/utility libraries">🔌</a></td>
</tr>
</table>
<!-- markdownlint-restore -->

152
install
View file

@ -1,152 +0,0 @@
#!/bin/env sh
# Script for installing ugit (git undo)
#
# This script can be executed via
# curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
# or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
# or httpie:
# sh -c "$(http --download https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
status_check() {
if command -v ugit 2>&1 > /dev/null; then
printf "\n\t%s\n" "You already have ${BOLD}ugit${RESET} installed."
printf "\n\t%s\n" "Run ${BOLD}git undo${RESET} everytime you make a git mistake :)"
exit 0
fi
}
installed() {
cmd=$(command -v "${1}")
return ${?}
}
die() {
>&2 echo "Fatal: $*"
exit 1
}
# TODO
# check if correct version of fzf is there
# check if correct version of git is there
# check if correct version of bash is there
check_dependencies() {
if ! command -v git > /dev/null 2>&1; then
printf "\n%s\n" "${BOLD}Can't work without git 😞. Please install git version >=2.30.0${RESET}"
exit 1
fi
if ! command -v fzf > /dev/null 2>&1; then
printf "\n%s\n" "${BOLD}Can't work without fzf 😞. Please install fzf version >=0.21.0${RESET}"
exit 1
fi
if ! command -v bash > /dev/null 2>&1; then
printf "\n%s\n" "${BOLD}Can't work without bash 😞. Please install bash version >=4${RESET}"
exit 1
fi
DEPS=""
DEPS="${DEPS} awk"
DEPS="${DEPS} xargs"
DEPS="${DEPS} cut"
DEPS="${DEPS} nl"
DEPS="${DEPS} tr"
for DEP in ${DEPS}; do
installed ${DEP} || die "Missing GNU Utility: '${DEP}'"
done
}
set_permissions(){
if [ -f ugit ] && ! chmod +x ugit; then
printf "\n%s\n" "Unknown error while installing ugit"
exit 1
fi
move_to_path
}
move_to_path(){
printf "%s\n" "We require some permissions to move ugit to /usr/bin"
if sudo mv ugit /usr/bin; then
sudo ln -s ugit /usr/bin/git-undo
else
printf "\n%s\n" "Unknown error while installing ugit"
exit 1
fi
}
download_ugit(){
UGIT_HOST="https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit"
printf "\n%s\n" "Downloading ugit from ${BOLD}$UGIT_HOST${RESET} ..."
if curl -fsSL $UGIT_HOST -o ugit; then
set_permissions
else
printf "\n%s\n" "Unknown error while downloading ugit"
exit 1
fi
}
config_check() {
reflogExpire=$(git config --get gc.reflogExpire)
if [ "$reflogExpire" = "" ] ; then
printf "%s\n" "Setting ${BOLD}gc.reflogExpire${RESET} to 200 days"
if ! git config --global gc.reflogExpire 200; then
printf "%s\n" "Unexpected error while setting up gitconfig"
exit 1
fi
elif [ "$reflogExpire" -lt 200 ]; then
printf "%s\n" "ugit recommends increasing ${BOLD}gc.reflogExpire${RESET} config duration to 200 days."
fi
reflogExpireUnreachable=$(git config --get gc.reflogExpireUnreachable)
if [ "$reflogExpireUnreachable" = "" ]; then
printf "%s\n" "Setting ${BOLD}gc.reflogExpireUnreachable${RESET} to 90 days"
if ! git config --global gc.reflogExpireUnreachable 90; then
printf "%s\n" "Unexpected error while setting up gitconfig"
exit 1
fi
elif [ "$reflogExpireUnreachable" -lt 90 ]; then
printf "%s\n" "ugit recommends increasing ${BOLD}gc.reflogExpireUnreachable${RESET} config duration to 90 days."
fi
}
main () {
status_check
check_dependencies
download_ugit
config_check
printf "${BOLD}${ORANGE_FG}%s\n" ""
printf "%s\n" " _ _ "
printf "%s\n" " _ _ __ _(_| |_ "
printf "%s\n" "| | | |/ _\` | | __| "
printf "%s\n" "| |_| | (_| | | |_ "
printf "%s\n" " \__,_|\__, |_|\__| "
printf "%s\n" " |___/ "
printf "${RESET}\n%s" ""
printf "\t\t%s\n" ".... is now installed 👍"
printf "\n%s" "Run ${BOLD}ugit --help${RESET} for any help & assistance"
printf "\n%s\n" "Use ${BOLD}${ORANGE_FG}git undo${RESET} or ${BOLD}${ORANGE_FG}ugit${RESET} everytime you make a git mistake :)"
}
# check if tput exists
if ! command -v tput > /dev/null 2>&1; then
# tput could not be found :(
BOLD=""
RESET=""
ORANGE_FG=""
else
BOLD=$(tput bold)
RESET=$(tput sgr0)
ORANGE_FG=$(tput setaf 208)
fi
main

197
ugit
View file

@ -1,15 +1,14 @@
#!/usr/bin/env bash
# ugit: Undo git commands with ease. Powered by FZF
# ugit: Undo your last git command without much effort. Powered by FZF
set -uo pipefail;
SCRIPT_NAME="$0"
SCRIPT_URL="https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit"
TMP_FILE="/tmp/ugit.sh"
VERSION="5.9"
VERSION="5.0"
pointer=""
BOLD_ORG_FG=$(tput bold)$(tput setaf 208)
BOLD=$(tput bold)
RESET=$(tput sgr0)
@ -34,15 +33,10 @@ display_menu() {
printf "%s\n" "Undo/Restore file to a previous commit"
printf "%s\n" "Undo ${BOLD_ORG_FG}git cherry-pick${RESET}"
printf "%s\n" "Undo all current uncommited changes"
printf "%s\n" "Undo ${BOLD_ORG_FG}git tag${RESET}"
printf "%s\n" "Undo ${BOLD_ORG_FG}git rm${RESET}"
}
perror() {
printf "%s\n" "$(tput bold)$(tput setaf 196)ugit error${RESET}: $1"
printf "%s\n" "If you think this is a Ugit bug, please follow this link to report it:"
printf "%s\n" "${BOLD_ORG_FG}https://github.com/Bhupesh-V/ugit/issues/new?template=bug-report.yml${RESET}"
exit
}
undo_git_commit() {
@ -58,30 +52,14 @@ undo_git_commit() {
[ -z "$commit" ] && exit
last_commit=$(git log --format="%h" -n 1)
initial_commit=$(git rev-list --max-parents=0 --abbrev-commit HEAD)
if [[ "$last_commit" == "$commit" ]]; then
# If the last commit is the same as the initial commit, delete reference to the branch(update-ref) and unstage changes of the initial commit(git rm).
# This will not delete the files from your working directory
if [[ "$last_commit" == "$initial_commit" ]]; then
if git update-ref -d HEAD && git rm --cached -rf . > /dev/null 2>&1; then
printf "%s\n" "Initial commit: $initial_commit successfully undone. Commit state is clean."
else
perror "Error: Failed to revert initial commit"
exit
fi
elif git reset HEAD~; then
if git reset HEAD~; then
printf "%s\n" "Commit: $last_commit successfully undone"
else
perror "Failed to revert commit $last_commit"
exit
fi
elif git revert "$commit"; then
printf "%s\n" "Commit: $commit successfully reverted. Check ${BOLD_ORG_FG}git status${RESET}"
else
perror "Error: unable to perfom operation"
fi
}
do_git_reset() {
@ -91,7 +69,7 @@ do_git_reset() {
# check if working tree is clean or not
[[ $(git status --porcelain 2>/dev/null) != "" ]] && read -p "You have uncommited changes, still proceed? [Y/n]: " -n 1 -r USER_INPUT
USER_INPUT=${USER_INPUT:-Y}
[[ "$USER_INPUT" == Y ]] && git reset --hard "$last_good_state" || perror "Error: unable to perform reset operation"
[[ "$USER_INPUT" == Y ]] && git reset --hard "$last_good_state"
}
undo_git_add() {
@ -103,8 +81,6 @@ undo_git_add() {
if [[ ${#choices[@]} -gt 0 ]] && git restore --staged "${choices[@]}"; then
printf "%s\n" "Done 👍️"
else
perror "Error: unable to perform operation"
fi
}
@ -113,8 +89,8 @@ change_commit_message() {
printf "%s" "Enter New Commit Message (Ctrl+d to save):"
msg=$(</dev/stdin)
echo
[[ "$msg" != "" ]] && git commit --amend -m "$msg" && printf "%s\n" "Remember to run ${BOLD_ORG_FG}git push -f <remoteName> <branchName>${RESET} if this was a pushed commit" \
|| perror "Empty Commit string!"
[[ "$msg" != "" ]] && git commit --amend -m "$msg" || perror "Empty Commit string!"
printf "%s\n" "Remember to run ${BOLD_ORG_FG}git push -f <remoteName> <branchName>${RESET} if this was a pushed commit"
}
undo_git_push() {
@ -122,8 +98,6 @@ undo_git_push() {
if git revert "$commit"; then
printf "%s\n" "Commit: $commit successfully reverted."
printf "%s\n" "Make sure to run ${BOLD_ORG_FG}git push${RESET} now!"
else
perror "Error: unable to perform operation"
fi
}
@ -136,7 +110,7 @@ undo_branch_delete() {
if [ -n "$BRANCH_NAME" ] && git checkout -b "$BRANCH_NAME" "$last_branch_commit"; then
printf "%s\n" "Branch $BRANCH_NAME successfully recovered 👍️"
else
perror "Failed to recover branch $BRANCH_NAME"
perror "Error: unable to perform operation"
fi
}
@ -144,8 +118,6 @@ undo_git_reset() {
LAST_GOOD_STATE=$(git reflog | fzf --ansi --height 20% --reverse --multi --header="Choose last known good commit" | awk '{print $1}')
if [[ -n "$LAST_GOOD_STATE" ]] && git reset "$LAST_GOOD_STATE"; then
printf "%s\n" "Reset to $LAST_GOOD_STATE 👍️"
else
perror "Unable to reset state"
fi
}
@ -163,15 +135,7 @@ undo_git_merge() {
[[ $(git status --porcelain 2>/dev/null) != "" ]] && read -p "You have uncommited changes, still proceed? [Y/n]: " -n 1 -r USER_INPUT
USER_INPUT=${USER_INPUT:-Y}
# ref: ORIG_HEAD points to the original commit from before the merge
if [[ "$USER_INPUT" == Y ]]; then
if git reset --merge ORIG_HEAD; then
printf "Operation completed successfully"
else
perror "Unable to revert merge commit"
fi
else
exit
fi
[[ "$USER_INPUT" == Y ]] && git reset --merge ORIG_HEAD || exit 0
# [[ "$USER_INPUT" == Y ]] && git reset --merge "$last_good_state" || exit 0
else
default_branch=$(git remote show origin | awk '/HEAD/ {print $3}')
@ -180,27 +144,20 @@ undo_git_merge() {
commit=$(git log --oneline | fzf --ansi --height 10% --reverse --header="Choose the merge commit" | awk '{print $1}')
if git revert -m 1 "$commit"; then
printf "%s\n" "Merge ($commit) successfully reverted 👍️"
else perror "Unable to revert merge commit"
fi
fi
}
recover_lost_stash() {
LOST_STASH=$(git fsck --no-progress --unreachable |
awk '/commit/ {print $3}' |
xargs git log --color --oneline --merges --no-walk
LOST_STASH=$(git fsck --no-progress --unreachable | \
awk '/commit/ {print $3}' | \
xargs git log --color --oneline --merges --no-walk | \
fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}'
)
if [ -z "$LOST_STASH" ]; then
printf "%s\n" "No unreachable commits found. Exiting..."
exit
fi
[[ "$LOST_STASH" ]] && read -p "Enter Stash Description: " -r STASH_MSG || exit
STASH=$(echo "$LOST_STASH" | fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}')
read -p "Enter Stash Description: " -r STASH_MSG
if git update-ref refs/stash "$STASH" --create-reflog -m "$STASH_MSG"; then
if git update-ref refs/stash "$LOST_STASH" --create-reflog -m "$STASH_MSG"; then
printf "%s\n" "Stash Successfully Recovered 👍️"
else
perror "Unable to recover stash"
@ -246,22 +203,11 @@ recover_deleted_tag() {
undo_file_delete() {
if [[ "$1" = "uncommited" ]]; then
# user didn't commit the file deletion
readarray -t DELETED_FILES < <(
git ls-files -d |
fzf --ansi --height 20% --reverse --header="Choose deleted files to recover" --multi |
awk '{print $1}'
)
if [ ${#DELETED_FILES[@]} -eq 0 ]; then
DELETED_FILE=$(git ls-files -d | fzf --ansi --height 20% --reverse --header="Choose deleted file to recover" | awk '{print $1}')
if git checkout HEAD "$DELETED_FILE"; then
printf "%s\n" "${BOLD}$DELETED_FILE${RESET} Successfully Recovered 👍️"
exit 0
fi
if git checkout HEAD -- "${DELETED_FILES[@]}"; then
printf "%s\n" "${BOLD}${DELETED_FILES[*]}${RESET}"
printf "%s\n" "Successfully Recovered ${#DELETED_FILES[@]} file(s)"
else
perror "Unable to recover ${BOLD}${DELETED_FILES[*]}${RESET}"
fi
elif [[ "$1" = "commited" ]]; then
read -p "Enter complete filename: " -r FILENAME
COMMIT=$(git log --color --diff-filter=D --oneline | fzf --ansi --height 50% \
@ -275,8 +221,6 @@ undo_file_delete() {
if git checkout "$COMMIT"~1 -- "$FILENAME"; then
printf "%s\n" "${BOLD}$FILENAME${RESET} Successfully Recovered 👍️"
else
perror "Unable to recover ${BOLD}$FILENAME${RESET}"
fi
fi
}
@ -302,8 +246,6 @@ restore_file() {
exit 0
elif [[ "$COMMIT" != "" && "$FILE" != "" ]] && git restore --source="$COMMIT" "$FILE"; then
printf "%s\n" "$FILE restored to version at ${BOLD}$COMMIT${RESET}"
else
perror "Error: unable to perform operation"
fi
}
@ -321,54 +263,6 @@ undo_all() {
# printf "%s\n" "Note: Stashing untracked files might take some time, hold on"
printf "%s\n" "Cleared all changes 👍️"
printf "%s\n" "Run ${BOLD_ORG_FG}git stash apply${RESET} to redo changes or ${BOLD_ORG_FG}git stash drop${RESET} to remove them"
else
perror "Error: unable to perform operation"
fi
}
undo_git_tag() {
# Fetch all tags from remote
if git fetch --all --tags > /dev/null 2>&1; then
printf "\nFetching tags from remote"
else
perror "Unable to fetch tags from remote.Please check repository access."
exit
fi
tag=$(git tag --sort=v:refname | fzf --ansi --height 80% \
--reverse --multi --header="Choose a tag to remove" \
--preview "echo {} | cut -d' ' -f1 | xargs -I{} git show --color --pretty=format:%b {}" \
--bind 'j:down,k:up,ctrl-j:preview-down,ctrl-k:preview-up,ctrl-space:toggle-preview' --preview-window right:60% )
# Exit if no tag is selected
[ -z "$tag" ] && exit
read -p "${BOLD_ORG_FG}Warning:${RESET} Undoing a git tag will remove the tag from both your local repository as well as the remote origin. Do you want to continue [Y/n]?" -n 1 -r USER_INPUT
USER_INPUT=${USER_INPUT:-y}
# Delete git tag
if [[ "$USER_INPUT" == Y || "$USER_INPUT" == y ]] && printf "%s\nDeleting tag: $tag"; then
if git tag -d "$tag" > /dev/null 2>&1; then
git push origin --delete "$tag" > /dev/null 2>&1
printf "%s\n\nTag $tag deleted 👍️\n"
else
perror "Failed to delete tag."
fi
else
exit
fi
}
undo_git_rm(){
# Find all the deleted files from git history
filepath=$(git log --diff-filter=D --summary | grep delete | nl -n ln | fzf --header="Choose the file to restore" --height 50% --ansi --reverse "$pointer" --cycle | awk '{print $5}')
# Find the commit hash value of the selected filepath
commit=$(git log -- "$filepath"| awk 'NR==1{print $2}')
# Restore the file
if git checkout "$commit"^ "$filepath"; then
printf "%s\n" "File $filepath restored successfully."
else
perror "Unable to restore Fie $filepath"
fi
}
@ -393,8 +287,6 @@ ugit_menu() {
17) restore_file;;
18) undo_git_commit;;
19) undo_all;;
20) undo_git_tag;;
21) undo_git_rm;;
esac
}
@ -419,12 +311,6 @@ check_deps() {
for dep in "${deps[@]}"; do
installed "${dep}" || die "Missing dependency: '${dep}'"
done
# if version of fzf < 0.21, do not use --pointer
fzf_version=$(fzf --version | cut -d "." -f 1,2 | tr -d '.()[:alpha:]')
if test "$fzf_version" -ge 021; then
pointer="--pointer=👉"
fi
}
show_version() {
@ -432,33 +318,33 @@ show_version() {
}
print_help() {
printf "Usage: %s [-h] [-v] [-u] [-g]\n" "ugit"
printf "ugit helps you undo git commands without much effort\n"
printf "Just run 'ugit' and search for what you want to undo\n\n"
printf "Available options:\n"
printf " -h, --help Print this help and exit\n"
printf " -v, --version Print current ugit version\n"
printf " -u, --update Update ugit\n"
printf " -g, --guide Open the ugit undo text guide\n\n"
printf "Contact 📬️: %s for assistance\n" "$(tput bold)varshneybhupesh@gmail.com${RESET}"
printf "Read the guide: %s\n" "https://til.bhupesh.me/git/how-to-undo-anything-in-git"
printf "Please give us a ⭐ if you liked ugit %s\n" "${BOLD_ORG_FG}https://github.com/Bhupesh-V/ugit${RESET}"
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-u] [-g]
ugit helps you undo git commands without much effort
Just run 'ugit' and search for what you want to undo
Available options:
-h, --help Print this help and exit
-v, --version Print current ugit version
-u, --update Update ugit
-g, --guide Open ugit undo text guide
EOF
printf "\n%s\n" "Contact 📬️: $(tput bold)varshneybhupesh@gmail.com${RESET} for assistance"
printf "%s\n" "Read the guide: https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git"
printf "\n%s\n" "Please give us ⭐ a if you liked ugit ${BOLD_ORG_FG}https://github.com/Bhupesh-V/ugit${RESET}"
}
get_changelog() {
# get changelog/release notes for the most recent release
REMOTE_REPO="Bhupesh-V/ugit"
CHANGELOG=$(curl -s -L https://api.github.com/repos/$REMOTE_REPO/releases | awk -F=":" '/html_url/ {print $1;exit}' | cut -d ':' -f 2,3 | tr -d "\", ")
printf "Read Full Changelog: %s\n" "${BOLD}${CHANGELOG}${RESET}"
CHANGELOG=$(curl -s -L https://api.github.com/repos/$REMOTE_REPO/releases | awk -F=":" '/body/ {print $1;exit}' | cut -d ':' -f 2 | tr -d "\"")
printf "%s\n" "${BOLD}Changelog:${RESET}"
echo -e "${CHANGELOG#* }"
}
ugit_update() {
if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then
printf "%s\n\n" "You are running version ${VERSION} of ugit via Docker. Please pull the latest docker image to update."
printf "\t%s\n" "${BOLD_ORG_FG}docker pull bhupeshimself/ugit${RESET}"
return
fi
printf "%s\n" "Checking for updates ..."
curl -s -L "$SCRIPT_URL" > "$TMP_FILE"
NEW_VER=$(grep "^VERSION" "$TMP_FILE" | awk -F'[="]' '{print $3}')
@ -478,12 +364,7 @@ ugit_update() {
}
open_guide() {
GUIDE="https://til.bhupesh.me/git/how-to-undo-anything-in-git"
if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then
printf "%s\n" "You can find how ugit does its magic at: ${BOLD_ORG_FG}${GUIDE}${RESET}"
return
fi
GUIDE="https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git"
case "$OSTYPE" in
darwin*)
@ -513,7 +394,7 @@ init_test() {
# test if user is in a git directory or not
if git rev-parse --git-dir > /dev/null 2>&1; then
# check if the current working directory is top level or not
[ "" != "$(git rev-parse --show-cdup)" ] && printf "ugit: %s\n" "Not inside top level dir $(git rev-parse --show-toplevel)"
[ "$(pwd)" != "$(git rev-parse --show-toplevel)" ] && printf "ugit: %s\n" "Not inside top level dir $(git rev-parse --show-toplevel)"
else
printf "%s\n" "Ummm, you are not inside a Git repo 😟"
exit
@ -541,7 +422,7 @@ main() {
check_deps
init_test
header
option=$(display_menu | nl -n ln | fzf --header="Don't worry we all mess up sometimes" --height 50% --ansi --reverse "$pointer" --cycle | awk '{print $1}')
option=$(display_menu | nl -n ln | fzf --header="Don't worry we all mess up sometimes" --height 50% --ansi --reverse --pointer='👉' --cycle | awk '{print $1}')
ugit_menu
fi
}

View file

@ -1,2 +0,0 @@
.flatpak-builder
build-dir

View file

@ -1,45 +0,0 @@
app-id: org.Bhupesh-V.ugit
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: ugit
finish-args:
- --filesystem=home:rw
- --share=network
modules:
- name: fzf
buildsystem: simple
build-commands:
- tar -xvf fzf-0.33.0-linux_amd64.tar.gz
- install -Dm755 fzf ${FLATPAK_DEST}/bin/fzf
sources:
- type: file
url: https://github.com/junegunn/fzf/releases/download/0.33.0/fzf-0.33.0-linux_amd64.tar.gz
sha256: bcf2f4ba957cce15cea1546f48cdd3bfe9b5dc9a6e80ccc400314bda171466f3
- name: git
buildsystem: simple
build-commands:
- install -Dm755 $(which git) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-cvsserver) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-receive-pack) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-shell) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-upload-archive) ${FLATPAK_DEST}/bin/
- install -Dm755 $(which git-upload-pack) ${FLATPAK_DEST}/bin/
- name: ugit
buildsystem: simple
build-options:
build-commands:
- chmod +x ugit
- install -Dm755 ugit ${FLATPAK_DEST}/bin/ugit
- install -Dm755 org.Bhupesh-V.ugit.desktop ${FLATPAK_DEST}/share/applications/org.Bhupesh-V.ugit.desktop
sources:
- type: git
url: https://github.com/Bhupesh-V/ugit
tag: v5.3
commit: 14da50780e696e758bf362489496b74901f84cc1
- type: file
path: org.Bhupesh-V.ugit.desktop

View file

@ -1,5 +0,0 @@
[Desktop Entry]
Name=ugit
Exec=ugit
Type=Application
Terminal=true