Code Monkey home page Code Monkey logo

ugit's People

Contributors

allcontributors[bot] avatar bhupesh-v avatar cesarcoatl avatar deepsourcebot avatar dr41d45 avatar engagepy avatar ibayramli avatar kopalchakravarty avatar nalin-singh avatar rohitsingh107 avatar sharan-aithal avatar sullivan-sean avatar t-joseph-kim avatar tabulatejarl8 avatar thmaillarb avatar unixorn avatar vinayaknayar avatar wrecklass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ugit's Issues

Fix empty/null condition edge-cases across ugit

I have overlooked handling edge-cases in multiple places, they need to be fixed for a more robut and error prone ugit.

  1. handle no commit situation when undoing git commit, do not open the FZF menu.
  2. return custom string when tags are not present while undoing git tag, again dont invoke FZF

Keeping this open to add more missed edge-cases as I discover. If you are looking to contribute please create separate PRs for each item listed above

Empty commit list when running `git fsck`

Describe the bug
The command git fsck will return no data if there are no unreachable commits in history.

wat

To Reproduce

  • Create a new git repo
  • Stash something
  • Run ugit and try to undo git stash pop

Expected behavior
ugit should exit if there is no data provided by git fsck

Desktop (please complete the following information):

  • OS: [Ubuntu]
  • Bash Version [5.0.17]
  • FZF Version: [0.27.2]
  • Git Version: [2.35.1]

Additional context
Check for this case while recovering deleted tag as well

Remove usage of HEREDOC in favor of `printf` while printing `--help` text

Is your feature request related to a problem? Please describe.

  • Currently, while showing help text, we rely on bash HEREDOCS. This can also be achieved using multiple printf commands one-by-one.
  • Doing this helps us remove the reliance on cat command altogether from the script.

Describe the solution you'd like

Use printf variations like this for the entirety of the help text

printf "\n%s\n" "Contact πŸ“¬οΈ: $(tput bold)[email protected]${RESET} for assistance"

Describe alternatives you've considered

No response

Sort tags in proper order in "Undo git tag"

Is your feature request related to a problem? Please describe.

The current ugit method to undo_git_tag() calls git tag. This presents the tags in a string sort order that looks incorrectly sorted with numeric tags. For instance:

v1.0
v1.1
v1.10
v1.11
v1.2
v1.3
v1.4

etc.

Describe the solution you'd like

Use git tag --sort=v:refname to present tags in correct order:

v1.0
v1.2
v1.3
v1.4
v1.10
v1.11

etc.

Describe alternatives you've considered

You could create your own sorting method, but why?

publishing to snapcraft

Is your feature request related to a problem? Please describe.
For Linux users, a snap for ugit would be nice so that users don't have to curl the script manually

`--pointer=ᐅ` option not supported by older versions of fzf

Describe the bug
For older versions of fzf, ugit returns the following error when executed:

Undo your last oopsie in Git πŸ™ˆοΈ
unknown option: --pointer=ᐅ

I'm not sure in which version this option was added to fzf but I've tested with version 0.17.3.

To Reproduce
Install an older version fzf (eg. v0.17.3) and run ugit with no parameters.

Expected behavior
ugit should ignore the fzf error or the oldest functioning version of fzf should be added to the list of dependencies.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS 11.3
  • Bash Version: fish 3.2.1
  • FZF Version: 0.17.3

Additional context
N/A

Add AUR Version to README

Is your feature request related to a problem? Please describe.
I have packaged and submitted a version of this package to the AUR, which I can maintain, and if you would like to add it to the README, that would be a pretty easy fix

Describe the solution you'd like
Add instructions on how to install from the AUR to the README

Describe alternatives you've considered
I mean, you could not add it if you want

Git BASH for Windows "Not inside top level dir" warning

Is your feature request related to a problem? Please describe.
I have installed Git for Windows which comes with Git BASH, and ugit prints a warning when executed at the top-level directory of the working tree.

$ mkdir ~/git-repo
$ cd ~/git-repo
$ git init
$ ugit
ugit: Not inside top level dir C:/Users/thecesrom/git-repo
Undo your last oopsie in Git πŸ™ˆοΈ
Press ctrl+c to exit anytime

This is because in Git BASH for Windows $(pwd) is a "UNIX" path, and git rev-parse --show-toplevel is a Windows path.

$ pwd
/c/Users/thecesrom/git-repo
$ git rev-parse --show-toplevel
C:/Users/thecesrom/git-repo

Describe the solution you'd like
After reading Git's documentation for rev-parse I have found a suitable option, and I have a PR #22 ready if you're interested.

In this case git rev-parse --show-cdup is a suitable alternative.

--show-cdup
When the command is invoked from a subdirectory, show the path of the top-level directory relative to the current directory (typically a sequence of "../", or an empty string).

See: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---show-cdup

git rev-parse --show-cdup will only return an empty string if we are at the top-level directory.

$ cd ~/git-repo
$ mkdir -p sub/dir/ect/ory
$ cd sub/dir/ect/ory
$ git rev-parse --show-cdup
../../../../
$ cd ~/git-repo
$ git rev-parse --show-cdup

Describe alternatives you've considered
None.

Additional context
N/A

Add support for running ugit inside docker

Is your feature request related to a problem? Please describe.

We are planning to ship a docker image for ugit, which everyone would be able to pull from dockerhub registry. We need to make few adjustments in ugit for that.

Describe the solution you'd like

To aid this, we will introduce a new boolean ENV variable UGIT_RUNNING_IN_DOCKER. Use this new variabel to perform following things:

  • Don't open the guide when user invokes the script with --guide flag. Instead, just display the URL of the guide.
  • Don't update the script when user invokes the script using --update flag, just print what version of script a user is using, and tell them to pull the latest image.

Other items that are related to this:

Describe alternatives you've considered

No response

auto detect last `git` command

Is your feature request related to a problem? Please describe.
Since v1.0 users have to type what they want to undo. I added this just to give more control to users in choosing how and what they want to undo

Describe the solution you'd like
A new arg/flag --auto should incorporate detecting the last git command to undo.
A simple solution would be to read the user's last 10-15 commands from their $HISTORY file then grep through the file to find basic git commands and trigger the appropriate functions already available.

Additional context
Some git commands would be tricky to detect for e.g. is no way one could defer an unpused merge commit to a merge with conflicts.
the solution should only handle basic git commands like commit, stash which can be easily detected.

Feel free to ask anything below

Videos don't work in Firefox

I'm not sure if you can do anything about this, or if it's the fault of GitHub or something else, but I'll post an issue anyway.

Describe the bug
The videos in the README and on your blog post don't seem to be working in Firefox

To Reproduce
N/A

Expected behavior
N/A

Screenshots

README

image

Blog

image

Desktop (please complete the following information):

  • OS: Manjaro Linux
  • Browser: Firefox 89.0

Additional context
It seems to work in Chromium 90.0.4430.212 and Microsoft Edge 92.0.891.1

fzf before 0.21.0 not supported

What happened?

In older versions of fzf (which are still the default versions in some OSes when installing from the package manager), the option --pointer was not supported. It causes ugit to crash πŸ‘

theotime@THEOTIME-PORTMINT:~/ugit$ ugit
Undo your last oopsie in Git πŸ™ˆοΈ
Press ctrl+c to exit anytime 
unknown option: --pointer=πŸ‘‰

Ugit Version

v5.1 (Latest)

Bash Version

Bash >= 5.0

Git Version

git version 2.25.1

What OS are you seeing the problem on?

Linux Based

Terminal Name

GNOME Terminal

Code of Conduct

  • I agree to follow this project's Code of Conduct

write tests for ugit brew formula

I have a draft formula ready, but need help with writing test

class Ugit < Formula
  desc "Undo git commands. Your damage control git buddy"
  homepage "https://github.com/Bhupesh-V/ugit"
  url "https://github.com/Bhupesh-V/ugit/archive/refs/tags/v4.1.tar.gz"
  sha256 "5ce35179714263412f65cc78c247900c5349bfbf4bd9576e4075aa1a9055e0d6"
  license "MIT"

  depends_on "bash"
  depends_on "fzf"

  def install
    bin.install "ugit"
    bin.install "git-undo"
  end

  test do
   # not good, will be rejected by maintainers probably
    assert_match "ugit version", shell_output("#{bin}/ugit --version")
  end
end

A basic set of tests would include setting up a directory (non-git) and running the command ugit. The expected output should look like

Ummm, you are not inside a Git repo 😟

Apart from that I am out of ideas of what to test. Since both ugit --version & ugit --help are bad examples.

Any suggestions?

undoing `git tag`

Is your feature request related to a problem? Please describe.

Let's say you accidentally create a git tag, feature to rename a git tag would be nice

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Incorrect SGR code in 24-bit terminal

What happened?

  1. Install iTerm2 3.5.0beta6
  2. Run ugit
  3. This happens: https://gitlab.com/gnachman/iterm2/-/issues/10510

The 24-bit color SGR code is missing a CSI leader, causing part of the sequence to be printed to the screen.

Ugit Version

v5.1 (Latest)

Bash Version

Bash >= 5.0

Git Version

git version 2.28.0

What OS are you seeing the problem on?

MacOS

Terminal Name

iTerm2 3.5.0beta6

Code of Conduct

  • I agree to follow this project's Code of Conduct

Undo git commit results in fatal error when the commit to undo is the initial commit

Describe the bug
When the commit to undo is the initial commit, there is no HEAD~, so undoing this commit results in the following error:

$ ugit
fatal: ambiguous argument 'HEAD~': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

To Reproduce

$ cd ~
$ mkdir git-repo
$ cd git-repo
$ git init
Initialized empty Git repository in ~/git-repo/.git/
$ touch README.md
$ git add README.md
$ git commit -a -m "chore: initial commit"
$ ugit
Undo your last oopsie in Git πŸ™ˆοΈ
Press ctrl+c to exit anytime
# 1 Undo git commit
# Choose git commit
fatal: ambiguous argument 'HEAD~': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Expected behavior
The commit should be undone.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

macOS

  • OS: macOS 10.15
  • Bash Version: 5.1.16(1)
  • FZF Version: 0.30.0 (brew)
  • Git Version: 2.35.1

Windows

  • OS: Windows 10
  • Bash Version: 4.4.23(2)
  • FZF Version: 0.30.0 (2093667)
  • Git Version: 2.35.1.windows.2

Additional context
vscode fixed this same issue via: microsoft/vscode#47578

iTerm colors issues

I have a color issue in iTerm, tried different settings/profiles, could not get it work, on the default terminal macos app it works ok, so it's something related to iterm or my settings, do you have any suggestions?
Thank you for this great tool!
image

git-undo symlink conflicts with git-extras

Describe the bug
If you have git-extras installed that has a git-undo command, ugit can conflict with it.
E.g.: This is what I get when I try to install ugit when git-extras is already installed.

==> Pouring ugit--5.1.all.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/git-undo
Target /usr/local/bin/git-undo
is a symlink belonging to git-extras. You can unlink it:
  brew unlink git-extras

To force the link and overwrite all conflicting files:
  brew link --overwrite ugit

To list all files that would be deleted:
  brew link --overwrite --dry-run ugit

Possible conflicting files are:
/usr/local/bin/git-undo -> /usr/local/Cellar/git-extras/6.4.0/bin/git-undo
==> Summary
🍺  /usr/local/Cellar/ugit/5.1: 6 files, 28.7KB
==> Running `brew cleanup ugit`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

To Reproduce

brew install git-extras
brew install ugit

Expected behavior
That's a great question and I'm not sure about it. I think there are a few options:

  1. Renaming the git-undo symlink but I'm not sure I can think of an alternative name and this will break existing users who happily run git undo (I also like git undo)
  2. As far as I know Homebrew has some mechanism to deal with conflicting formulae but I'm not sure how it works
  3. Call this out in the readme and in the Homebrew description, the error above is not a fatal one, only the symlink is missing so ugit works but git undo comes from git-extras. If the user decides they want git undo to execute ugit, they just need ask Homebrew to overwrite the link: brew link --overwrite ugit

Desktop (please complete the following information):

  • OS: macOS 12.4 (build: 21F79)
  • Bash Version zsh 5.8.1 (x86_64-apple-darwin21.0)
  • FZF Version: 0.30.0 (brew)
  • Git Version: git version 2.36.1
  • git-extras Version: 6.4.0
  • Homebrew Version: Homebrew 3.5.2
Homebrew/homebrew-core (git revision 3033e2a3b66; last commit 2022-06-18)
Homebrew/homebrew-cask (git revision e83c83c0a2; last commit 2022-06-18)

Additional context
The change was introduced with this issue: #15

Add a git-undo symlink

git will call scripts that are named git-SOMETHING when you run git SOMETHING.

Describe the solution you'd like

Add a git-undo symlink to ugit to make it callable consistently with other git commands as git undo.

Additional context

This will make using ugit more pleasant since it'll be consistent with other git commands.

I'd like to add an oh-my-zsh-compatible plugin file

I'd like to add an oh-my-zsh compatible plugin file. This will let users of oh-my-zsh compatible shell frameworks automatically add ugit to their shell setup, and with some frameworks, automatically keep it up to date by periodically running git pull.

Describe the solution you'd like

Basically I'm going to write a very short (~3 lines of code) plugin file that the frameworks can load to automatically add the ugit repository to the user's $PATH.

Ability to travel back b/w TUI panes

Is your feature request related to a problem? Please describe.

It's possible that a user might hit enter on an incorrect item from the list. Any pets on the keyboard?

Describe the solution you'd like

  • Check if travelling b/w menu options is possible
  • Document where we can travel back
  • Set a keystroke to go back

Describe alternatives you've considered

No response

Add tput to dependency list

At first thanks for bringing such an undoing tool entirely in Bash.

What is the problem?

tput is maybe missing in some other os. I think it is better to add it in dependency list of ugit.

I would like to contribute if I have any new feature to add it here.😍

installation docs for Windows

ugit should work on Windows considering we have either git bash installed or WSL working with the FZF binary.
It would be nice to have docs to install ugit the correct way.

Any help/suggestions are appreciated πŸ’™

ugit (via docker) does not resolve that it is in a git repo.

What happened?

Attempted invoking ugit via

docker pull bhupeshimself/ugit
docker run --rm -it -v $(pwd):/app bhupeshimself/ugit

Even in the ugit repo that has been cloned (or any other git repo), always get the following message:

Ummm, you are not inside a Git repo 😟

Test Repo

/home/auser/Projects/TestGitRepo
total 58
drwxrwxr-x 3 auser auser 4 Feb 5 15:45 .
drwxrwxr-x 300 auser auser 305 Feb 5 15:58 ..
drwxrwxr-x 8 auser auser 14 Feb 5 15:45 .git
-rwxrwxr-x 1 auser auser 147 Feb 5 15:44 ungitInvoke

Using the script directly works fine.

Maybe a missing environment variable or volume mapping that is unaccounted for?

Ugit Version

v5.1 (Latest)

Bash Version

Bash >= 5.0

Git Version

Whatever versions that are in the current docker image for all of the above.

❯ docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
bhupeshimself/ugit latest 6c57f819c864 2 days ago 14.9MB

What OS are you seeing the problem on?

Linux Based

Terminal Name

SSH'ed into Ubuntu 22.04 host.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Undo `git worktree remove`

Is your feature request related to a problem? Please describe.

Add the ability to undo the "removal of a git worktree"

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

remove usage of `basename` on `--help` argument

Is your feature request related to a problem? Please describe.

Currently when printing help text for ugit ugit --help, we figure out the basename of the current running script. Which seems and looks good but adds unnecessary overhead of external command usage.

 $(basename "${BASH_SOURCE[0]}")

More about BASH_SOURCE

BASH_SOURCE
                An array variable whose members are the source filenames where
                the corresponding shell function names in the FUNCNAME array
                variable are defined.  The shell function ${FUNCNAME[$i]} is
*               defined in the file ${BASH_SOURCE[$i]} and called from
*               ${BASH_SOURCE[$i+1]}.

Describe the solution you'd like

Just reference "ugit" string directly.

Describe alternatives you've considered

No response

unhandled `fzf --version` output

What happened?

When executing ugit. It’s checks for fzf version on line ugit#L410 and excepts an integer.

However, the output of fzf --version in my device is:

$ fzf β€”-version
0.29 (devel)

Hence, the script couldn’t handle the string part and exited.

You can add the cut or tr to split by spaces and get the first element.

fzf_version=$(fzf β€”-version | cut -d " " -f 1 | cut -d "." -f 1,2 | tr -d '.')

Ugit Version

v5.1 (Latest)

Bash Version

Bash >= 5.0

Git Version

2.38.2

What OS are you seeing the problem on?

Linux Based

Terminal Name

zsh

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.