Created
May 31, 2019 16:34
-
-
Save adregan/8619a35499346600746bda4a94f27dc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fixup | |
set -lx current_branch (git rev-parse --abbrev-ref HEAD) | |
set -lx commits (git log --oneline $current_branch...origin/master)[-1..1] | |
set -lx len (count $commits) | |
printf "Fixup: Which commit would you like to fixup? \n\n" | |
for i in (seq $len) | |
printf "$i) $commits[$i]\n" | |
end | |
printf "\n" | |
while true | |
read -l -P "> " selection | |
if test "$selection" -gt $len -o "$selection" -lt 1 | |
printf "\nSelection must be a number from 1–$len\n\n" | |
continue | |
else | |
set -lx commit $commits[$selection] | |
printf "\nMarking \"$commit\" for fixup\n\n" | |
set -lx hash (string split " " $commit)[1] | |
git commit --fixup=$hash | |
return | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment