-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transfer ownsership via json api #5075
Comments
Here's a workaround: import requests
from lxml import html
LOGIN_URL = "https://git.mydomain.com/user/login"
REPO_SETTINGS_URL = "https://git.mydomain.com/{org}/{repo}/settings"
USERNAME = "admin"
PASSWORD = "password"
def get_csrf(resp):
# Get the csrf token from the html
doc = html.fromstring(resp.content)
return doc.find('*//input[@name="_csrf"]').value
def transfer_ownsership(reponame, source_org, target_org):
session = requests.Session()
# Authenticate
resp = session.get(LOGIN_URL)
session.post(
LOGIN_URL,
data={
"_csrf": get_csrf(resp),
"user_name": USERNAME,
"password": PASSWORD,
},
)
# Transfer to other org
repo_settings_url = REPO_SETTINGS_URL.format(org=source_org, repo=reponame)
resp = session.get(repo_settings_url)
session.post(
repo_settings_url,
data={
"_csrf": get_csrf(resp),
"action": "transfer",
"repo_name": reponame,
"new_owner_name": target_org,
},
)
# Transfer myproject from SOURCE_ORG to TARGET_ORG
transfer_ownsership('myproject', 'projects', 'archived_projects') |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions. |
This issue has been automatically closed because of inactivity. You can re-open it if needed. |
Will this be supported in the future? Usecase:
Are there any other ways to cover my usecase? |
This was implemented in #9947 |
Wow. Nice. 👍 |
Hi,
There's not an option to transfer ownership of a repo using the json API.
I'd like to move project to an "archive" organisation when the project is done.
The text was updated successfully, but these errors were encountered: