From bd093290b357aa02bffde79e10ab672bc99e5cce Mon Sep 17 00:00:00 2001 From: JoseluCross Date: Thu, 30 Jun 2016 13:07:35 +0200 Subject: [PATCH 1/6] Error correction ("), improve error control (~ to $HOME) --- jka-toolkit/gitdit | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index 1b80a97..dca66f3 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -2,11 +2,11 @@ # gitdit, a dialog interface to manage git repositories # Author: JKA Network - contacto@jkanetwork.com -VERSION="0.2.3" +VERSION="0.3.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 - 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 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 @@ -15,7 +15,24 @@ if [ ! -z $gitopt ];then #No canceled case $gitopt in #Not staying in a git repo "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") giturl=`dialog --stdout --inputbox "URL del git" 10 60` @@ -29,7 +46,7 @@ if [ ! -z $gitopt ];then #No canceled "p") git pull $actual;; "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 commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"` if [[ -z $commit ]];then From 786f3bcea23e6ef5cdfe3534cf09096e2b7054fa Mon Sep 17 00:00:00 2001 From: JoseluCross Date: Thu, 30 Jun 2016 13:14:41 +0200 Subject: [PATCH 2/6] Add $actual in merge option (before it isn't there) --- jka-toolkit/gitdit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index dca66f3..d0a0dd2 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -101,7 +101,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` if [ ! -z $merges ];then git merge ${lista[$merges]} - git push + git push $actual fi ;; esac From ebd76a6b9bf742fc43a1d473cb3022388f3e371e Mon Sep 17 00:00:00 2001 From: JoseluCross Date: Thu, 30 Jun 2016 15:03:44 +0200 Subject: [PATCH 3/6] Checkout options improved to cloned repositories (when the branch never used before) --- jka-toolkit/gitdit | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index d0a0dd2..e8b2178 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -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]} From 7cbd484b4d67cd388790ae7a43aa2d2fe337087e Mon Sep 17 00:00:00 2001 From: JoseluCross Date: Thu, 30 Jun 2016 15:39:03 +0200 Subject: [PATCH 4/6] JoseluCross is stupid, read sentense removed --- jka-toolkit/gitdit | 1 - 1 file changed, 1 deletion(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index e8b2178..3b06665 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -94,7 +94,6 @@ if [ ! -z $gitopt ];then #No canceled 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]} From fd786666526edc8ad41e0e996018f567e2c23dc9 Mon Sep 17 00:00:00 2001 From: JoseluCross Date: Thu, 30 Jun 2016 16:16:04 +0200 Subject: [PATCH 5/6] add option, update before change branch --- jka-toolkit/gitdit | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index 3b06665..3ac39b9 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -8,7 +8,7 @@ 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 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 - 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 " u "Cambiar de rama y actualizar" 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 @@ -65,7 +65,7 @@ if [ ! -z $gitopt ];then #No canceled fi git add . && git commit -m "$commit" ;; - "b") + "b" | "u") j=0 rama="" #Loop to create dialog whith all branches (except the current) @@ -80,7 +80,7 @@ if [ ! -z $gitopt ];then #No canceled 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 + if [ $aux =s ${lista[$i]} -o $aux = $actual2 ];then error=1 fi done @@ -97,6 +97,9 @@ if [ ! -z $gitopt ];then #No canceled ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama` if [ ! -z $ramificacion ];then git checkout ${lista[$ramificacion]} + if [ $gitopt = "u" ];then + git pull origin ${lista[$ramificacion]} + fi fi ;; "n") From c6e9506edfc7c1f8ed7a8eb68064aa4f09dbd730 Mon Sep 17 00:00:00 2001 From: kprkpr Date: Thu, 30 Jun 2016 16:20:34 +0200 Subject: [PATCH 6/6] Changed form of change branch --- jka-toolkit/gitdit | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jka-toolkit/gitdit b/jka-toolkit/gitdit index 3ac39b9..ff557f4 100755 --- a/jka-toolkit/gitdit +++ b/jka-toolkit/gitdit @@ -8,7 +8,7 @@ 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 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 - 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 " u "Cambiar de rama y actualizar" 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 actual2=$(git branch --list | grep "^*" | cut -f2 -d" ") #Current branch name fi @@ -65,7 +65,11 @@ if [ ! -z $gitopt ];then #No canceled fi git add . && git commit -m "$commit" ;; - "b" | "u") + "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) @@ -97,7 +101,7 @@ if [ ! -z $gitopt ];then #No canceled ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama` if [ ! -z $ramificacion ];then git checkout ${lista[$ramificacion]} - if [ $gitopt = "u" ];then + if [ $howopt = "u" ];then git pull origin ${lista[$ramificacion]} fi fi