-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimporter.py
53 lines (44 loc) · 2.16 KB
/
importer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import requests
class Importer:
def __init__(self, options, project):
self.accesstoken = options.accesstoken
self.account = options.account
self.repo = options.repo
self.project = project
def import_milestones(self):
# Simulating the milestone import process
print(f"Simulating migration of milestones to repository {self.repo}")
def import_labels(self, label_selector):
# Simulating the label import process
print(f"Simulating migration of labels to repository {self.repo}")
def import_issues(self, start_from_issue):
# Simulate importing the issues
for issue in self.project._project['Issues'][start_from_issue:]:
print(f"Simulating migration of issue {issue['key']} to repository {self.repo}")
# Debug: Construct and print the API URL
issue_url = f"https://api.github.com/repos/{self.account}/{self.repo}/issues"
print(f"Debug: Issue API URL = {issue_url}")
# Debug: Print headers
headers = {
"Authorization": f"token {self.accesstoken}",
"Accept": "application/vnd.github+json",
}
print(f"Debug: Headers = {headers}")
# Debug: Print payload
payload = {
"title": issue["summary"],
"body": issue.get("description", "No description provided."),
"labels": issue.get("labels", [])
}
print(f"Debug: Payload = {payload}")
# Attempt to make the API call
response = requests.post(issue_url, json=payload, headers=headers)
print(f"Debug: Response Status Code = {response.status_code}")
print(f"Debug: Response Content = {response.text}")
if response.status_code != 201:
print(f"Failed to create issue '{issue['key']}': {response.status_code} - {response.text}")
else:
print(f"Successfully created issue '{issue['key']}'")
def post_process_comments(self):
# Simulate post-processing comments
print(f"Simulating post-processing of comments in repository {self.repo}")