# Note, if both the org and project names change, this script will# perform the org transfer first, followed by the project name change.# If there is already a project in the new org with the old name, it# will fail.-name:"Parsereponamesfor{{repo.old}}->{{repo.new}}"set_fact:oldorg:"{{repo.old.split('/')[0]}}"neworg:"{{repo.new.split('/')[0]}}"oldproj:"{{repo.old.split('/')[1]}}"newproj:"{{repo.new.split('/')[1]}}"-name:Get Gitea org list# We assume that all the orgs we are interested in are owned by rooturi:url:"{{gitea_url}}/api/v1/user/orgs"user:rootpassword:"{{gitea_root_password}}"force_basic_auth:truevalidate_certs:falsestatus_code:200register:gitea_org_list-name:Parse Gitea org listset_fact:gitea_orgs:"{{gitea_org_list.json|map(attribute='username')|list}}"-name:"Makenewgiteaorg"include_tasks:gitea-rename-setup-org.yamlvars:org:"{{neworg}}"-name:"Getrepo{{oldorg}}/{{oldproj}}"uri:url:"{{gitea_url}}/api/v1/repos/{{oldorg}}/{{oldproj}}"validate_certs:falseuser:rootpassword:"{{gitea_root_password}}"force_basic_auth:trueregister:gitea_repo-name:"Transferrepoownershipfrom{{oldorg}}/{{oldproj}}to{{neworg}}/{{oldproj}}"when:"oldorg!=neworg"uri:url:"{{gitea_url}}/api/v1/repos/{{oldorg}}/{{oldproj}}/transfer"validate_certs:falseuser:rootpassword:"{{gitea_root_password}}"force_basic_auth:truestatus_code:202method:POSTbody_format:jsonbody:new_owner:"{{neworg}}"-name:"Updatereponamefrom{{neworg}}/{{oldproj}}to{{neworg}}/{{newproj}}"when:"oldproj!=newproj"uri:url:"{{gitea_url}}/api/v1/repos/{{neworg}}/{{oldproj}}"validate_certs:falseuser:rootpassword:"{{gitea_root_password}}"force_basic_auth:truestatus_code:200method:PATCHbody_format:jsonbody:name:"{{newproj}}"description:"{{gitea_repo.json.description}}"website:"{{gitea_repo.json.website}}"