[Feature] API endpint for repo transfer #4678

Closed
opened 2025-11-02 05:59:13 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @6543 on GitHub (Jan 18, 2020).

expose repo-transfer function from UI to API

Originally created by @6543 on GitHub (Jan 18, 2020). expose repo-transfer function from UI to API
GiteaMirror added the modifies/api label 2025-11-02 05:59:13 -06:00
Author
Owner

@camlafit commented on GitHub (Jan 18, 2020):

Could be in /repos/{owner}/{repo} API options adding new_owner option

@camlafit commented on GitHub (Jan 18, 2020): Could be in /repos/{owner}/{repo} API options adding new_owner option
Author
Owner

@camlafit commented on GitHub (Jan 19, 2020):

Hello

As workardound we can do this :

GITEA_HOST="try.gitea.io"
GITEA_PORT="443"
#Account to webui
user=""
password=""
old_owner=""
new_owner=""
repo_name=""

#GET cookies data (and csrf data)
curl -X GET \
    -c cookies.txt \
    -s \
    -d "redirect_to=/$old_owner/$repo_name/settings" \
    "$GITEA_HOST:$GITEA_PORT/user/login" \
    > /dev/null

csrf=$(grep csrf cookies.txt|sed 's/.*csrf\s*\(.*\)/\1/')

#Connect as admin
curl -X POST \
    -b cookies.txt \
    -c cookies.txt \
    -s \
    -d "user_name=$user&password=$password&_csrf=$csrf&redirect_to=/$old_owner/$repo_name/settings" \
    "$GITEA_HOST:$GITEA_PORT/user/login" \
    > /dev/null

    echo "Transfer $repo_name"
    curl -X GET \
        -b cookies.txt \
        -c cookies.txt \
        -s \
        "$GITEA_HOST:$GITEA_PORT/$old_owner/$repo_name/settings" \
        > /dev/null

    csrf=$(grep csrf cookies.txt|sed 's/.*csrf\s*\(.*\)/\1/')

    #Move plugin to its new orga
    curl -X POST \
        -b cookies.txt \
        -c cookies.txt \
        -d "repo_name=$repo_name&new_owner_name=$new_owner&_csrf=$csrf&action=transfer" \
        "$GITEA_HOST:$GITEA_PORT/$old_owner/$repo_name/settings"
@camlafit commented on GitHub (Jan 19, 2020): Hello As workardound we can do this : ``` GITEA_HOST="try.gitea.io" GITEA_PORT="443" #Account to webui user="" password="" old_owner="" new_owner="" repo_name="" #GET cookies data (and csrf data) curl -X GET \ -c cookies.txt \ -s \ -d "redirect_to=/$old_owner/$repo_name/settings" \ "$GITEA_HOST:$GITEA_PORT/user/login" \ > /dev/null csrf=$(grep csrf cookies.txt|sed 's/.*csrf\s*\(.*\)/\1/') #Connect as admin curl -X POST \ -b cookies.txt \ -c cookies.txt \ -s \ -d "user_name=$user&password=$password&_csrf=$csrf&redirect_to=/$old_owner/$repo_name/settings" \ "$GITEA_HOST:$GITEA_PORT/user/login" \ > /dev/null echo "Transfer $repo_name" curl -X GET \ -b cookies.txt \ -c cookies.txt \ -s \ "$GITEA_HOST:$GITEA_PORT/$old_owner/$repo_name/settings" \ > /dev/null csrf=$(grep csrf cookies.txt|sed 's/.*csrf\s*\(.*\)/\1/') #Move plugin to its new orga curl -X POST \ -b cookies.txt \ -c cookies.txt \ -d "repo_name=$repo_name&new_owner_name=$new_owner&_csrf=$csrf&action=transfer" \ "$GITEA_HOST:$GITEA_PORT/$old_owner/$repo_name/settings" ```
Author
Owner

@6543 commented on GitHub (Jan 23, 2020):

github as a own endpoint for this: POST /repos/:owner/:repo/transfer

link spec

open PR witch can be cherry-picked & modivied: https://gitea.artixlinux.org/artix/gitea/pulls/1/files

@6543 commented on GitHub (Jan 23, 2020): github as a own endpoint for this: `POST /repos/:owner/:repo/transfer` [link spec](https://developer.github.com/v3/repos/#transfer-a-repository) open PR witch can be cherry-picked & modivied: https://gitea.artixlinux.org/artix/gitea/pulls/1/files
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4678