-
-
Save g3rhard/d2c734ed9a07e9ea9b3bac6d9f2ef3f4 to your computer and use it in GitHub Desktop.
gogs repo migration 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
#!/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