forked from Lesin/reposync
75 lines
2.0 KiB
Python
75 lines
2.0 KiB
Python
import requests
|
|
import mysql.connector
|
|
import json
|
|
|
|
def send_gintlink_issue(owner, repo, token, conn, cursor):
|
|
cursor.execute("SELECT issue_title,issue_body,issue_state,issue_created_at,issue_priority,issue_start_date,issue_deadline,issue_branch FROM gitee_issue")
|
|
gitee_issue_data = cursor.fetchall()
|
|
for row in gitee_issue_data:
|
|
if row[2] == 'open':
|
|
status_id = 1
|
|
else:
|
|
status_id = 2
|
|
|
|
if row[4] == 0:
|
|
status_priority = 1
|
|
elif row[4] == 1:
|
|
status_priority = 1
|
|
elif row[4] == 2:
|
|
status_priority = 2
|
|
elif row[4] == 3:
|
|
status_priority = 3
|
|
else:
|
|
status_priority = 4
|
|
|
|
url = f"https://gitlink.org.cn/api/v1/{owner}/{repo}/issues.json"
|
|
|
|
payload = json.dumps({
|
|
"status_id": status_id,
|
|
"priority_id": status_priority,
|
|
# "milestone_id": 0,
|
|
"branch_name": row[7],
|
|
"start_date": row[5],
|
|
"due_date": row[6],
|
|
"subject": row[0],
|
|
"description": row[1],
|
|
# "blockchain_token_num": 0,
|
|
# "issue_tag_ids": [
|
|
# 0
|
|
# ],
|
|
# "assigner_ids": [
|
|
# 0
|
|
# ],
|
|
# "attachment_ids": [
|
|
# 0
|
|
# ],
|
|
# "receivers_login": [
|
|
# "string"
|
|
# ]
|
|
})
|
|
|
|
headers = {
|
|
'Authorization': f'Bearer {token}',
|
|
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
print(response.text)
|
|
print("成功同步gitee-issues到gitlink_issues")
|
|
|
|
# # 连接到数据库
|
|
# conn = mysql.connector.connect(
|
|
# host="localhost",
|
|
# user="root",
|
|
# password="251226X",
|
|
# database="reposyncer"
|
|
# )
|
|
# cursor = conn.cursor()
|
|
#
|
|
# owner= 'wuyifan'
|
|
# repo = 'wuyifan-ob-reposyncer'
|
|
# token = 'gzH8B9wvjs_82e5IoTe9Fi79OwKp0Z0CtBGyyz1GWFI'
|
|
#
|
|
# send_gintlink_issue(owner, repo, token, conn, cursor) |