1
0
mirror of https://gitlab.com/JKANetwork/jka-toolkit.git synced 2026-02-24 05:53:48 +01:00

Error control improved, add comments and headers, null option included (cancel button)

This commit is contained in:
JoseluCross
2016-06-29 16:27:34 +02:00
parent b51f5bd9ba
commit 4534dd214c

View File

@@ -1,68 +1,85 @@
#!/bin/bash #!/bin/bash
VERSION="0.2.1" # gitdit, a dialog interface to manage git repositories
# Author: JKA Network - contacto@jkanetwork.com
VERSION="0.2.2"
#First check if the user is in a git repository
preOption=$(git status 2>/dev/stdout | sed -n 1p | cut -f2 -d" ") preOption=$(git status 2>/dev/stdout | sed -n 1p | cut -f2 -d" ")
if [ $preOption = "Not" ];then if [ $preOption = "Not" ];then #When it isn't only it can do git clone
gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface" 0 0 6 c "Descargar un nuevo git (Hacer clone)"` gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface" 0 0 6 c "Descargar un nuevo git (Hacer clone)"`
else else #Else, all other options
gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface" 0 0 6 p "Descargar actualizaciones del git (Hacer pull)" t "Confirmar cambios sin subida" s "Subir actualizaciones al git (Hacer push)" n "Crear nueva rama" b "Cambiar de branch/rama (Hacer checkout)" m "Unir ramas (Hacer merge)"` gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface" 0 0 6 p "Descargar actualizaciones del git (Hacer pull)" t "Confirmar cambios sin subida" s "Subir actualizaciones al git (Hacer push)" n "Crear nueva rama" b "Cambiar de branch/rama (Hacer checkout)" m "Unir ramas (Hacer merge)"`
actual="origin $(git branch --list | grep "^*" | cut -f2 -d" ")" actual="origin $(git branch --list | grep "^*" | cut -f2 -d" ")" #Current branch
fi fi
case $gitopt in if [ ! -z $gitopt ];then #No canceled
"p") git pull $actual;; case $gitopt in
"s") commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` "p")
if [[ -z $commit ]];then git pull $actual;;
commit="changes" "s")
fi estado=$(git status | wc -l) #It need to commit something?
git add . && git commit -m "$commit" && git push $actual if [ $estado -ne 2 ];then #When is necesary commit
;; commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
"c") if [[ -z $commit ]];then
giturl=`dialog --stdout --inputbox "URL del git" 10 60` commit="changes"
git clone $giturl fi
;; git add . && git commit -m "$commit" && git push $actual
"t") else #Nothing to commit, only push
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` git push $actual
if [[ -z $commit ]];then fi
commit="changes" ;;
fi "c")
git add . && git commit -m "$commit" giturl=`dialog --stdout --inputbox "URL del git" 10 60`
;; if [ -z $giturl ];then
"b") echo "Ningún repositorio especificado"
j=0 exit
rama="" fi
for i in $(git branch --list | grep "^*" -v ) git clone $giturl
do ;;
if [ $i != "*" ];then "t")
rama="$rama $j $i" commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
lista[$j]=$i if [[ -z $commit ]];then
let j++ commit="changes"
fi
git add . && git commit -m "$commit"
;;
"b")
j=0
rama=""
for i in $(git branch --list | grep "^*" -v )
do
if [ $i != "*" ];then
rama="$rama $j $i"
lista[$j]=$i
let j++
fi
done
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
if [ ! -z $ramificacion ];then
git checkout ${lista[$ramificacion]}
fi
;;
"n")
NewBranch=`dialog --stdout --inputbox "Nombre de la nueva rama" 10 50 "new branch"`
if [ ! -z $NewBranch ];then
git checkout -b $NewBranch
fi
;;
"m")
j=0
rama=""
for i in $(git branch --list | grep "^*" -v )
do
if [ $i != "*" ];then
rama="$rama $j $i"
lista[$j]=$i
let j++
fi
done
merges=`dialog --stdout --scrollbar --menu "Selecione la rama a unir a $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
if [ ! -z $merges ];then
git merge ${lista[$merges]}
git push
fi fi
done ;;
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama` esac
if [ ! -z $ramificacion ];then fi
git checkout ${lista[$ramificacion]}
fi
;;
"n")
NewBranch=`dialog --stdout --inputbox "Nombre de la nueva rama" 10 50 "new branch"`
if [ ! -z $NewBranch ];then
git checkout -b $NewBranch
fi
;;
"m")
j=0
rama=""
for i in $(git branch --list | grep "^*" -v )
do
if [ $i != "*" ];then
rama="$rama $j $i"
lista[$j]=$i
let j++
fi
done
merges=`dialog --stdout --scrollbar --menu "Selecione la rama a unir a $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
if [ ! -z $merges ];then
git merge ${lista[$merges]}
git push
fi
;;
esac