Skip to content

Instantly share code, notes, and snippets.

@g3rhard
Forked from senz/gogs_migrate.sh
Created February 15, 2018 06:53
Show Gist options
  • Save g3rhard/d2c734ed9a07e9ea9b3bac6d9f2ef3f4 to your computer and use it in GitHub Desktop.
Save g3rhard/d2c734ed9a07e9ea9b3bac6d9f2ef3f4 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment