Created
January 12, 2017 09:11
-
-
Save cedricziel/6dbf652649a98aee924dd4dc83524581 to your computer and use it in GitHub Desktop.
Very simple migration script to move from gitlab to gogs
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/env bash | |
## Needs `jq` (https://stedolan.github.io/jq/) on PATH | |
## and a personal gogs token of yours. | |
## Obtain token from https://git.example.com/user/settings/applications | |
## Usage: | |
## ./migrate.sh $clone_url $project_name [$optional_group] | |
## Migrate a repository to gogs into the user namespace of the token-user | |
## ./migrate.sh git@mygitlab.com:group/repo.git repo | |
## Migrate a repository to gogs into the group namespace `group` (needs to exist) | |
## ./migrate.sh git@mygitlab.com:group/repo.git repo group | |
echo $1; | |
clone_url=$1 | |
name=$2 | |
org=$3 | |
GOGS_URL="https://git.example.com" | |
GOGS_TOKEN="yourpersonalgogstoken" | |
PWD=`pwd` | |
uuid=$(uuidgen) | |
git clone $1 $uuid; | |
cd $uuid; | |
if [ -z "$3" ] | |
then | |
clone_url=`curl -H "Authorization: token $GOGS_TOKEN" \ | |
-H "Accept: application/json" \ | |
-H "Content-Type:application/json" \ | |
--data '{"name": "'"$name"'", "description":"automatic migration", "private": true}' \ | |
https://git.example.com/api/v1/user/repos | jq -r '.ssh_url'` | |
else | |
clone_url=`curl -H "Authorization: token $GOGS_TOKEN" \ | |
-H "Accept: application/json" \ | |
-H "Content-Type:application/json" \ | |
--data '{"name": "'"$name"'", "description":"automatic migration", "private": true}' \ | |
https://git.example.com/api/v1/org/$org/repos | jq -r '.ssh_url'` | |
fi | |
echo $clone_url; | |
git remote add migration $clone_url; | |
git push --all migration; | |
git push --tags migration; | |
cd ..; | |
rm -Rf $uuid; |
good job
I made a gist to migrate from gitlab to gogs using the migration API, inspired by @senz' gist
https://gist.github.com/gregdel/870d58c80b80172445dc93294531d88c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is an api for migration now, here is a simplier version https://gist.github.com/senz/bd6f4754300f335bf051ddee1d93af5d