copy stories from old circle #15
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://git.ourworld.tf/tfcoop/circle_prodmgmt_grid/issues
done
done using python script
import requests
Define Gitea instance URLs
source_gitea_url = 'https://git.ourworld.tf/api/v1'
target_gitea_url = 'https://git.ourworld.tf/api/v1'
Define authentication tokens
source_token = 'token'
target_token = 'token'
Define organization and repository names
source_org = 'tfcoop'
source_repo = 'circle_prodmgmt_grid'
target_org = 'tfgrid'
target_repo = 'circle_engineering'
Define issue number to move
issue_number = #
def fetch_issue_details(org, repo, issue_number):
response = requests.get(f'{source_gitea_url}/repos/{org}/{repo}/issues/{issue_number}', headers={'Authorization': f'token {source_token}'})
if response.status_code == 200:
return response.json()
else:
print(f"Failed to fetch issue details from {org}/{repo} for issue #{issue_number}.")
return None
def fetch_comments(org, repo, issue_number):
response = requests.get(f'{source_gitea_url}/repos/{org}/{repo}/issues/{issue_number}/comments', headers={'Authorization': f'token {source_token}'})
if response.status_code == 200:
return response.json()
else:
print(f"Failed to fetch comments for issue #{issue_number} in {org}/{repo}.")
return None
def create_issue(org, repo, issue_details):
data = {
'title': issue_details['title'],
'body': issue_details['body']
# Add more fields as needed
}
response = requests.post(f'{target_gitea_url}/repos/{org}/{repo}/issues', json=data, headers={'Authorization': f'token {target_token}'})
if response.status_code == 201:
return response.json()['number']
else:
print(f"Failed to create issue in {org}/{repo}.")
return None
def create_comment(org, repo, issue_number, comment_body):
data = {
'body': comment_body
}
response = requests.post(f'{target_gitea_url}/repos/{org}/{repo}/issues/{issue_number}/comments', json=data, headers={'Authorization': f'token {target_token}'})
if response.status_code == 201:
return True
else:
print(f"Failed to create comment on issue #{issue_number} in {org}/{repo}.")
return False
def main():
# Fetch issue details from source repository
issue_details = fetch_issue_details(source_org, source_repo, issue_number)
if issue_details:
# Create issue in target repository
new_issue_number = create_issue(target_org, target_repo, issue_details)
if new_issue_number:
print(f"Issue #{issue_number} moved successfully to {target_org}/{target_repo} as issue #{new_issue_number}.")
# Fetch comments from source issue
comments = fetch_comments(source_org, source_repo, issue_number)
if comments:
# Post comments to new issue
for comment in comments:
success = create_comment(target_org, target_repo, new_issue_number, comment['body'])
if success:
print(f"Comment on issue #{issue_number} copied successfully.")
else:
print(f"Failed to copy comment on issue #{issue_number}.")
else:
print(f"Failed to move issue #{issue_number} to {target_org}/{target_repo}.")
else:
print(f"Failed to move issue #{issue_number} from {source_org}/{source_repo}.")
if name == "main":
main()