mirror of
https://gitlab.com/JKANetwork/jka-toolkit.git
synced 2026-02-14 09:01:31 +01:00
Ident file and grammar fix
This commit is contained in:
@@ -13,137 +13,139 @@ else #Else, all other options
|
|||||||
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
|
#Options not in a git repo
|
||||||
"i")
|
"i")
|
||||||
gitdir=`dialog --stdout --inputbox "Repo directory" 10 60 "."`
|
gitdir=`dialog --stdout --inputbox "Repo directory" 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
|
|
||||||
if [ ! -d $gitdir ];then
|
|
||||||
mkdir -p $gitdirdef
|
|
||||||
fi
|
|
||||||
if [ $? -eq 1 ];then
|
|
||||||
echo "You dont have permission to write in this directory" >> /dev/stderr
|
|
||||||
else
|
|
||||||
cd $gitdirdef
|
|
||||||
git init
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"c")
|
|
||||||
giturl=`dialog --stdout --inputbox "URL del git" 10 60`
|
|
||||||
if [ -z $giturl ];then
|
|
||||||
echo "No repository there."
|
|
||||||
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 "Changes text: " 10 50 "changes"`
|
|
||||||
if [[ -z $commit ]];then
|
|
||||||
commit="changes"
|
|
||||||
fi
|
|
||||||
git add -A && git commit -m "$commit" && git push $actual
|
|
||||||
else #Nothing to commit, only push
|
|
||||||
git push $actual
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"t")
|
|
||||||
commit=`dialog --stdout --inputbox "Changes text: " 10 50 "changes"`
|
|
||||||
if [[ -z $commit ]];then
|
|
||||||
commit="changes"
|
|
||||||
fi
|
|
||||||
git add -A && git commit -m "$commit"
|
|
||||||
;;
|
|
||||||
"b")
|
|
||||||
howopt=`dialog --stdout --scrollbar --menu "Change branch" 0 0 6 c "Only change branch" u "Change branch and update it"`
|
|
||||||
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
|
||||||
done
|
if [ ! -d $gitdir ];then
|
||||||
if [ $error -eq 0 ];then
|
mkdir -p $gitdirdef
|
||||||
aux2=1
|
fi
|
||||||
fi
|
if [ $? -eq 1 ];then
|
||||||
fi
|
echo "You dont have permission to write in this directory" >> /dev/stderr
|
||||||
if [ $aux2 -eq 1 ];then
|
else
|
||||||
rama="$rama $j $aux"
|
cd $gitdirdef
|
||||||
lista[$j]=$aux #Array with the names of branches
|
git init
|
||||||
let j++
|
fi
|
||||||
fi
|
;;
|
||||||
done
|
"c")
|
||||||
ramificacion=`dialog --stdout --scrollbar --menu "Select branch to goto" 0 0 6 $rama`
|
giturl=`dialog --stdout --inputbox "git URL: " 10 60`
|
||||||
if [ ! -z $ramificacion ];then
|
if [ -z $giturl ];then
|
||||||
git checkout ${lista[$ramificacion]}
|
echo "No URL specified."
|
||||||
if [ $howopt = "u" ];then
|
exit
|
||||||
git pull origin ${lista[$ramificacion]}
|
fi
|
||||||
fi
|
git clone $giturl
|
||||||
fi
|
;;
|
||||||
;;
|
|
||||||
"n")
|
|
||||||
NewBranch=`dialog --stdout --inputbox "Name of the new branch" 10 50 "New branch"`
|
#Options of a git repo
|
||||||
if [ ! -z $NewBranch ];then
|
"p")
|
||||||
git checkout -b $NewBranch
|
git pull $actual;;
|
||||||
fi
|
"s")
|
||||||
;;
|
estado=$(git status | grep -E '(^Changes|^Untracked)' ) #It need to commit something?
|
||||||
"m")
|
if [ "$estado" ];then #When is necesary commit
|
||||||
j=0
|
commit=`dialog --stdout --inputbox "Changes text: " 10 50 "changes"`
|
||||||
rama=""
|
if [[ -z $commit ]];then
|
||||||
for i in $(git branch --list | grep "^*" -v )
|
commit="changes"
|
||||||
do
|
fi
|
||||||
if [ $i != "*" ];then
|
git add -A && git commit -m "$commit" && git push $actual
|
||||||
rama="$rama $j $i"
|
else #Nothing to commit, only push
|
||||||
lista[$j]=$i
|
git push $actual
|
||||||
let j++
|
fi
|
||||||
fi
|
;;
|
||||||
done
|
"t")
|
||||||
merges=`dialog --stdout --scrollbar --menu "Select branch for merge to $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
|
commit=`dialog --stdout --inputbox "Changes text: " 10 50 "changes"`
|
||||||
if [ ! -z $merges ];then
|
if [[ -z $commit ]];then
|
||||||
git merge ${lista[$merges]}
|
commit="changes"
|
||||||
git push $actual
|
fi
|
||||||
fi
|
git add -A && git commit -m "$commit"
|
||||||
;;
|
;;
|
||||||
"d")
|
"b")
|
||||||
var=1
|
howopt=`dialog --stdout --scrollbar --menu "Change branch" 0 0 6 c "Only change branch" u "Change branch and update it"`
|
||||||
while [[ $var -eq 1 ]]; do
|
if [ -z $howopt ];then
|
||||||
if [[ $(ls -a | grep .git) ]]; then
|
exit
|
||||||
var=0
|
fi
|
||||||
else
|
j=0
|
||||||
cd ..
|
rama=""
|
||||||
fi
|
#Loop to create dialog whith all branches (except the current)
|
||||||
done
|
for i in $(git branch -a | grep -v "^*" | grep -v "HEAD \->")
|
||||||
git checkout .;
|
do
|
||||||
;;
|
aux2=0
|
||||||
esac
|
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 "Select branch to goto" 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 "Name of the new branch" 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 "Select branch for merge to $(git branch --list | grep "^*" | cut -f2 -d" ")" 0 0 6 $rama`
|
||||||
|
if [ ! -z $merges ];then
|
||||||
|
git merge ${lista[$merges]}
|
||||||
|
git push $actual
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"d")
|
||||||
|
var=1
|
||||||
|
while [[ $var -eq 1 ]]; do
|
||||||
|
if [[ $(ls -a | grep .git) ]]; then
|
||||||
|
var=0
|
||||||
|
else
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
git checkout .;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user