This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PWD=$(pwd) | |
GIT_ROOT=~/workspace | |
CYAN='\033[36m' | |
GREEN='\033[32m' | |
NC='\033[0m' # No Color | |
cd $GIT_ROOT > /dev/null | |
PROJECTS="$@" | |
if [[ $# -eq 0 ]] || [[ "$1" == "all" ]]; then | |
PROJECTS="*/" | |
fi | |
for project in $PROJECTS | |
do | |
if [[ ! -d "$project" ]]; then | |
project="jusbrasil-$project" | |
fi | |
echo -e "${CYAN}Updating $project${NC}" | |
cd $project > /dev/null | |
if [ -d ".git" ]; then | |
_changes=$(git status | grep Changes) | |
[ -z "$_changes" ] || git stash | |
echo "git pull and updating submodules..." | |
git pull --rebase && git submodule update --init | |
echo "removing branches deleted remotely" | |
git fetch -p | |
[ -z "$_changes" ] || git stash pop | |
else | |
echo "$project is not a git project" | |
fi | |
cd - > /dev/null | |
done | |
echo -e "${GREEN}Done :)${NC}" | |
cd $PWD > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment