mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-02-14 17:11:32 +01:00
Merge branch 'development'
This commit is contained in:
@@ -2,20 +2,38 @@
|
|||||||
# 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.3"
|
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
|
||||||
gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface" 0 0 6 c "Descargar un nuevo repo (Hacer clone)"" i "Inicializar nuevo repo"`
|
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 rama " 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
|
||||||
#Not staying in a git repo
|
#Not staying in a git repo
|
||||||
"i")
|
"i")
|
||||||
git init
|
gitdir=`dialog --stdout --inputbox "Directorio del repositorio" 10 60 "."`
|
||||||
|
if [ $(echo $gitdir | cut -f1 -d"/") = "~" ];then #~ don't understand like $HOME
|
||||||
|
cant=$(echo $gitdir | grep -o "/" | wc -l)
|
||||||
|
gitdirdef="$HOME"
|
||||||
|
for (( i=2; i<=$cant; i++ ))
|
||||||
|
do
|
||||||
|
gitdirdef="$gitdirdef/$(echo $gitdir | cut -f$i -d"/")"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ ! -d $gitdir ];then
|
||||||
|
mkdir -p $gitdirdef
|
||||||
|
fi
|
||||||
|
if [ $? -eq 1 ];then
|
||||||
|
echo "No tienes permiso para escribir en ese directorio" >> /dev/stderr
|
||||||
|
else
|
||||||
|
cd $gitdirdef
|
||||||
|
git init
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"c")
|
"c")
|
||||||
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
|
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
|
||||||
@@ -29,7 +47,7 @@ if [ ! -z $gitopt ];then #No canceled
|
|||||||
"p")
|
"p")
|
||||||
git pull $actual;;
|
git pull $actual;;
|
||||||
"s")
|
"s")
|
||||||
estado=$(git status | grep "^Changes" ) #It need to commit something?
|
estado=$(git status | grep -o "^Changes" ) #It need to commit something?
|
||||||
if [ $estado ];then #When is necesary commit
|
if [ $estado ];then #When is necesary commit
|
||||||
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
|
||||||
@@ -48,20 +66,44 @@ if [ ! -z $gitopt ];then #No canceled
|
|||||||
git add . && git commit -m "$commit"
|
git add . && git commit -m "$commit"
|
||||||
;;
|
;;
|
||||||
"b")
|
"b")
|
||||||
|
howopt=`dialog --stdout --scrollbar --menu "Cambiar de rama" 0 0 6 c "Solo cambiar de rama" u "Cambiar de rama y actualizarla"`
|
||||||
|
if [ -z $howopt ];then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
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 =s ${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
|
||||||
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]}
|
||||||
|
if [ $howopt = "u" ];then
|
||||||
|
git pull origin ${lista[$ramificacion]}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"n")
|
"n")
|
||||||
@@ -84,7 +126,7 @@ if [ ! -z $gitopt ];then #No canceled
|
|||||||
merges=`dialog --stdout --scrollbar --menu "Selecione la rama a unir a $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
|
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
|
if [ ! -z $merges ];then
|
||||||
git merge ${lista[$merges]}
|
git merge ${lista[$merges]}
|
||||||
git push
|
git push $actual
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user