Last active
April 4, 2019 08:36
-
-
Save frenzzy/6559289e7a159c781feb1296858ccac5 to your computer and use it in GitHub Desktop.
Update git subtree
This file contains hidden or 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 | |
if [ "${CIRCLE_BRANCH}" != "master" ] || [ -z "${SUBTREE_REPOSITORY_URL}" ] | |
then | |
exit 0 | |
fi | |
# abort the script if there is a non-zero error | |
set -e | |
# show where we are on the machine | |
pwd | |
mkdir repo-subtree | |
cd repo-subtree | |
git init | |
git config user.email "$SUBTREE_USER_EMAIL" > /dev/null 2>&1 | |
git config user.name "$SUBTREE_USER_NAME" > /dev/null 2>&1 | |
git remote add origin "$SUBTREE_REPOSITORY_URL" | |
git pull origin "${SUBTREE_BRANCH:-master}" | |
message="Merge upstream repo '$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME' into '$SUBTREE_DIR'" | |
git remote add --fetch "$CIRCLE_PROJECT_REPONAME" "$CIRCLE_REPOSITORY_URL" | |
git subtree pull --prefix="$SUBTREE_DIR" --squash --message "$message" "$CIRCLE_PROJECT_REPONAME" "$CIRCLE_BRANCH" | |
git push origin "${SUBTREE_BRANCH:-master}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment