Skip to content

Instantly share code, notes, and snippets.

@paul-chambers
Created October 28, 2019 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul-chambers/cc0277b74487c41513eb9d477705f34f to your computer and use it in GitHub Desktop.
Save paul-chambers/cc0277b74487c41513eb9d477705f34f to your computer and use it in GitHub Desktop.
Short script to split the miniupnp/miniupnp repo into three - miniupnpc, miniupnpd, and minissdpd
#!/bin/bash
set -x
USER=miniupnp
PROJECT=miniupnp
repo=https://github.com/${USER}/${PROJECT}.git
if [ -d "${PROJECT}" ]; then
rm -rf "${PROJECT}"
fi
git clone "${repo}"
mkdir -p root-files
find "${PROJECT}/" -maxdepth 1 -type f -exec cp -av "{}" root-files/ ';'
USER=paul-chambers
for subdir in miniupnpd minissdpd miniupnpc
do
if [ -d "${subdir}" ]; then
rm -rf "${subdir}"
fi
git clone --local "${PROJECT}/" "${subdir}"
cd "${subdir}"
git remote set-url origin "git@github.com:${USER}/${subdir}.git"
otherTags=$(git tag --list | sed -e "/^${subdir}.*/ d")
git tag -d ${otherTags}
if [ "${subdir}" == "miniupnpc" ]; then
git filter-branch --index-filter 'git rm --cached -qr --ignore-unmatch -- minissdpd miniupnpd' --prune-empty -- --all
else
git filter-branch -d "/tmp/${subdir}" --prune-empty --tag-name-filter "cat" --subdirectory-filter "${subdir}/" -- --all
cp -vn ../root-files/* ../root-files/.??* .
git add . && git commit -m "add back the top-level files"
fi
git repack -ad
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment