mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-02-22 04:54:13 +01:00
Error control improved, add comments and headers, null option included (cancel button)
This commit is contained in:
@@ -1,22 +1,38 @@
|
||||
#!/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" ")
|
||||
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)"`
|
||||
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)"`
|
||||
actual="origin $(git branch --list | grep "^*" | cut -f2 -d" ")"
|
||||
actual="origin $(git branch --list | grep "^*" | cut -f2 -d" ")" #Current branch
|
||||
fi
|
||||
if [ ! -z $gitopt ];then #No canceled
|
||||
case $gitopt in
|
||||
"p") git pull $actual;;
|
||||
"s") commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
|
||||
"p")
|
||||
git pull $actual;;
|
||||
"s")
|
||||
estado=$(git status | wc -l) #It need to commit something?
|
||||
if [ $estado -ne 2 ];then #When is necesary commit
|
||||
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
|
||||
if [[ -z $commit ]];then
|
||||
commit="changes"
|
||||
fi
|
||||
git add . && git commit -m "$commit" && git push $actual
|
||||
else #Nothing to commit, only push
|
||||
git push $actual
|
||||
fi
|
||||
;;
|
||||
"c")
|
||||
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
|
||||
if [ -z $giturl ];then
|
||||
echo "Ningún repositorio especificado"
|
||||
exit
|
||||
fi
|
||||
git clone $giturl
|
||||
;;
|
||||
"t")
|
||||
@@ -66,3 +82,4 @@ case $gitopt in
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
Reference in New Issue
Block a user