-
-
Save logmanoriginal/fa1e59703c41e27758bcb935f15bea21 to your computer and use it in GitHub Desktop.
OpenG Import Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo Requesting list of branches... | |
branches=$(svn ls https://svn.code.sf.net/p/opengtoolkit/svn/branches | cut -d / -f 1) | |
echo Requesting list of tags... | |
tags=$(svn ls https://svn.code.sf.net/p/opengtoolkit/svn/tags | cut -d / -f 1) | |
echo Requesting list of projects... | |
projects=$(svn ls https://svn.code.sf.net/p/opengtoolkit/svn/trunk | cut -d / -f 1) | |
echo Requesting list of projects outside trunk... | |
top_projects=$(svn ls https://svn.code.sf.net/p/opengtoolkit/svn | cut -d / -f 1) | |
# Filter standard folders from projects outside trunk | |
top_projects=${top_projects//tags/} | |
top_projects=${top_projects//trunk/} | |
top_projects=${top_projects//branches/} | |
# Combine list of projects inside/outside trunk | |
projects+=$(printf -- '\n%s' "${top_projects[@]}") | |
echo "${projects[@]}" | while read project | |
do | |
if [[ -z "$project" ]] # Skip empty project names | |
then | |
continue | |
fi | |
repo=$(echo "$project" | tr ' ' '_') | |
if [[ -d "./openg_$repo.git" ]] # Skip finished projects | |
then | |
continue | |
fi | |
echo | |
echo ===== Working on project: $project ===== | |
echo | |
echo Checking if the project has branches... | |
if [[ ! -z $(printf -- '%s\n' $branches | grep "$project") ]] | |
then | |
echo Branches found. | |
branch="$project" | |
else | |
echo No branches. | |
unset branch | |
fi | |
echo Checking if the project has tags... | |
if [[ ! -z $(printf -- '%s\n' $tags | grep "$project") ]] | |
then | |
echo Tags found. | |
tag="$project" | |
else | |
echo No tags. | |
unset tag | |
fi | |
echo Checking if the project is inside trunk... | |
if [[ ! -z $(printf -- '%s\n' $top_projects | grep "$project") ]] | |
then | |
echo Project is not inside trunk. | |
trunk="$project" | |
else | |
echo Project is inside trunk. | |
trunk="trunk/$project" | |
fi | |
echo Cloning the project... | |
git svn clone https://svn.code.sf.net/p/opengtoolkit/svn \ | |
--quiet \ | |
--no-metadata \ | |
-A authors-transform.txt \ | |
--trunk="$trunk" \ | |
${branch:+--branch=/branches/$branch} \ | |
${tag:+--tags=/tags/$tag} \ | |
"./temp_$project" | |
echo Creating a bare repository, pointing HEAD to trunk... | |
git init --bare "./new_$project.git" | |
cd "./new_$project.git" | |
git symbolic-ref HEAD refs/heads/trunk | |
cd .. | |
echo Pushing repo to bare... | |
cd "./temp_$project" | |
git remote add bare "../new_$project.git" | |
git config remote.bare.push 'refs/remotes/origin/*:refs/heads/*' | |
git push bare | |
git remote remove bare | |
cd .. | |
echo Renaming trunk to master... | |
cd "./new_$project.git" | |
git branch -m trunk master | |
cd .. | |
echo Tags are branches, fixing... | |
cd "./new_$project.git" | |
git for-each-ref --format='%(refname)' refs/heads/tags | | |
cut -d / -f 4 | | |
while read ref | |
do | |
git tag "$ref" "refs/heads/tags/$ref"; | |
git branch -D "tags/$ref"; | |
done | |
cd .. | |
echo Removing temp folder... | |
rm -rf "./temp_$project" | |
echo Renaming bare repository to final repository... | |
mv "./new_$project.git" "./openg_$repo.git" | |
echo done. | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment