💄 Finished up bgit v2

This commit is contained in:
z3rOR0ne 2022-09-08 00:29:06 -07:00
parent b2dc0c5d54
commit dfcd302615
2 changed files with 52 additions and 10 deletions

26
scripts/bgit_revert Normal file
View file

@ -0,0 +1,26 @@
#!/bin/bash
function b_revert() {
read -e -r -p "${txtblue} Would you like to revert back to a previous commit?: ${txtyellow}" revert
tput bold & tput setaf 7
if [[ $revert == "y" || $revert == "yes" ]] ; then
commitarray=($(git log -6 | grep commit | sed 's/commit//g'))
verbosecommits=$(git shortlog -6 --reverse | sed 1d);
numcommits=6
for ((i = 0; i < numcommits; i++)) do
j=$(echo ${i} + 1 | bc)
nextcommit=$(echo "${verbosecommits}" | head -n $j | tail -n 1)
echo -e "${i}) ${txtyellow}${commitarray[$i]}${txtblue}${nextcommit}${txtwhite}"
done
read -e -r -p "${txtblue} Choose commit to revert back to: ${txtyellow}" version
echo "${txtblue} Reverting back to version: ${txtyellow}${commitarray[$version]}"
git reset --hard ${commitarray[$version]}
for ((i = 0; i < numrepos; i++)) ; do
git push --force ${remotearray[i]} ;
done
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
exit 0
else
echo "${txtblue} No revisions to git branch have been made.${txtwhite}"
fi
}