Commit 6fbdf337 authored by Antonio Ragagnin's avatar Antonio Ragagnin 💬
Browse files

fix clone script

parent 4c6858f3
Loading
Loading
Loading
Loading

cloneall.bash

100644 → 100755
+32 −14
Original line number Diff line number Diff line
#!/bin/bash
set -vex

REPOS=(gitlab-profile core io integrate octree domain PM)
SESSION_NAME=how
REPOS=(${REPOS:=gitlab-profile core io integrate octree domain PM})
: ${SESSION_NAME:=hw}

while getopts "csapt" opt

while getopts "cptlr:" opt
do
   case "$opt" in
      c ) clona=1 ;;
      s ) tmuxa=1 ;;
      a ) attaccha=1 ;;
      p ) installa=1 ;;
      t ) testa=1 ;;
      p ) pyinsta=1 ;;
      t ) tmuxa=1 ;;
      l ) linka=1 ;;
      r ) shift $(( OPTIND - 2 )) && REPOS=($@) && break
   esac
done

if [ -z "$clona" ] && [ -z "$tmuxa" ] && [ -z "$attaccha" ];then
    echo 'usage: ./cloneall.bash -c (clone repos) -p (pip install) -t (python tests) -s (create screen tmux session) -a (attach to tmux)'
if [ -z "$clona" ] && [ -z "$pyinsta" ] && [ -z "$tmuxa" ] && [ -z "$linka" ];then
    echo 'usage: ./cloneall.bash -c (clone repos) -p (python install and tests) -t (attach to tmux) -l (full tree of links) -r (repos)'
    exit 1
fi

for REPO in "${REPOS[@]}"; do
    echo [ $REPO ]
done
#exit 0

if [ ! -z "$clona" ]; then
    [[ ! -d "venv" ]] && python3 -mvenv venv
    . venv/bin/activate
@@ -33,19 +39,34 @@ if [ ! -z "$clona" ]; then
        pushd $REPO
        git switch dev || echo no dev branch
	if [[ "$REPO" != "gitlab-profile" ]]; then
	    [ ! -z "$installa" ] && python -mpip install -e .
	    [ ! -z "$testa" ] && python -m hotwheels.checkup hotwheels/
	    [ ! -z "$pyinsta" ] && python -mpip install -e . && python -m hotwheels.checkup hotwheels/
	fi
        popd
    done
fi

if [ ! -z "$linka" ]; then
    mkdir -p full/hotwheels
    touch full/hotwheels/__init__.py || echo cant touch
    for f in core/hotwheels/*; do
	[[ "${f##*/:0:2}" == "__" ]] && continue
	ln -sf $PWD/$f full/hotwheels/${f##*/}
    done
    for REPO in "${REPOS[@]}"; do
	if [ "$REPO" != "core" ] && [ "$REPO" != "gitlab-profile" ]; then
	    ln -sf $PWD/$REPO/hotwheels/$REPO full/hotwheels/$REPO
	fi
    done
fi

if [ ! -z "$tmuxa" ]; then
    
    if ! tmux has-session -t $SESSION_NAME ; then
	# Create a new tmux session
	tmux new-session -d -s $SESSION_NAME -c $PWD

	[[ -d full ]] && REPOS+=(full)
	
	for index in "${!REPOS[@]}"; do
            value="${REPOS[index]}"
	    
@@ -57,9 +78,6 @@ if [ ! -z "$tmuxa" ]; then
            tmux new-window -t $SESSION_NAME -c $PWD
	done
    fi
fi

if [ ! -z "$attaccha" ]; then
    tmux attach-session -t $SESSION_NAME
fi