mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-03-12 21:42:04 +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
|
# gitdit, a dialog interface to manage git repositories
|
||||||
# Author: JKA Network - contacto@jkanetwork.com
|
# Author: JKA Network - contacto@jkanetwork.com
|
||||||
|
|
||||||
VERSION="0.3.0"
|
VERSION="1.0.0"
|
||||||
#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
|
||||||
@@ -10,6 +10,7 @@ if [ $preOption = "Not" ];then #When it isn't only it can do git clone
|
|||||||
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
|
||||||
|
actual2=$(git branch --list | grep "^*" | cut -f2 -d" ") #Current branch name
|
||||||
fi
|
fi
|
||||||
if [ ! -z $gitopt ];then #No canceled
|
if [ ! -z $gitopt ];then #No canceled
|
||||||
case $gitopt in
|
case $gitopt in
|
||||||
@@ -68,14 +69,32 @@ if [ ! -z $gitopt ];then #No canceled
|
|||||||
j=0
|
j=0
|
||||||
rama=""
|
rama=""
|
||||||
#Loop to create dialog whith all branches (except the current)
|
#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
|
do
|
||||||
if [ $i != "*" ];then
|
aux2=0
|
||||||
rama="$rama $j $i"
|
if [ -z $(echo $i | grep -o "remotes") ];then
|
||||||
lista[$j]=$i #Array with the names of branches
|
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++
|
let j++
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
read
|
||||||
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
|
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
|
||||||
if [ ! -z $ramificacion ];then
|
if [ ! -z $ramificacion ];then
|
||||||
git checkout ${lista[$ramificacion]}
|
git checkout ${lista[$ramificacion]}
|
||||||
|
|||||||
Reference in New Issue
Block a user