NOTE: This will only work if you are an administrator on your Gogs instance, or if an administrator has enabled local repository importing for all users.
First, save the following as migrate.sh somewhere, and make it executable (chmod +x migrate.sh):
HOSTNAME="git.cryto.net"
BASEPATH="/home/git/old-repositories/projects/joepie91"
OWNER_ID="$1"
CSRF=`cat ./cookies.txt | grep _csrf | cut -f 7`
while read REPO; do
REPONAME=`echo "$REPO" | sed "s/\.git\$//"`
curl "https://$HOSTNAME/repo/migrate" \
-b "./cookies.txt" \
-H 'origin: null' \
-H 'content-type: application/x-www-form-urlencoded' \
-H "authority: $HOSTNAME" \
--data "_csrf=$CSRF" \
--data-urlencode "clone_addr=$BASEPATH/$REPO" \
--data-urlencode "uid=$OWNER_ID" \
--data-urlencode "auth_username=" \
--data-urlencode "auth_password=" \
--data-urlencode "repo_name=$REPONAME" \
--data-urlencode "description=Automatically migrated from Gitolite"
doneChange HOSTNAME to point at your Gogs installation, and BASEPATH to point at the folder where your Gitolite repositories live on the filesystem. It must be the entire base path - the repository names cannot contain slashes!
Now save the Gogs cookies from your browser as cookies.txt, and create a file (eg. repositories.txt) containing all your repository names, each on a new line. It could look something like this:
project1.git
project2.git
project3.git
After that, run the following command:
cat repositories.txt | ./migrate.sh 1... where you replace 1 with your User ID on your Gogs instance.
Done!
I had the same problem: The cookie-stuff failed.
You can use my webtester to execute the migration. This also works if you are not the administrator of your gogs instance.
Installation
See: https://dev.marc.waeckerlin.org/redmine/
e.g. ubuntu:
sudo apt-get install -y wget software-properties-common apt-transport-https sudo apt-add-repository https://dev.marc.waeckerlin.org/repository wget -O- https://dev.marc.waeckerlin.org/repository/PublicKey \ | sudo apt-key add - sudo apt-get update -y sudo apt-get install webtesterUsage
run
webtesterin tab
Setup Scriptenter:where:
To get a list of all your repositories, replace mwaeckerlin by your user name and run:
In tab
Test Script, paste:Hit
Runand wait.In case of failure: Just remove the repositories that have already been migrated from REPO and hit
Runagain.