mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-03-09 12:02:05 +01:00
Checkout options improved to cloned repositories (when the branch never used before)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# gitdit, a dialog interface to manage git repositories
|
||||
# Author: JKA Network - contacto@jkanetwork.com
|
||||
|
||||
VERSION="0.3.0"
|
||||
VERSION="1.0.0"
|
||||
#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 #When it isn't only it can do git clone
|
||||
@@ -10,6 +10,7 @@ if [ $preOption = "Not" ];then #When it isn't only it can do git clone
|
||||
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" ")" #Current branch
|
||||
actual2=$(git branch --list | grep "^*" | cut -f2 -d" ") #Current branch name
|
||||
fi
|
||||
if [ ! -z $gitopt ];then #No canceled
|
||||
case $gitopt in
|
||||
@@ -68,14 +69,32 @@ if [ ! -z $gitopt ];then #No canceled
|
||||
j=0
|
||||
rama=""
|
||||
#Loop to create dialog whith all branches (except the current)
|
||||
for i in $(git branch --list | grep "^*" -v )
|
||||
for i in $(git branch -a | grep -v "^*" | grep -v "HEAD \->")
|
||||
do
|
||||
if [ $i != "*" ];then
|
||||
rama="$rama $j $i"
|
||||
lista[$j]=$i #Array with the names of branches
|
||||
let j++
|
||||
fi
|
||||
aux2=0
|
||||
if [ -z $(echo $i | grep -o "remotes") ];then
|
||||
aux=$i
|
||||
aux2=1
|
||||
else
|
||||
aux=$(echo $i | cut -f3 -d"/")
|
||||
error=0 #If 1 aux is yet in lista array
|
||||
for (( i=0;i<${#lista[@]} && error==0;i++ ))
|
||||
do
|
||||
if [ $aux = ${lista[$i]} -o $aux = $actual2 ];then
|
||||
error=1
|
||||
fi
|
||||
done
|
||||
if [ $error -eq 0 ];then
|
||||
aux2=1
|
||||
fi
|
||||
fi
|
||||
if [ $aux2 -eq 1 ];then
|
||||
rama="$rama $j $aux"
|
||||
lista[$j]=$aux #Array with the names of branches
|
||||
let j++
|
||||
fi
|
||||
done
|
||||
read
|
||||
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
|
||||
if [ ! -z $ramificacion ];then
|
||||
git checkout ${lista[$ramificacion]}
|
||||
|
||||
Reference in New Issue
Block a user