Skip to content

Instantly share code, notes, and snippets.

@swegner
Last active September 19, 2018 19:21
Show Gist options
  • Save swegner/233ede6e4764009a93bcaf0091bf02d2 to your computer and use it in GitHub Desktop.
Save swegner/233ede6e4764009a93bcaf0091bf02d2 to your computer and use it in GitHub Desktop.
Script to automate migration of apache/beam-site into apache/beam. https://issues.apache.org/jira/browse/BEAM-4494
#!/bin/bash
SITE_BRANCH=website-migration-beamsite
BEAM_BRANCH=website-migration
WEBSITE_UPSTREAM=upstream-site/asf-site
# WEBSITE_UPSTREAM=swegner-site/apache_headers
cd ~/beam
git reset --hard
git clean -fdx
git checkout master
git fetch --all --prune
git branch -D $SITE_BRANCH $BEAM_BRANCH
git checkout -b $SITE_BRANCH $WEBSITE_UPSTREAM
# Remove content and auto-generated docs in src/documentation/sdks from the history.
git filter-branch --index-filter 'git rm -rf -q --ignore-unmatch content src/documentation/sdks/pydoc src/documentation/sdks/javadoc' --prune-empty -f HEAD
# Re-write shorthand PR/issue links.
git filter-branch --msg-filter 'sed "s|#\([0-9][0-9]*\)|https://github.com/apache/beam-site/pull/\1|g"' -f HEAD
# Move everything to a website subdirectory.
# NOTE: BSD sed (including OS X) does not support \t as tab.
git filter-branch --index-filter 'git ls-files -s | sed "s|\t|\twebsite/|" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' -f HEAD
# Grab main repo and merge the site in.
# git checkout website-migration-deltas
git checkout master
git up
git checkout -b $BEAM_BRANCH
git branch --set-upstream-to=upstream/master
git merge $SITE_BRANCH --allow-unrelated-histories -m "Migrate beam-site sources to apache/beam"
git mergetool
git push swegner $BEAM_BRANCH $SITE_BRANCH -f
@apilloud
Copy link

Ugh, the --allow-unrelated-histories flag breaks a bunch of tools including git bisect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment