mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-02-17 18:41:34 +01:00
Merge branch 'development'
This commit is contained in:
BIN
jka-toolkit/.gitdit.swp
Normal file
BIN
jka-toolkit/.gitdit.swp
Normal file
Binary file not shown.
@@ -1,133 +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
|
||||||
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
|
||||||
|
gitdirdef=$(pwd)
|
||||||
|
for (( i=1; 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`
|
||||||
|
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 [ ! -d $gitdir ];then
|
done
|
||||||
mkdir -p $gitdirdef
|
if [ $error -eq 0 ];then
|
||||||
fi
|
aux2=1
|
||||||
if [ $? -eq 1 ];then
|
fi
|
||||||
echo "No tienes permiso para escribir en ese directorio" >> /dev/stderr
|
fi
|
||||||
else
|
if [ $aux2 -eq 1 ];then
|
||||||
cd $gitdirdef
|
rama="$rama $j $aux"
|
||||||
git init
|
lista[$j]=$aux #Array with the names of branches
|
||||||
fi
|
let j++
|
||||||
;;
|
fi
|
||||||
"c")
|
done
|
||||||
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
|
ramificacion=`dialog --stdout --scrollbar --menu "Selecione la rama a saltar" 0 0 6 $rama`
|
||||||
if [ -z $giturl ];then
|
if [ ! -z $ramificacion ];then
|
||||||
echo "Ningún repositorio especificado"
|
git checkout ${lista[$ramificacion]}
|
||||||
exit
|
if [ $howopt = "u" ];then
|
||||||
fi
|
git pull origin ${lista[$ramificacion]}
|
||||||
git clone $giturl
|
fi
|
||||||
;;
|
fi
|
||||||
#Staying in a git repo
|
;;
|
||||||
"p")
|
"n")
|
||||||
git pull $actual;;
|
NewBranch=`dialog --stdout --inputbox "Nombre de la nueva rama" 10 50 "new branch"`
|
||||||
"s")
|
if [ ! -z $NewBranch ];then
|
||||||
estado=$(git status | grep -E '(^Changes|^Untracked)' ) #It need to commit something?
|
git checkout -b $NewBranch
|
||||||
if [ "$estado" ];then #When is necesary commit
|
fi
|
||||||
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
|
;;
|
||||||
if [[ -z $commit ]];then
|
"m")
|
||||||
commit="changes"
|
j=0
|
||||||
fi
|
rama=""
|
||||||
git add . && git commit -m "$commit" && git push $actual
|
for i in $(git branch --list | grep "^*" -v )
|
||||||
else #Nothing to commit, only push
|
do
|
||||||
git push $actual
|
if [ $i != "*" ];then
|
||||||
fi
|
rama="$rama $j $i"
|
||||||
;;
|
lista[$j]=$i
|
||||||
"t")
|
let j++
|
||||||
commit=`dialog --stdout --inputbox "Cambios (texto commit)" 10 50 "changes"`
|
fi
|
||||||
if [[ -z $commit ]];then
|
done
|
||||||
commit="changes"
|
merges=`dialog --stdout --scrollbar --menu "Selecione la rama a unir a $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
|
||||||
fi
|
if [ ! -z $merges ];then
|
||||||
git add . && git commit -m "$commit"
|
git merge ${lista[$merges]}
|
||||||
;;
|
git push $actual
|
||||||
"b")
|
fi
|
||||||
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
|
esac
|
||||||
exit
|
fi
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function msg() {
|
|||||||
local var="$1"
|
local var="$1"
|
||||||
local var2="$2"
|
local var2="$2"
|
||||||
printf -- "$(gettext "File/s %s has/have been compressed in %s")" "$var" "$var2"
|
printf -- "$(gettext "File/s %s has/have been compressed in %s")" "$var" "$var2"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
#Function msg2, print in stdout a final message
|
#Function msg2, print in stdout a final message
|
||||||
function msg2() {
|
function msg2() {
|
||||||
@@ -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,9 +122,9 @@ 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
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -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")
|
||||||
@@ -189,7 +189,7 @@ elif [ "$1" = "-l" ];then
|
|||||||
tar taf "$2"
|
tar taf "$2"
|
||||||
;;
|
;;
|
||||||
"7z")
|
"7z")
|
||||||
7z l "$2"
|
7z l "$2"
|
||||||
;;
|
;;
|
||||||
"zip")
|
"zip")
|
||||||
unzip -v "$2"
|
unzip -v "$2"
|
||||||
|
|||||||
Reference in New Issue
Block a user