1
0
mirror of https://gitlab.com/JKANetwork/jka-toolkit.git synced 2026-02-19 03:21:32 +01:00

Update version number

This commit is contained in:
JoseluCross
2016-09-16 11:37:03 +02:00
parent 497e7d3286
commit 70a4fa7578

View File

@@ -1,138 +1,138 @@
#!/bin/bash #!/bin/bash
# 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="1.0.2" VERSION="1.0.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 repo (Hacer clone)" i "Inicializar nuevo repo"` gitopt=`dialog --stdout --scrollbar --menu "gitdit - Git DIalog inTerface $VERSION" 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 rama " 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 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")
gitdir=`dialog --stdout --inputbox "Directorio del repositorio" 10 60 "."` gitdir=`dialog --stdout --inputbox "Directorio del repositorio" 10 60 "."`
if [ $(echo $gitdir | cut -f1 -d"/") = "~" ];then #~ don't understand like $HOME if [ $(echo $gitdir | cut -f1 -d"/") = "~" ];then #~ don't understand like $HOME
gitdirdef="$HOME" gitdirdef="$HOME"
for (( i=2; i<=$cant; i++ )) for (( i=2; i<=$cant; i++ ))
do do
gitdirdef="$gitdirdef/$(echo $gitdir | cut -f$i -d"/")" gitdirdef="$gitdirdef/$(echo $gitdir | cut -f$i -d"/")"
done done
elif [ $(echo $gitdit | cut -f1 -d"/") = "." ];then elif [ $(echo $gitdit | cut -f1 -d"/") = "." ];then
gitdirdef=$(pwd) gitdirdef=$(pwd)
for (( i=1; i<=$cant; i++ )) for (( i=1; i<=$cant; i++ ))
do do
gitdirdef="$gitdirdef/$(echo $gitdir | cut -f$i -d"/")" gitdirdef="$gitdirdef/$(echo $gitdir | cut -f$i -d"/")"
done done
fi fi
if [ ! -d $gitdir ];then if [ ! -d $gitdir ];then
mkdir -p $gitdirdef 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")
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
if [ -z $giturl ];then
echo "Ningún repositorio especificado"
exit
fi
git clone $giturl
;;
#Staying in a git repo
"p")
git pull $actual;;
"s")
estado=$(git status | grep -E '(^Changes|^Untracked)' ) #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")
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
if [[ -z $commit ]];then
commit="changes"
fi
git add . && git commit -m "$commit"
;;
"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
rama=""
#Loop to create dialog whith all branches (except the current)
for i in $(git branch -a | grep -v "^*" | grep -v "HEAD \->")
do
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 fi
if [ $? -eq 1 ];then done
echo "No tienes permiso para escribir en ese directorio" >> /dev/stderr if [ $error -eq 0 ];then
else aux2=1
cd $gitdirdef fi
git init fi
fi if [ $aux2 -eq 1 ];then
;; rama="$rama $j $aux"
"c") lista[$j]=$aux #Array with the names of branches
giturl=`dialog --stdout --inputbox "URL del git" 10 60` let j++
if [ -z $giturl ];then fi
echo "Ningún repositorio especificado" done
exit ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
fi if [ ! -z $ramificacion ];then
git clone $giturl git checkout ${lista[$ramificacion]}
;; if [ $howopt = "u" ];then
#Staying in a git repo git pull origin ${lista[$ramificacion]}
"p") fi
git pull $actual;; fi
"s") ;;
estado=$(git status | grep -E '(^Changes|^Untracked)' ) #It need to commit something? "n")
if [ "$estado" ];then #When is necesary commit NewBranch=`dialog --stdout --inputbox "Nombre de la nueva rama" 10 50 "new branch"`
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` if [ ! -z $NewBranch ];then
if [[ -z $commit ]];then git checkout -b $NewBranch
commit="changes" fi
fi ;;
git add . && git commit -m "$commit" && git push $actual "m")
else #Nothing to commit, only push j=0
git push $actual rama=""
fi for i in $(git branch --list | grep "^*" -v )
;; do
"t") if [ $i != "*" ];then
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` rama="$rama $j $i"
if [[ -z $commit ]];then lista[$j]=$i
commit="changes" let j++
fi fi
git add . && git commit -m "$commit" done
;; merges=`dialog --stdout --scrollbar --menu "Selecione la rama a unir a $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
"b") if [ ! -z $merges ];then
howopt=`dialog --stdout --scrollbar --menu "Cambiar de rama" 0 0 6 c "Solo cambiar de rama" u "Cambiar de rama y actualizarla"` git merge ${lista[$merges]}
if [ -z $howopt ];then git push $actual
exit fi
fi ;;
j=0 esac
rama="" fi
#Loop to create dialog whith all branches (except the current)
for i in $(git branch -a | grep -v "^*" | grep -v "HEAD \->")
do
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
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
if [ ! -z $ramificacion ];then
git checkout ${lista[$ramificacion]}
if [ $howopt = "u" ];then
git pull origin ${lista[$ramificacion]}
fi
fi
;;
"n")
NewBranch=`dialog --stdout --inputbox "Nombre de la nueva rama" 10 50 "new branch"`
if [ ! -z $NewBranch ];then
git checkout -b $NewBranch
fi
;;
"m")
j=0
rama=""
for i in $(git branch --list | grep "^*" -v )
do
if [ $i != "*" ];then
rama="$rama $j $i"
lista[$j]=$i
let j++
fi
done
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
git merge ${lista[$merges]}
git push $actual
fi
;;
esac
fi