Skip to content

Instantly share code, notes, and snippets.

@aelkiss
Last active October 16, 2023 15:36
Show Gist options
  • Save aelkiss/d4104d425491fa19669323019974cb15 to your computer and use it in GitHub Desktop.
Save aelkiss/d4104d425491fa19669323019974cb15 to your computer and use it in GitHub Desktop.
merge together babel repos
# based on https://josh.fail/2022/merging-git-repos-with-git-filter-repo/
# First, make a clean checkout of all the repositories
REPO_ROOT=~/Repositories/babel-merge
# REPO_ROOT=$(dirname $(realpath $0))
git_filter_repo="git filter-repo"
[email protected]:hathitrust
export REPO_ROOT git_filter_repo GIT_BASE
# Apps to merge in productgion
#
# access - in use as of 2017, should double-check
# htdc - in use, deprecated
# htd - in use, deprecated
# imgsrv - in use
# imgsrv-tools - stamp_pdf.pl is used by imgsrv
# kgs - in use, deprecated
# logout - in use
# ls - in use
# mb - in use
# mdp-misc - in use for cron jobs
# mdp-tools - needed for deployment
# ping - in use
# pt - in use
# slip - in use
# ssd - in use
# watermarks - in use
# wayf - in use
# whoami - in use
# dependencies
# mdp-lib
# mdp-web
# plack-lib
# slip-lib
# TBD
# access
# keep separate
# crms
# feed - not used directly; need some of the directories here for file-shuffling
# firebird-common
# hathifiles
# stats
# directories we need but not repos
# cache
# etc
# flags
# geoip
# logs
# unused (here)
# audit
# common - no longer used?
# feedback - not used? check w/ roger?
# gr - not used?
# groove - not used? check timestamps for log files
# logout.x - not in use, check w/ dueberb
# ptsearch - not in use
# qual - not in use
# widgets - defunct
APPS="htd htdc imgsrv imgsrv-tools kgs logout ls mb mdp-lib mdp-misc mdp-tools mdp-web ping plack-lib pt slip slip-lib ssd watermarks wayf whoami"
export APPS
clone_apps () {
mkdir $REPO_ROOT/fresh-copy
cd $REPO_ROOT/fresh-copy
for app in $APPS; do
git clone $GIT_BASE/$app
done
git clone $GIT_BASE/imgsrv-sample-data ./sample-data
}
clean () {
rm -vrf $REPO_ROOT/apps-clones
rm -vrf $REPO_ROOT/babel
}
copy_apps () {
cp -vrp $REPO_ROOT/fresh-copy $REPO_ROOT/apps-clones
}
move_to_subdirs () {
for app in $APPS; do
(cd "$REPO_ROOT/apps-clones/$app" && $git_filter_repo --to-subdirectory $app/);
done
}
clone_babel () {
cd $REPO_ROOT
git clone $GIT_BASE/babel-local-dev babel
}
merge_apps () {
cd $REPO_ROOT/babel
for app in $APPS; do
echo "Merging $app"
git remote add "$app" ../apps-clones/"$app" &&
git fetch "$app" &&
default_branch=$(git remote show "$app" | sed -n '/HEAD branch/s/.*: //p')
git merge "$app"/"$default_branch" --allow-unrelated-histories --no-ff -m "Add ${app}"
done
}
remove_submodules () {
for app in $APPS; do
cd $REPO_ROOT/apps-clones/$app/$app
if [[ -e .gitmodules ]]; then
git rm -rf vendor
git rm -f .gitmodules
git rm -rf web/common-web
git commit -m "remove submodules from $app"
fi
done
}
clone_apps
clean
copy_apps
move_to_subdirs
remove_submodules
clone_babel
merge_apps
###
# Then:
# - add github.com/hathitrust/babel as a remote
# - check diffs from babel/main
# - force push to main (🙀)
# - rebase branch on main if needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment