Last active
September 4, 2018 07:34
-
-
Save shazron/0207eaa4a19ea5fad2c87bdd0ca2c600 to your computer and use it in GitHub Desktop.
Update named repos in a Github Organization
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 | |
# simple update, nothing fancy, gets things done | |
# run from the parent folder CWD (all repos will are siblings) | |
# EDIT: this is the Org for the repos | |
GH_ORG="adobe" | |
# EDIT: this is the base url for the repos (Github.com) | |
BASE_URL="https://github.com/$GH_ORG" | |
# EDIT: add the repo name to this list | |
repos=( aio-cli aio-cli-plugin-config aio-cli-plugin-jwt-auth aio-cli-plugin-console) | |
echo "-----Start updating $BASE_URL repos-----" | |
for i in "${repos[@]}" | |
do | |
echo "-----Updating $i-----" | |
# if the repo does not exist, we clone it | |
if [[ ! -d $i ]]; then | |
echo "Cloning the repo $i..." | |
git clone $BASE_URL/$i | |
fi | |
cd $i | |
# save the working branch | |
ACTIVE_BRANCH=$(git symbolic-ref --short HEAD) | |
# try to push to stack, if changes available | |
STASH_RC=$(git stash) | |
# only update master branch | |
git checkout master | |
git pull --rebase | |
# go back to the working branch | |
git checkout $ACTIVE_BRANCH | |
# we don't want to pop if we didn't push in the first place, | |
# if not we will pop a non-related stack item | |
if [ "$STASH_RC" != "No local changes to save" ]; then | |
git stash pop | |
fi | |
cd .. | |
done | |
echo "-----Done updating $BASE_URL repos-----" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 34 might not work if you have a non-English locale