Skip to content

Commit

Permalink
Add environment variable "GIR_FORCEALL"
Browse files Browse the repository at this point in the history
Annoyed whenever you need to remove something but Git needs you to force it?
Now you can run Gir with the environment variable GIR_FORCEALL
Set it to either 1, TRUE or true and it will know to force all git operations.
  • Loading branch information
kevadesu authored and kevadesu committed Jan 18, 2025
1 parent ea98dfd commit 9ebd457
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ function gir.main() {
git add $(ls | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...")
;;
"Remove files from commit")
git rm $(ls | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...")
case $GIR_FORCEALL in
1|TRUE|true)
git rm $(ls | gum filter --selected-indicator.foreground="#d20f39" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Remove files" --prompt="| " --indicator="> " --selected-prefix "REMOVE " --unselected-prefix " KEEP " --placeholder "Press TAB to select, Enter to confirm...") -f
;;
*)
git rm $(ls | gum filter --selected-indicator.foreground="#d20f39" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Remove files" --prompt="| " --indicator="> " --selected-prefix "REMOVE " --unselected-prefix " KEEP " --placeholder "Press TAB to select, Enter to confirm...")
;;
esac
;;
"Commit")
git commit -m "$(gum input --cursor.foreground="#fe640b" --width 50 --placeholder "Summary of changes")" \
Expand All @@ -48,7 +55,7 @@ function gir.main() {
git stash
;;
"Switch branch")
git checkout $(git branch | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --header "Select hash to undo" --prompt="| " --indicator="> " | sed 's/* //g' | sed 's/ //g')
git checkout $(git branch | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --header "Select branch to switch to" --prompt="| " --indicator="> " | sed 's/* //g' | sed 's/ //g')
;;
"(Re)initialise repository")
git init
Expand Down Expand Up @@ -104,7 +111,7 @@ function gir.wrongbranch() {
}

function gir.undocommit() {
SEL_HASH=$(git log --oneline | gum filter | cut -d' ' -f1)
SEL_HASH=$(git log --oneline | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Select hash to undo" --prompt="| " --indicator="> " | cut -d' ' -f1)
git revert $SEL_HASH
}

Expand Down

0 comments on commit 9ebd457

Please # to comment.