Skip to content

Instantly share code, notes, and snippets.

@egore
Created April 30, 2022 05:16
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 egore/c84cc283e2b2ba6bdaf9fd162857b0d8 to your computer and use it in GitHub Desktop.
Save egore/c84cc283e2b2ba6bdaf9fd162857b0d8 to your computer and use it in GitHub Desktop.
!/bin/bash
set -euo pipefail
if [ -d dosbox ]; then
echo "update"
cd dosbox
git svn fetch
else
echo "clone"
git svn clone -s --no-minimize-url https://svn.code.sf.net/p/dosbox/code-0/dosbox dosbox --no-metadata --authors-file=authors.txt --prefix=p/dosbox/code-0/
cd dosbox
fi
# Create tags from SVN
echo "tag"
git for-each-ref refs/remotes/p/dosbox/code-0/tags | cut -d / -f 7- | while read ref; do
if ! git show-ref --tags ${ref} --quiet; then
export GIT_COMMITTER_DATE=$(git log -n1 --format=format:"%ad" refs/remotes/p/dosbox/code-0/tags/${ref})
export GIT_AUTHOR_DATE="${GIT_COMMITTER_DATE}"
export GIT_COMMITTER_NAME=$(git log -n1 --format=format:"%an" refs/remotes/p/dosbox/code-0/tags/${ref})
export GIT_AUTHOR_NAME="${GIT_COMMITTER_NAME}"
export GIT_COMMITTER_EMAIL=$(git log -n1 --format=format:"%ae" refs/remotes/p/dosbox/code-0/tags/${ref})
export GIT_AUTHOR_EMAIL="${GIT_COMMITTER_EMAIL}"
git tag -a "${ref}" -m "${ref}" "refs/remotes/p/dosbox/code-0/tags/${ref}^1"
fi
done
# Create branches
echo "branch"
for BRANCH in $(git branch -a | grep remotes/p/dosbox/code-0/ | grep -v "/tags/" | grep -v "/trunk" | grep -v " -> " | sed "s:^ remotes/::"); do
SHORT_BRANCH=$(echo ${BRANCH} | sed -e "s:p\/dosbox\/code-0\/::")
if ! git show-ref --heads ${SHORT_BRANCH} --quiet; then
git branch ${BRANCH/p\/dosbox\/code-0\//} remotes/${BRANCH}
fi
done
exit 1
echo "ignore"
if [ -f .svnignore ]; then
git mv .svnignore .gitignore
git commit .svnignore .gitignore -m "Convert .svnignore to .gitignore"
fi
echo "cleanup"
git config --remove-section svn
git config --remove-section svn-remote.svn
for BRANCH in $(git branch -a | grep remotes/svn/ | sed "s:^ remotes/::" ); do
git branch -d -r ${BRANCH}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment