Skip to content

Instantly share code, notes, and snippets.

@senz
Created August 8, 2017 09:41
Show Gist options
  • Save senz/bd6f4754300f335bf051ddee1d93af5d to your computer and use it in GitHub Desktop.
Save senz/bd6f4754300f335bf051ddee1d93af5d to your computer and use it in GitHub Desktop.
gogs repo migration script
#!/usr/bin/env bash
## Usage:
## ./migrate.sh $clone_url $project_name $owner_uid
## Migrate a repository to gogs into the user namespace of the token-user
## ./migrate.sh [email protected]:group/repo.git repo 1
## uid can be a group uid
## NB: for local migration, if your gogs instance is inside docker or vm, you must provide path local relative to container's fs
echo $1;
clone_url=$1
name=$2
owner_uid=$3
GOGS_URL=${GOGS_URL:-"http://gogs.example.com"}
GOGS_TOKEN=${GOGS_TOKEN:-"abcde"}
curl -s -L -H "Authorization: token $GOGS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
--data '{"repo_name": "'"$name"'", "description":"automatic migration", "private": true, "uid": '$owner_uid', "clone_addr": "'$clone_url'"}' \
$GOGS_URL/api/v1/repos/migrate
@gregdel
Copy link

gregdel commented May 6, 2018

I made a gist to migrate from gitlab to gogs without knowing the user id, you can check it out here: https://gist.github.com/gregdel/870d58c80b80172445dc93294531d88c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment