1
0
mirror of https://gitlab.com/JKANetwork/jka-toolkit.git synced 2026-02-21 12:23:46 +01:00

Merge branch 'development'

This commit is contained in:
JoseluCross
2016-09-16 11:45:14 +02:00
3 changed files with 131 additions and 126 deletions

BIN
jka-toolkit/.gitdit.swp Normal file

Binary file not shown.

View File

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

View File

@@ -39,7 +39,7 @@ function msg2() {
echo echo
} }
version="2.3.0" version="2.3.1"
if [ -z "$1" ];then if [ -z "$1" ];then
echo "$(gettext "No option specified, use jkazip -h")" > /dev/stderr echo "$(gettext "No option specified, use jkazip -h")" > /dev/stderr
elif [ "$1" = "-h" ];then elif [ "$1" = "-h" ];then
@@ -122,7 +122,7 @@ elif [ "$1" = "-c" ];then
### Funcion nueva ### Funcion nueva
for compfile in "$@"; do for compfile in "$@"; do
if [[ "$compfile" != "$1" && "$compfile" != "$2" ]];then if [[ "$compfile" != "$1" && "$compfile" != "$2" ]];then
if [ ! -d "$compfile" -a ! -f "$compfile" ];then if [[ ! -d "$compfile" && ! -f "$compfile" ]];then
printf -- "$(gettext "%s no such file or directory")" "$compfile" printf -- "$(gettext "%s no such file or directory")" "$compfile"
echo echo
#exit #exit
@@ -154,7 +154,7 @@ elif [ "$1" = "-c" ];then
msg "$files" "$salida" msg "$files" "$salida"
;; ;;
"zip") "zip")
zip "$salida" $files zip -r "$salida" $files
msg "$files" "$salida" msg "$files" "$salida"
;; ;;
"gz" | "lz") "gz" | "lz")