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

Improved update option and include init option

This commit is contained in:
JoseluCross
2016-06-29 19:51:54 +02:00
parent 6d1ffe8fa2
commit 3b62d77253

View File

@@ -2,30 +2,20 @@
# gitdit, a dialog interface to manage git repositories # gitdit, a dialog interface to manage git repositories
# Author: JKA Network - contacto@jkanetwork.com # Author: JKA Network - contacto@jkanetwork.com
VERSION="0.2.2" VERSION="0.2.3"
#First check if the user is in a git repository #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 #When it isn't only it can do git clone 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 repo (Hacer clone)"" i "Inicializar nuevo repo"`
else #Else, all other options 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" ")" #Current branch actual="origin $(git branch --list | grep "^*" | cut -f2 -d" ")" #Current branch
fi fi
if [ ! -z $gitopt ];then #No canceled if [ ! -z $gitopt ];then #No canceled
case $gitopt in case $gitopt in
"p") #Not staying in a git repo
git pull $actual;; "i")
"s") git init
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") "c")
giturl=`dialog --stdout --inputbox "URL del git" 10 60` giturl=`dialog --stdout --inputbox "URL del git" 10 60`
@@ -35,6 +25,21 @@ if [ ! -z $gitopt ];then #No canceled
fi fi
git clone $giturl git clone $giturl
;; ;;
#Staying in a git repo
"p")
git pull $actual;;
"s")
estado=$(git status | grep "^Changes" ) #It need to commit something?
if [ $estado ];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
;;
"t") "t")
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
if [[ -z $commit ]];then if [[ -z $commit ]];then
@@ -45,11 +50,12 @@ if [ ! -z $gitopt ];then #No canceled
"b") "b")
j=0 j=0
rama="" rama=""
#Loop to create dialog whith all branches (except the current)
for i in $(git branch --list | grep "^*" -v ) for i in $(git branch --list | grep "^*" -v )
do do
if [ $i != "*" ];then if [ $i != "*" ];then
rama="$rama $j $i" rama="$rama $j $i"
lista[$j]=$i lista[$j]=$i #Array with the names of branches
let j++ let j++
fi fi
done done