Compare commits
45 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
432fab153e | |
![]() |
eec9f48cd8 | |
|
11922510c5 | |
|
287ac44eea | |
|
861c247657 | |
|
8ba2f2d2a1 | |
|
6ac1006cb4 | |
|
5583c7f63b | |
|
e69d25ecf8 | |
|
9ea50201f9 | |
|
7acfc2dea7 | |
|
5b3fa90d76 | |
|
2e610524d0 | |
|
6219b0d329 | |
|
add11ed9d8 | |
|
8f7d9a857a | |
|
6fceeebfef | |
|
94274379b4 | |
|
2ba125511d | |
![]() |
0927408e74 | |
|
97a2b1eabb | |
![]() |
c8d4e2d0e2 | |
|
12d3b5ff5e | |
![]() |
751b911cbd | |
|
c879dfdd61 | |
![]() |
6125be5ea4 | |
|
f34876f52f | |
![]() |
d0983670c0 | |
|
f1077c6ce2 | |
|
dbf8b315af | |
|
2dad9a4b8d | |
|
bc68c78e1a | |
|
e7909b439d | |
|
3db4e158b7 | |
![]() |
b546800461 | |
![]() |
10b8124b23 | |
|
f39a6809a5 | |
|
8f82da98d4 | |
|
2051167396 | |
|
d53dad3222 | |
|
c70f45a476 | |
|
5875c4fa94 | |
|
324d008fe4 | |
![]() |
67cba2d1f8 | |
![]() |
17b278cc77 |
|
@ -0,0 +1,65 @@
|
|||
version: 2
|
||||
name: 子任务二——RepoSyncer缺陷修复
|
||||
description: ""
|
||||
global:
|
||||
concurrent: 1
|
||||
trigger:
|
||||
webhook: gitlink@1.0.0
|
||||
event:
|
||||
- ref: push
|
||||
ruleset-operator: AND
|
||||
workflow:
|
||||
- ref: start
|
||||
name: 开始
|
||||
task: start
|
||||
- ref: end
|
||||
name: 结束
|
||||
task: end
|
||||
needs:
|
||||
- ssh_cmd_0
|
||||
- ref: git_clone_0
|
||||
name: git clone
|
||||
task: git_clone@1.2.9
|
||||
input:
|
||||
username: ((zhanglinhao_gitlink_account.account))
|
||||
password: ((zhanglinhao_gitlink_account.password))
|
||||
remote_url: '"https://gitlink.org.cn/wuyifan/reposync.git"'
|
||||
ref: '"refs/heads/master"'
|
||||
commit_id: '""'
|
||||
depth: 1
|
||||
needs:
|
||||
- start
|
||||
- ref: docker_image_build_0
|
||||
name: docker镜像构建
|
||||
task: docker_image_build@1.6.0
|
||||
input:
|
||||
docker_username: ((zhanglinhao_gitlink_account.account))
|
||||
docker_password: ((zhanglinhao_gitlink_account.password))
|
||||
image_name: '"registry.cn-hangzhou.aliyuncs.com/zhanglinhao/gitlink-ob"'
|
||||
image_tag: '"latest"'
|
||||
registry_address: '"registry.cn-hangzhou.aliyuncs.com"'
|
||||
docker_file: '"Dockerfile"'
|
||||
docker_build_path: '"."'
|
||||
workspace: git_clone_0.git_path
|
||||
image_push: true
|
||||
build_args: '""'
|
||||
needs:
|
||||
- git_clone_0
|
||||
- ref: ssh_cmd_0
|
||||
name: ssh执行命令
|
||||
task: ssh_cmd@1.1.1
|
||||
input:
|
||||
ssh_pass: ((ssh_password.group4))
|
||||
ssh_ip: '"120.27.216.107"'
|
||||
ssh_port: '"22"'
|
||||
ssh_user: '"root"'
|
||||
ssh_cmd: "\"docker stop reposyncer_app && docker rm reposyncer_app && docker
|
||||
pull registry.cn-hangzhou.aliyuncs.com/zhanglinhao/gitlink-ob:latest &&
|
||||
docker run -it -d -e CEROBOT_MYSQL_HOST='120.27.216.107' -e
|
||||
CEROBOT_MYSQL_PORT=3306 -e CEROBOT_MYSQL_USER=gitlink -e
|
||||
CEROBOT_MYSQL_PWD='gitlink' -e CEROBOT_MYSQL_DB='reposyncer' -e
|
||||
BOOT_MODE='app' -p 8089:8000 --name reposyncer_app -d
|
||||
registry.cn-hangzhou.aliyuncs.com/zhanglinhao/gitlink-ob:latest\""
|
||||
needs:
|
||||
- docker_image_build_0
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="@localhost" uuid="59aa4e64-7c19-48d1-afd3-22139a00b76a">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (Virtualenv)" project-jdk-type="Python SDK" />
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/reposync.iml" filepath="$PROJECT_DIR$/.idea/reposync.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (Virtualenv)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,53 @@
|
|||
import urllib
|
||||
|
||||
import requests
|
||||
import mysql.connector
|
||||
|
||||
|
||||
def delete_gitee_issues(owner, repo, cursor):
|
||||
cursor.execute('SELECT issue_id FROM gitee_issue')
|
||||
gitee_results = cursor.fetchall()
|
||||
for row in gitee_results:
|
||||
issue_number = row[0]
|
||||
url = f'https://gitee.com/api/v5/repos/{owner}/issues/{issue_number}'
|
||||
# 构造请求头
|
||||
token = '62b7d0577a13b75ff066047426df30cb'
|
||||
headers = {'Authorization': f'token {token}'}
|
||||
|
||||
# 发送POST请求
|
||||
data = {
|
||||
"access_token": token,
|
||||
"owner": owner,
|
||||
"repo": repo,
|
||||
"number": issue_number,
|
||||
"state": 'closed',
|
||||
"labels":'wait_for_delete'
|
||||
}
|
||||
# 将字典转换为查询字符串
|
||||
query_string = urllib.parse.urlencode(data)
|
||||
|
||||
# 完整的请求 URL,包括查询字符串
|
||||
full_url1 = f"{url}?{query_string}"
|
||||
response = requests.patch(full_url1, headers=headers, json=data)
|
||||
# 打印响应
|
||||
# print(response.text)
|
||||
# 检查响应状态码
|
||||
if response.status_code == 200:
|
||||
issue_info = response.json()
|
||||
# print(f'Issue created with ID: {issue_info["number"]}')
|
||||
else:
|
||||
print(f"更新issue状态失败,状态码:{response.status_code},错误信息:{response.text}")
|
||||
print("成功删除gitee—issues")
|
||||
|
||||
# # 连接到MySQL数据库
|
||||
# conn = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
# password="251226X",
|
||||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
#
|
||||
# owner = 'wyf0625'
|
||||
# repo = 'ob-reposyncer-gitee'
|
||||
# delete_gitee_issues(owner, repo, cursor)
|
|
@ -0,0 +1,40 @@
|
|||
import requests
|
||||
import Token
|
||||
import mysql.connector
|
||||
import json
|
||||
|
||||
|
||||
|
||||
def delete_all_issues(owner, repo, cursor):
|
||||
url = f"https://gitlink.org.cn/api/v1/{owner}/{repo}/issues/batch_destroy.json"
|
||||
|
||||
cursor.execute("SELECT issue_id FROM gitlink_issue")
|
||||
gitlink_issue_data = cursor.fetchall()
|
||||
for row in gitlink_issue_data:
|
||||
payload = json.dumps({
|
||||
"ids": [
|
||||
row[0]
|
||||
]
|
||||
})
|
||||
|
||||
token = Token.getToken()
|
||||
headers = {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
||||
# print(response.text)
|
||||
print("成功删除gitlink—issues")
|
||||
|
||||
# conn = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
# password="251226X",
|
||||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
# owner= 'wuyifan'
|
||||
# repo = 'wuyifan-ob-reposyncer'
|
||||
# delete_all_issues(owner, repo, cursor)
|
Binary file not shown.
|
@ -1,16 +0,0 @@
|
|||
export SYS_ENV=DEV
|
||||
export LOG_PATH=
|
||||
export LOG_LV=DEBUG
|
||||
|
||||
# 后端数据库配置
|
||||
export CEROBOT_MYSQL_HOST=127.0.0.1
|
||||
export CEROBOT_MYSQL_PORT=
|
||||
export CEROBOT_MYSQL_USER=""
|
||||
export CEROBOT_MYSQL_PWD=""
|
||||
export CEROBOT_MYSQL_DB=
|
||||
|
||||
# 缓存数据库配置
|
||||
|
||||
# 运行构建任务容器名
|
||||
export EL8_DOCKER_IMAGE=''
|
||||
export EL7_DOCKER_IMAGE=''
|
|
@ -0,0 +1,107 @@
|
|||
import json
|
||||
import urllib
|
||||
import mysql.connector
|
||||
import requests
|
||||
|
||||
def get_issue_details(owner, repo, issue_id, access_token):
|
||||
headers = {
|
||||
'Authorization': f'token {access_token}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
url = f'https://gitee.com/api/v5/repos/{owner}/{repo}/issues/{issue_id}'
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
# print(response.json())
|
||||
return response.json()
|
||||
else:
|
||||
print(f"Failed to retrieve issue {issue_id}. Status code: {response.status_code}")
|
||||
return None
|
||||
|
||||
|
||||
def get_issue_key_info(issue_details, conn, cursor):
|
||||
|
||||
if issue_details:
|
||||
# print(f"Issue ID: {issue_details['number']}")
|
||||
issue_Id = issue_details['number']
|
||||
issue_Title = issue_details['title']
|
||||
issue_Body = issue_details['body']
|
||||
issue_State = issue_details['state']
|
||||
issue_Created_At = issue_details['created_at']
|
||||
issue_Priority = issue_details["priority"]
|
||||
issue_start_date = issue_details['plan_started_at']
|
||||
# print(issue_start_date)
|
||||
try:
|
||||
issue_start_date = issue_start_date.split('T')[0]
|
||||
except:
|
||||
issue_start_date = issue_details['plan_started_at']
|
||||
issue_deadline = issue_details['deadline']
|
||||
# print(issue_deadline)
|
||||
try:
|
||||
issue_deadline = issue_deadline.split('T')[0]
|
||||
except:
|
||||
issue_deadline = issue_details['deadline']
|
||||
issue_branch = issue_details['branch']
|
||||
|
||||
cursor.execute(
|
||||
"INSERT INTO gitee_issue (issue_id, issue_title, issue_body, issue_state, issue_created_at, issue_priority, issue_start_date, issue_deadline, issue_branch) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||
(issue_Id, issue_Title, issue_Body, issue_State, issue_Created_At, issue_Priority, issue_start_date, issue_deadline, issue_branch))
|
||||
conn.commit()
|
||||
result = cursor.fetchall()
|
||||
|
||||
|
||||
def get_gitee_issues(owner, repo, access_token, conn, cursor):
|
||||
headers = {
|
||||
'Authorization': f'token {access_token}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
url = f'https://gitee.com/api/v5/repos/{owner}/{repo}/issues'
|
||||
# 发送POST请求 获取状态为open的issue
|
||||
data = {
|
||||
"access_token": access_token,
|
||||
"owner": owner,
|
||||
"repo": repo,
|
||||
"state": 'all',
|
||||
"sort": 'created',
|
||||
"direction": 'asc'
|
||||
}
|
||||
# 将字典转换为查询字符串
|
||||
query_string = urllib.parse.urlencode(data)
|
||||
|
||||
# 完整的请求 URL,包括查询字符串
|
||||
url = f"{url}?{query_string}"
|
||||
|
||||
response = requests.get(url, headers=headers, json=data)
|
||||
# print(response.text)
|
||||
cursor.execute('DROP TABLE IF EXISTS gitee_issue')
|
||||
# 创建一个表
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS gitee_issue
|
||||
(id INT AUTO_INCREMENT PRIMARY KEY, issue_id VARCHAR(10), issue_title VARCHAR(100), issue_body VARCHAR(1000), issue_state VARCHAR(15), issue_created_at VARCHAR(100), issue_priority INT,issue_start_date VARCHAR(100), issue_deadline VARCHAR(100), issue_branch VARCHAR(100))''')
|
||||
|
||||
if response.status_code == 200:
|
||||
issues = response.json()
|
||||
for issue in issues:
|
||||
# print(issue['number'])
|
||||
issue_details = get_issue_details(owner, repo, issue['number'], access_token)
|
||||
|
||||
if issue_details:
|
||||
get_issue_key_info(issue_details, conn, cursor)
|
||||
print("获取gitee-issue成功")
|
||||
|
||||
# # 连接到数据库
|
||||
# conn = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
# password="251226X",
|
||||
# database="reposyncer"
|
||||
# )
|
||||
#
|
||||
# cursor = conn.cursor()
|
||||
#
|
||||
# # 你的Gitee Access Token
|
||||
# access_token = '62b7d0577a13b75ff066047426df30cb'
|
||||
# # 仓库的拥有者用户名和仓库名
|
||||
# owner = 'wyf0625'
|
||||
# repo = 'ob-reposyncer-gitee'
|
||||
# get_gitee_issues(owner, repo, access_token, conn, cursor)
|
|
@ -0,0 +1,69 @@
|
|||
import json
|
||||
import mysql.connector
|
||||
import requests
|
||||
import Token
|
||||
|
||||
|
||||
def get_issues_detail(owner, repo, token, conn, cursor):
|
||||
url = f"https://gitlink.org.cn/api/v1/{owner}/{repo}/issues.json?category&participant_category&keyword&author_id&milestone_id&assigner_id&status_id&sort_by&sort_direction&issue_tag_ids&page&limit&debug=admin"
|
||||
payload = {}
|
||||
headers = {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)'
|
||||
}
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
# print(response.text)
|
||||
data = json.loads(response.text)
|
||||
cursor.execute('DROP TABLE IF EXISTS gitlink_issue')
|
||||
# 创建一个表
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS gitlink_issue
|
||||
(id INT AUTO_INCREMENT PRIMARY KEY, issue_id VARCHAR(10), subject VARCHAR(100), description VARCHAR(1000), branch_name VARCHAR(15), start_date VARCHAR(100), due_date VARCHAR(100), priority_id INT,project_issues_index INT, status_id INT)''')
|
||||
|
||||
conn.commit()
|
||||
for issue in data["issues"]:
|
||||
issue_id = issue["id"]
|
||||
|
||||
# 打印每个issue的信息
|
||||
url = f"https://gitlink.org.cn/api/v1/{owner}/{repo}/issues/{issue_id}.json"
|
||||
|
||||
headers = {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)'
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
|
||||
# print(response.text)
|
||||
issue_data = json.loads(response.text)
|
||||
issue_id = issue_data["id"]#标识id
|
||||
subject = issue_data["subject"]#标题
|
||||
description = issue_data["description"]#内容
|
||||
branch_name = issue_data["branch_name"]#分支名
|
||||
start_date = issue_data["start_date"]#开始日期
|
||||
due_date = issue_data["due_date"]#完成日期
|
||||
priority_id = issue_data["priority"]["id"]#优先级 1低 2正常 3高 4紧急
|
||||
project_issues_index = issue_data["project_issues_index"] # 顺序位置
|
||||
status_id = issue_data["status"]["id"] #完成状态 1新增 2正在解决 3已解决 5关闭 6拒绝
|
||||
cursor.execute(
|
||||
"INSERT INTO gitlink_issue (issue_id,subject,description,branch_name,start_date,due_date,priority_id,project_issues_index,status_id) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||
(issue_id, subject, description, branch_name, start_date, due_date, priority_id, project_issues_index,
|
||||
status_id))
|
||||
conn.commit()
|
||||
print("获取gitlink—issues成功")
|
||||
|
||||
# # 连接到数据库
|
||||
# conn = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
# password="251226X",
|
||||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
#
|
||||
#
|
||||
# owner= 'wuyifan'
|
||||
# repo = 'wuyifan-ob-reposyncer'
|
||||
# token = Token.getToken()
|
||||
# get_issues_detail(owner, repo, token, conn, cursor)
|
||||
#
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
import urllib
|
||||
import requests
|
||||
import mysql.connector
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def send_gitee_issue(owner, repo, token, conn, cursor):
|
||||
cursor.execute('SELECT subject, description, status_id ,priority_id, start_date, due_date , branch_name FROM gitlink_issue')
|
||||
|
||||
gitlink_result = cursor.fetchall()
|
||||
|
||||
cursor.execute('DROP TABLE IF EXISTS gitee_issue')
|
||||
# 创建一个表
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS gitee_issue
|
||||
(id INT AUTO_INCREMENT PRIMARY KEY, issue_id VARCHAR(10), issue_title VARCHAR(100), issue_body VARCHAR(1000), issue_state VARCHAR(15), issue_created_at VARCHAR(100), issue_priority INT,issue_start_date VARCHAR(100), issue_deadline VARCHAR(100), issue_branch VARCHAR(100))''')
|
||||
|
||||
for row in gitlink_result:
|
||||
# Gitee创建issue的API URL
|
||||
url = f"https://gitee.com/api/v5/repos/{owner}/issues"
|
||||
# 构造请求头
|
||||
|
||||
headers = {'Authorization': f'token {token}'}
|
||||
|
||||
data = {
|
||||
"access_token": token,
|
||||
"owner": owner,
|
||||
"repo": repo,
|
||||
"title": row[0],
|
||||
"body": row[1],
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
issue_info = response.json()
|
||||
if row[2] == 1:
|
||||
state = 'open'
|
||||
elif row[2] == 2:
|
||||
state = 'progressing'
|
||||
else:
|
||||
state = 'closed'
|
||||
|
||||
if row [3] == 1:
|
||||
priority = 1
|
||||
elif row [3] == 2:
|
||||
priority = 2
|
||||
elif row [3] == 3:
|
||||
priority = 3
|
||||
else:
|
||||
priority = 4
|
||||
|
||||
start_date = row[4]
|
||||
due_date = row[5]
|
||||
branch = row[6]
|
||||
|
||||
cursor.execute(
|
||||
"INSERT INTO gitee_issue (issue_id, issue_title, issue_body, issue_state, issue_priority, issue_start_date, issue_deadline, issue_branch) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
(issue_info['number'], row[0], row[1], state, priority, start_date, due_date, branch))
|
||||
conn.commit()
|
||||
|
||||
# # 打印响应
|
||||
# print(response.text)
|
||||
# 检查响应状态码
|
||||
if response.status_code == 201:
|
||||
issue_info = response.json()
|
||||
# print(f'Issue created with ID: {issue_info["number"]}')
|
||||
else:
|
||||
print(f"创建issue失败,状态码:{response.status_code},错误信息:{response.text}")
|
||||
|
||||
###########################更改已经创建好的issue###############################
|
||||
cursor.execute('SELECT issue_id, issue_state, issue_priority, issue_start_date, issue_deadline, issue_branch FROM gitee_issue')
|
||||
# Gitee更新issue的API URL
|
||||
gitee_update_result = cursor.fetchall()
|
||||
for row in gitee_update_result:
|
||||
issue_number = row[0]
|
||||
state = row[1]
|
||||
url = f'https://gitee.com/api/v5/repos/{owner}/issues/{issue_number}'
|
||||
# 构造请求头
|
||||
headers = {'Authorization': f'token {token}'}
|
||||
plan_started_at = row[3]
|
||||
try:
|
||||
date_obj = datetime.strptime(plan_started_at, "%Y-%m-%d")
|
||||
formatted_date_str = date_obj.strftime("%Y-%m-%dT%H:%M:%S") + "+08:00"
|
||||
plan_started_at = date_obj.strftime("%Y-%m-%dT%H:%M:%S") + "+08:00"
|
||||
except:
|
||||
plan_started_at = row[3]
|
||||
deadline = row[4]
|
||||
|
||||
# original_date = datetime.strptime(deadline, "%Y-%m-%d")
|
||||
# target_date = original_date + timedelta(days=2)
|
||||
# target_time = target_date.replace(hour=23, minute=59, second=59)
|
||||
# deadline = target_time.strftime("%Y-%m-%dT%H:%M:%S") + "+08:00"
|
||||
# 发送POST请求
|
||||
data = {
|
||||
"access_token": token,
|
||||
"owner": owner,
|
||||
"repo": repo,
|
||||
"number": issue_number,
|
||||
"state": state,
|
||||
"priority": row[2],
|
||||
"plan_started_at": plan_started_at,
|
||||
"deadline": deadline,
|
||||
"branch": row[5]
|
||||
}
|
||||
# print(plan_started_at,deadline)
|
||||
# 将字典转换为查询字符串
|
||||
query_string = urllib.parse.urlencode(data)
|
||||
|
||||
# 完整的请求 URL,包括查询字符串
|
||||
full_url1 = f"{url}?{query_string}"
|
||||
response = requests.patch(full_url1, headers=headers, json=data)
|
||||
# 打印响应
|
||||
# print(response.text)
|
||||
# 检查响应状态码
|
||||
if response.status_code == 200:
|
||||
issue_info = response.json()
|
||||
# print(f'Issue created with ID: {issue_info["number"]}')
|
||||
else:
|
||||
print(f"创建issue失败,状态码:{response.status_code},错误信息:{response.text}")
|
||||
|
||||
print("成功同步gitlink-issues到gitee_issues")
|
||||
|
||||
# # 连接到MySQL数据库
|
||||
# conn = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
# password="251226X",
|
||||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
#
|
||||
# token = '62b7d0577a13b75ff066047426df30cb'
|
||||
# owner = 'wyf0625'
|
||||
# repo = 'ob-reposyncer-gitee'
|
||||
# send_gitee_issue(owner, repo, token, conn, cursor)
|
|
@ -0,0 +1,75 @@
|
|||
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)
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
|
||||
import re
|
||||
import mysql.connector
|
||||
from fastapi import (
|
||||
Body,
|
||||
Path,
|
||||
|
@ -19,7 +20,8 @@ from src.service.sync_config import SyncService, LogService
|
|||
from src.service.cronjob import sync_repo_task, sync_branch_task, modify_repos, delete_repo_dir
|
||||
from src.base.status_code import Status, SYNCResponse, SYNCException
|
||||
from src.service.cronjob import GITMSGException
|
||||
|
||||
import synchronize_issues_gitee_to_gitlink
|
||||
import synchronize_issues_gitlink_to_gitee
|
||||
|
||||
class SyncDirection(Controller):
|
||||
|
||||
|
@ -160,6 +162,60 @@ class SyncDirection(Controller):
|
|||
msg=Status.SUCCESS.msg
|
||||
)
|
||||
|
||||
@router.post("/repo/issues/{repo_name}", response_model=SYNCResponse, description='执行仓库issue同步')
|
||||
async def sync_repo_issue(
|
||||
self, request: Request, user: str = Depends(user),
|
||||
repo_name: str = Path(..., description="仓库名称"),
|
||||
force_flag: bool = Query(True, description="是否强制同步")
|
||||
# inter_token: str = Path(..., description="inter_token"),
|
||||
# exter_token: str = Path(..., description="exter_token")
|
||||
):
|
||||
api_log(LogType.INFO, f"用户 {user} 使用 POST 方法访问接口 {request.url.path}的issues ", user)
|
||||
conn = mysql.connector.connect(
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT internal_repo_address, external_repo_address, sync_direction FROM sync_repo_mapping WHERE repo_name =%s", (repo_name,))
|
||||
data = cursor.fetchone()
|
||||
internal_repo_address = data[0]
|
||||
external_repo_address = data[1]
|
||||
sync_direction = data[2]
|
||||
# print(inter_token)
|
||||
# print(exter_token)
|
||||
pattern = r'https://[^/]+/([^/]+)/([^/]+)'
|
||||
internal_match = re.search(pattern, internal_repo_address)
|
||||
if internal_match:
|
||||
internal_username = internal_match.group(1) # 第二个括号中的内容(用户名)
|
||||
internal_repo_name = internal_match.group(2) # 第三个括号中的内容(仓库名)
|
||||
print(f"internal用户名: {internal_username}")
|
||||
print(f"internal仓库名: {internal_repo_name}")
|
||||
external_match = re.search(pattern, external_repo_address)
|
||||
if external_match:
|
||||
external_username = external_match.group(1) # 第二个括号中的内容(用户名)
|
||||
external_repo_name = external_match.group(2) # 第三个括号中的内容(仓库名)
|
||||
print(f"external用户名: {external_username}")
|
||||
print(f"external仓库名: {external_repo_name}")
|
||||
|
||||
if sync_direction == "to_outer":
|
||||
if "gitee" in external_repo_address:
|
||||
synchronize_issues_gitlink_to_gitee.synchronize_issues_gitlink_to_gitee(internal_username, external_username, internal_repo_name, external_repo_name)
|
||||
elif "gitlink" in external_repo_address:
|
||||
synchronize_issues_gitee_to_gitlink.synchronize_issues_gitee_to_gitlink(internal_username, external_username, internal_repo_name, external_repo_name)
|
||||
elif sync_direction == "to_inter":
|
||||
if "gitee" in internal_repo_address:
|
||||
synchronize_issues_gitlink_to_gitee.synchronize_issues_gitlink_to_gitee(external_username, internal_username, external_repo_name, internal_repo_name)
|
||||
elif "gitlink" in internal_repo_address:
|
||||
synchronize_issues_gitee_to_gitlink.synchronize_issues_gitee_to_gitlink(external_username, internal_username, external_repo_name, internal_repo_name)
|
||||
|
||||
|
||||
return SYNCResponse(
|
||||
code_status=Status.SUCCESS.code,
|
||||
msg=Status.SUCCESS.msg
|
||||
)
|
||||
|
||||
@router.post("/{repo_name}/branch/{branch_name}", response_model=SYNCResponse, description='执行分支同步')
|
||||
async def sync_branch(
|
||||
self, request: Request, user: str = Depends(user),
|
||||
|
|
|
@ -33,12 +33,13 @@ buc_key and ConfigsUtil.set_obfastapi_config('buc_key', buc_key)
|
|||
DB_ENV = getenv('DB_ENV', 'test_env')
|
||||
DB = {
|
||||
'test_env': {
|
||||
'host': getenv('CEROBOT_MYSQL_HOST', ''),
|
||||
'port': getenv('CEROBOT_MYSQL_PORT', 2883, int),
|
||||
'user': getenv('CEROBOT_MYSQL_USER', ''),
|
||||
'passwd': getenv('CEROBOT_MYSQL_PWD', ''),
|
||||
'dbname': getenv('CEROBOT_MYSQL_DB', '')
|
||||
'host': getenv('CEROBOT_MYSQL_HOST', '127.0.0.1'),
|
||||
'port': getenv('CEROBOT_MYSQL_PORT', 8080, int),
|
||||
'user': getenv('CEROBOT_MYSQL_USER', 'gitlink'),
|
||||
'passwd': getenv('CEROBOT_MYSQL_PWD', 'gitlink'),
|
||||
'dbname': getenv('CEROBOT_MYSQL_DB', 'reposyncer')
|
||||
},
|
||||
|
||||
'local': {
|
||||
'host': getenv('CEROBOT_MYSQL_HOST', ''),
|
||||
'port': getenv('CEROBOT_MYSQL_PORT', 2881, int),
|
||||
|
|
|
@ -59,6 +59,7 @@ def shell(cmd, dire: str, log_name: str, user: str):
|
|||
else:
|
||||
sync_log(LogType.INFO, log, log_name, user)
|
||||
output = subprocess.run(shlex.split(cmd), cwd=dire, capture_output=True, text=True)
|
||||
|
||||
if output.returncode != 0:
|
||||
git_error = get_git_error(output.stderr)
|
||||
if config.LOG_DETAIL:
|
||||
|
@ -95,15 +96,71 @@ def inter_to_outer(repo, branch, log_name: str, user: str, force_flag):
|
|||
shell(f"git fetch internal {inter_name}", repo_dir, log_name, user)
|
||||
# 切换到inter_name分支,并将internal仓库的分支强制 checkout 到当前分支。
|
||||
shell(f"git checkout -B {inter_name} internal/{inter_name}", repo_dir, log_name, user)
|
||||
# 将本地仓库的inter_name分支推送到external仓库的outer_name分支上。
|
||||
# # 将本地仓库的inter_name分支推送到external仓库的outer_name分支上。
|
||||
# if force_flag:
|
||||
# shell(f"git push --force external {inter_name}:{outer_name}", repo_dir, log_name, user)
|
||||
# else:
|
||||
# shell(f"git push external {inter_name}:{outer_name}", repo_dir, log_name, user)
|
||||
# # commit id
|
||||
# # result = shell(f"git log HEAD~1..HEAD --oneline", repo_dir, log_name, user)
|
||||
# # commit_id = result.stdout.split(" ")[0]
|
||||
# result = shell(f'git log -1 --format="%H"', repo_dir, log_name, user)
|
||||
# commit_id = result.stdout[0:7]
|
||||
# sync_log(LogType.INFO, f'[COMMIT ID: {commit_id}]', log_name, user)
|
||||
# return commit_id
|
||||
# 将本地仓库的outer_name分支推送到internal仓库的inter_name分支上。
|
||||
if force_flag:
|
||||
shell(f"git push --force external {inter_name}:{outer_name}", repo_dir, log_name, user)
|
||||
shell(f"git push --force internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
else:
|
||||
shell(f"git push external {inter_name}:{outer_name}", repo_dir, log_name, user)
|
||||
# commit id
|
||||
# result = shell(f"git log HEAD~1..HEAD --oneline", repo_dir, log_name, user)
|
||||
# commit_id = result.stdout.split(" ")[0]
|
||||
result = shell(f'git log -1 --format="%H"', repo_dir, log_name, user)
|
||||
shell(f"git push internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
|
||||
# 使用 git diff 来获取并打印出新加、修改、删除的文件名
|
||||
diff_result = shell(f"git diff --name-status HEAD~1 HEAD", repo_dir, log_name, user)
|
||||
for line in diff_result.stdout.split('\n'):
|
||||
if line:
|
||||
status, filename = line.split('\t')
|
||||
if status == 'A': # 新加的文件
|
||||
sync_log(LogType.INFO, f'Newly added file: {filename}', log_name, user)
|
||||
elif status == 'M': # 修改的文件
|
||||
sync_log(LogType.INFO, f'Newly Modified file: {filename}', log_name, user)
|
||||
# 使用 git diff 命令来获取文件的修改内容
|
||||
diff_result = subprocess.run(
|
||||
shlex.split(f"git diff --unified=0 HEAD~1 HEAD -- {filename}"),
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding='utf-8',
|
||||
errors='replace'
|
||||
)
|
||||
if diff_result.returncode == 0:
|
||||
# 解析 git diff 的输出,跳过文件路径前缀和diff头部信息
|
||||
lines = diff_result.stdout.strip().split('\n')
|
||||
modified_lines = []
|
||||
in_header = True # 标志位,用于跟踪是否仍在diff头部中
|
||||
for line in lines:
|
||||
# 跳过diff的头部信息
|
||||
if line.startswith('diff --git') or line.startswith('index') or line.startswith(
|
||||
'---') or line.startswith('+++'):
|
||||
in_header = True
|
||||
continue
|
||||
# 一旦离开头部,我们就认为接下来的行都是修改内容
|
||||
if in_header and not line.startswith('+') and not line.startswith('-'):
|
||||
in_header = False
|
||||
# 检查行是否以'+'开头(即修改后的行)
|
||||
if line.startswith('+'):
|
||||
modified_line = line.lstrip('+ \t') # 去掉行首的'+'和可能的前缀
|
||||
modified_lines.append(f"+{modified_line}") # 在修改的行前加上'+'
|
||||
# 检查行是否以'-'开头(即被删除的行)
|
||||
elif line.startswith('-'):
|
||||
modified_line = line.lstrip('- \t') # 去掉行首的'-'和可能的前缀
|
||||
modified_lines.append(f"-{modified_line}") # 在删除的行前加上'-
|
||||
modified_content = '\n'.join(modified_lines)
|
||||
sync_log(LogType.INFO, f"文件 {filename} 的修改内容:\n{modified_content}", log_name, user)
|
||||
else:
|
||||
print(f"无法获取文件 {filename} 的修改内容,命令返回码: {diff_result.returncode}")
|
||||
elif status == 'D': # 删除的文件
|
||||
sync_log(LogType.INFO, f'Newly deleted file: {filename}', log_name, user)
|
||||
result = shell(f'git log -1 --format=%h', repo_dir, log_name, user)
|
||||
commit_id = result.stdout[0:7]
|
||||
sync_log(LogType.INFO, f'[COMMIT ID: {commit_id}]', log_name, user)
|
||||
return commit_id
|
||||
|
@ -121,13 +178,68 @@ def outer_to_inter(repo, branch, log_name: str, user: str, force_flag):
|
|||
# 切换到本地仓库的outer_name分支,并将origin仓库的outer_name分支强制 checkout 到当前分支。
|
||||
shell(f"git checkout -B {outer_name} external/{outer_name}", repo_dir, log_name, user)
|
||||
# 将本地仓库的outer_name分支推送到internal仓库的inter_name分支上。
|
||||
# if force_flag:
|
||||
# shell(f"git push --force internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
# else:
|
||||
# shell(f"git push internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
# # commit id
|
||||
# # result = shell(f"git log HEAD~1..HEAD --oneline", repo_dir, log_name, user)
|
||||
# # commit_id = result.stdout.split(" ")[0]
|
||||
# result = shell(f'git log -1 --format=%h', repo_dir, log_name, user)
|
||||
# commit_id = result.stdout[0:7]
|
||||
# sync_log(LogType.INFO, f'[COMMIT ID: {commit_id}]', log_name, user)
|
||||
# return commit_id
|
||||
if force_flag:
|
||||
shell(f"git push --force internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
else:
|
||||
shell(f"git push internal {outer_name}:{inter_name}", repo_dir, log_name, user)
|
||||
# commit id
|
||||
# result = shell(f"git log HEAD~1..HEAD --oneline", repo_dir, log_name, user)
|
||||
# commit_id = result.stdout.split(" ")[0]
|
||||
|
||||
# 使用 git diff 来获取并打印出新加、修改、删除的文件名
|
||||
diff_result = shell(f"git diff --name-status HEAD~1 HEAD", repo_dir, log_name, user)
|
||||
for line in diff_result.stdout.split('\n'):
|
||||
if line:
|
||||
status, filename = line.split('\t')
|
||||
if status == 'A': # 新加的文件
|
||||
sync_log(LogType.INFO, f'Newly added file: {filename}', log_name, user)
|
||||
elif status == 'M': # 修改的文件
|
||||
sync_log(LogType.INFO, f'Newly Modified file: {filename}', log_name, user)
|
||||
# 使用 git diff 命令来获取文件的修改内容
|
||||
diff_result = subprocess.run(
|
||||
shlex.split(f"git diff --unified=0 HEAD~1 HEAD -- {filename}"),
|
||||
cwd=repo_dir,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding='utf-8',
|
||||
errors='replace'
|
||||
)
|
||||
if diff_result.returncode == 0:
|
||||
# 解析 git diff 的输出,跳过文件路径前缀和diff头部信息
|
||||
lines = diff_result.stdout.strip().split('\n')
|
||||
modified_lines = []
|
||||
in_header = True # 标志位,用于跟踪是否仍在diff头部中
|
||||
for line in lines:
|
||||
# 跳过diff的头部信息
|
||||
if line.startswith('diff --git') or line.startswith('index') or line.startswith(
|
||||
'---') or line.startswith('+++'):
|
||||
in_header = True
|
||||
continue
|
||||
# 一旦离开头部,我们就认为接下来的行都是修改内容
|
||||
if in_header and not line.startswith('+') and not line.startswith('-'):
|
||||
in_header = False
|
||||
# 检查行是否以'+'开头(即修改后的行)
|
||||
if line.startswith('+'):
|
||||
modified_line = line.lstrip('+ \t') # 去掉行首的'+'和可能的前缀
|
||||
modified_lines.append(f"+{modified_line}") # 在修改的行前加上'+'
|
||||
# 检查行是否以'-'开头(即被删除的行)
|
||||
elif line.startswith('-'):
|
||||
modified_line = line.lstrip('- \t') # 去掉行首的'-'和可能的前缀
|
||||
modified_lines.append(f"-{modified_line}") # 在删除的行前加上'-
|
||||
modified_content = '\n'.join(modified_lines)
|
||||
sync_log(LogType.INFO, f"文件 {filename} 的修改内容:\n{modified_content}", log_name, user)
|
||||
else:
|
||||
print(f"无法获取文件 {filename} 的修改内容,命令返回码: {diff_result.returncode}")
|
||||
elif status == 'D': # 删除的文件
|
||||
sync_log(LogType.INFO, f'Newly deleted file: {filename}', log_name, user)
|
||||
result = shell(f'git log -1 --format=%h', repo_dir, log_name, user)
|
||||
commit_id = result.stdout[0:7]
|
||||
sync_log(LogType.INFO, f'[COMMIT ID: {commit_id}]', log_name, user)
|
||||
|
|
|
@ -169,7 +169,8 @@ class LogService(Service):
|
|||
|
||||
async def insert_repo_log(self, repo_name: str, direct: str):
|
||||
addr = f"{log_path}/sync_{repo_name}.log"
|
||||
with open(addr, 'r') as fd:
|
||||
# with open(addr, 'r') as fd:
|
||||
with open(addr, 'r', encoding='utf-8') as fd:
|
||||
log_content = fd.read()
|
||||
log_history = f"{log_path}/sync_{repo_name}_history.log"
|
||||
with open(log_history, 'a') as log_:
|
||||
|
@ -191,7 +192,8 @@ class LogService(Service):
|
|||
|
||||
async def insert_branch_log(self, repo_name: str, direct: str, branch_id: int, commit_id: str):
|
||||
addr = f"{log_path}/sync_{repo_name}_{branch_id}.log"
|
||||
with open(addr, 'r') as fd:
|
||||
# with open(addr, 'r') as fd:
|
||||
with open(addr, 'r', encoding='utf-8') as fd:
|
||||
log_content = fd.read()
|
||||
log_history = f"{log_path}/sync_{repo_name}_{branch_id}_history.log"
|
||||
with open(log_history, 'a') as log_:
|
||||
|
|
|
@ -39,7 +39,7 @@ def time_formatter(timestamp):
|
|||
def sync_log(log_type: str, msg: str, log_name: str, user="robot"):
|
||||
name = os.path.join(log_path, log_name)
|
||||
# 创建一个输出到控制台的handler,并设置日志级别为INFO
|
||||
file_handler = logging.FileHandler(name)
|
||||
file_handler = logging.FileHandler(name, encoding='utf-8')
|
||||
# console_handler = logging.StreamHandler()
|
||||
file_handler.setLevel(logging.INFO)
|
||||
# 创建一个格式化器,指定日志格式
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import Token
|
||||
import get_gitee_issue
|
||||
import get_gitlink_issue
|
||||
import delete_gitlink_issues
|
||||
import send_gitlink_issue
|
||||
import mysql.connector
|
||||
|
||||
def synchronize_issues_gitee_to_gitlink(gitee_owner, gitlink_owner, gitee_repo, gitlink_repo):
|
||||
# 连接到数据库
|
||||
conn = mysql.connector.connect(
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# gitlink_owner = 'wuyifan'
|
||||
# gitlink_repo = 'wuyifan-ob-reposyncer'
|
||||
gitlink_token = Token.getToken()
|
||||
|
||||
# gitee_owner = 'wyf0625'
|
||||
# gitee_repo = 'ob-reposyncer-gitee'
|
||||
gitee_token = '62b7d0577a13b75ff066047426df30cb'
|
||||
|
||||
get_gitlink_issue.get_issues_detail(gitlink_owner, gitlink_repo, gitlink_token, conn, cursor)
|
||||
# print("获取gitlink——issue成功")
|
||||
get_gitee_issue.get_gitee_issues(gitee_owner, gitee_repo, gitee_token, conn, cursor)
|
||||
# print("获取gitee-issue成功")
|
||||
delete_gitlink_issues.delete_all_issues(gitlink_owner, gitlink_repo, cursor)
|
||||
# print("成功删除gitlink——issue")
|
||||
send_gitlink_issue.send_gintlink_issue(gitlink_owner, gitlink_repo, gitlink_token, conn, cursor)
|
||||
# print("成功同步gitee_issue到gitlink_issue")
|
|
@ -0,0 +1,25 @@
|
|||
import get_gitee_issue
|
||||
import get_gitlink_issue
|
||||
import delete_gitee_issues
|
||||
import send_gitee_issue
|
||||
import mysql.connector
|
||||
import Token
|
||||
|
||||
def synchronize_issues_gitlink_to_gitee(gitlink_owner, gitee_owner, gitlink_repo, gitee_repo): #gitlink_token, gitee_token):
|
||||
# 连接到数据库
|
||||
conn = mysql.connector.connect(
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
gitlink_token = Token.getToken()
|
||||
gitee_token = '62b7d0577a13b75ff066047426df30cb'
|
||||
|
||||
get_gitlink_issue.get_issues_detail(gitlink_owner, gitlink_repo, gitlink_token, conn, cursor)
|
||||
get_gitee_issue.get_gitee_issues(gitee_owner, gitee_repo, gitee_token, conn, cursor)
|
||||
delete_gitee_issues.delete_gitee_issues(gitee_owner, gitee_repo, cursor)
|
||||
send_gitee_issue.send_gitee_issue(gitee_owner, gitee_repo, gitee_token, conn, cursor)
|
||||
|
Loading…
Reference in New Issue