Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clone from v1 #130

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions scripts/update-common-everywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ORG="validatedpatterns"
GITBASE="[email protected]:${ORG}"
COMMON="https://github.com/${ORG}/common.git"
BRANCH="common-automatic-update" # name of the branch being used locally and on the remote fork
MAINBRANCH="main"
MAINBRANCH=${MAINBRANCH:-v1}
TMPD=$(mktemp -d /tmp/commonrebase.XXXXX)
LOG="${TMPD}/log"

Expand Down Expand Up @@ -93,16 +93,19 @@ if [ ${#GHREPOS[@]} -eq 0 ]; then
fi

pushd "$TMPD"
echo "Working in ${TMPD} on the following repos: ${GHREPOS[*]}" | tee "$LOG"
git clone "${COMMON}" >> "$LOG"
echo "Working in ${TMPD} on the following repos: ${GHREPOS[*]}" | tee "${LOG}"
git clone "${COMMON}" >> "${LOG}"
pushd "common"
git checkout "origin/${MAINBRANCH}" -b "${MAINBRANCH}" >> "${LOG}"
popd
for i in "${GHREPOS[@]}"; do
echo "Cloning $i"
git clone "${GITBASE}/${i}.git" >> "$LOG"
git clone "${GITBASE}/${i}.git" >> "${LOG}"
pushd "$i"
git remote add common-upstream -f ../common | tee -a "$LOG"
git remote add fork -f "[email protected]:${USERGITHUB}/${i}.git" | tee -a "$LOG"
git checkout -b "${BRANCH}" | tee -a "$LOG"
git merge --no-edit -s subtree -Xtheirs -Xsubtree=common "common-upstream/${MAINBRANCH}" | tee -a "$LOG"
git remote add common-upstream -f ../common | tee -a "${LOG}"
git remote add fork -f "[email protected]:${USERGITHUB}/${i}.git" | tee -a "${LOG}"
git checkout -b "${BRANCH}" | tee -a "${LOG}"
git merge --no-edit -s subtree -Xtheirs -Xsubtree=common "common-upstream/${MAINBRANCH}" | tee -a "${LOG}"

# Check that no commit left conflicts
if grep -IR -e '^<<<' -e '^>>>' . 2>/dev/null; then
Expand All @@ -112,7 +115,7 @@ for i in "${GHREPOS[@]}"; do

# Check that upstream common/ and the subtree common/ are identical (add --no-dereference due to our commmon -> symlink)
set +e
diff -urN --exclude='.git' --no-dereference ../common ./common 2>&1 | tee "$LOG"
diff -urN --exclude='.git' --no-dereference ../common ./common 2>&1 | tee "${LOG}"
ret=$?
set -e
if [ $ret -ne 0 ]; then
Expand All @@ -124,7 +127,7 @@ for i in "${GHREPOS[@]}"; do
fi
fi

git push fork "${BRANCH}" -f | tee -a "$LOG"
git push fork "${BRANCH}" -f | tee -a "${LOG}"
gh repo set-default "${ORG}/${i}"

# Automatically create a PR. This needs more testing and explaining before we enable it
Expand Down