Created
February 18, 2020 09:01
-
-
Save sebastianneubert/fa40e3a35d7a3976c681c369733f508d to your computer and use it in GitHub Desktop.
git update all projects in dir
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 +e | |
#0 black COLOR_BLACK 0,0,0 | |
#1 red COLOR_RED 1,0,0 | |
#2 green COLOR_GREEN 0,1,0 | |
#3 yellow COLOR_YELLOW 1,1,0 | |
#4 blue COLOR_BLUE 0,0,1 | |
#5 magenta COLOR_MAGENTA 1,0,1 | |
#6 cyan COLOR_CYAN 0,1,1 | |
#7 white COLOR_WHITE 1,1,1 | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
yellow=`tput setaf 3` | |
cyan=`tput setaf 6` | |
reset=`tput sgr0` | |
dirs=($(find . -maxdepth 1 -type d \( ! -name . \) )) | |
for dir in "${dirs[@]}"; do | |
echo "${cyan}----${reset}" | |
cd "$dir" | |
pwd | |
if [[ -d ".git" ]]; then | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
echo "${green}Updating $dir branch $branch ${reset}"; | |
command="git pull origin $branch" | |
echo "${yellow}$command ${reset}" | |
$command 2> /dev/null | |
if [ $? -eq 0 ] | |
then | |
composer install | |
echo "Successfully updated" | |
else | |
echo "${red}Sumthin went wrong! ${reset}" >&2 | |
echo "" | |
echo "${red}PLEASE UPDATE $dir MANUALLY!" | |
fi | |
else | |
continue | |
fi | |
cd .. | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment