forked from Lesin/reposync
This commit is contained in:
parent
eec9f48cd8
commit
432fab153e
14
Dockerfile
14
Dockerfile
|
@ -7,19 +7,14 @@ RUN cd /data/ob-tool && tar xzf Python-3.9.6.tgz
|
|||
RUN cd /data/ob-tool/Python-3.9.6 && ./configure --enable-optimizations && make altinstall
|
||||
|
||||
ADD ./ /data/ob-robot/
|
||||
RUN wget https://github.com/encode/uvicorn/archive/refs/tags/0.14.0.tar.gz && \
|
||||
tar -zvxf 0.14.0.tar.gz && \
|
||||
cd uvicorn-0.14.0 && \
|
||||
pip3.9 install . && \
|
||||
cd /data/ob-robot/ && \
|
||||
pip3.9 install -r /data/ob-robot/requirement.txt && \
|
||||
pip3.9 install -i https://pypi.tuna.tsinghua.edu.cn/simple mysql-connector-python
|
||||
RUN cd /data/ob-robot/ && \
|
||||
pip3.9 install -r /data/ob-robot/requirement.txt
|
||||
|
||||
RUN yum install -y git openssh-server
|
||||
|
||||
ENV GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa'
|
||||
RUN yum install -y autoconf gettext && \
|
||||
wget https://github.com/git/git/archive/refs/tags/v2.32.0.tar.gz && \
|
||||
wget http://github.com/git/git/archive/v2.32.0.tar.gz && \
|
||||
tar -xvf v2.32.0.tar.gz && \
|
||||
rm -f v2.32.0.tar.gz && \
|
||||
cd git-* && \
|
||||
|
@ -28,6 +23,5 @@ RUN yum install -y autoconf gettext && \
|
|||
make -j16 && \
|
||||
make install
|
||||
|
||||
|
||||
WORKDIR /data/ob-robot
|
||||
CMD python3.9 main.py;
|
||||
CMD if [ "$BOOT_MODE" = "app" ] ; then python3.9 main.py; fi
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Description
|
||||
|
||||
ob-repository-synchronize is a small tool which can help engineer to master their open source production's code synchronization between GitHub, Gitee, CodeChina, internal repository and so on
|
||||
ob-repository-synchronize is a small tool which can help engineer to master their open source production's code synchronization between GitHub, Gitee, CodeChina, internal repository and so on.
|
||||
|
||||
## Principle
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import requests
|
||||
import Token
|
||||
import mysql.connector
|
||||
import json
|
||||
|
||||
|
||||
|
||||
def delete_all_issues(cursor):
|
||||
owner= 'wuyifan'
|
||||
repo = 'wuyifan-ob-reposyncer'
|
||||
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")
|
||||
|
@ -18,7 +17,7 @@ def delete_all_issues(cursor):
|
|||
]
|
||||
})
|
||||
|
||||
token = 'gzH8B9wvjs_82e5IoTe9Fi79OwKp0Z0CtBGyyz1GWFI'
|
||||
token = Token.getToken()
|
||||
headers = {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
||||
|
@ -36,4 +35,6 @@ def delete_all_issues(cursor):
|
|||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
# delete_all_issues(cursor)
|
||||
# owner= 'wuyifan'
|
||||
# repo = 'wuyifan-ob-reposyncer'
|
||||
# delete_all_issues(owner, repo, cursor)
|
|
@ -1,11 +1,8 @@
|
|||
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}',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
import mysql.connector
|
||||
import requests
|
||||
|
||||
import Token
|
||||
|
||||
|
||||
def get_issues_detail(owner, repo, token, conn, cursor):
|
||||
|
@ -59,11 +59,11 @@ def get_issues_detail(owner, repo, token, conn, cursor):
|
|||
# database="reposyncer"
|
||||
# )
|
||||
# cursor = conn.cursor()
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
# owner= 'wuyifan'
|
||||
# repo = 'wuyifan-ob-reposyncer'
|
||||
# token = 'gzH8B9wvjs_82e5IoTe9Fi79OwKp0Z0CtBGyyz1GWFI'
|
||||
# token = Token.getToken()
|
||||
# get_issues_detail(owner, repo, token, conn, cursor)
|
||||
|
||||
#
|
||||
|
||||
|
|
|
@ -172,9 +172,9 @@ class SyncDirection(Controller):
|
|||
):
|
||||
api_log(LogType.INFO, f"用户 {user} 使用 POST 方法访问接口 {request.url.path}的issues ", user)
|
||||
conn = mysql.connector.connect(
|
||||
host="120.27.216.107",
|
||||
user="gitlink",
|
||||
password="gitlink",
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
|
|
@ -33,8 +33,8 @@ 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', '120.27.216.107'),
|
||||
'port': getenv('CEROBOT_MYSQL_PORT', 3306, int),
|
||||
'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')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import Token
|
||||
import get_gitee_issue
|
||||
import get_gitlink_issue
|
||||
import delete_gitlink_issues
|
||||
|
@ -7,16 +8,16 @@ import mysql.connector
|
|||
def synchronize_issues_gitee_to_gitlink(gitee_owner, gitlink_owner, gitee_repo, gitlink_repo):
|
||||
# 连接到数据库
|
||||
conn = mysql.connector.connect(
|
||||
host="120.27.216.107",
|
||||
user="gitlink",
|
||||
password="gitlink",
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# gitlink_owner = 'wuyifan'
|
||||
# gitlink_repo = 'wuyifan-ob-reposyncer'
|
||||
gitlink_token = '2j0LVeSr1OQP6dbCC9D7V2G_4XpVR2bFg0VNemHoLRY'
|
||||
gitlink_token = Token.getToken()
|
||||
|
||||
# gitee_owner = 'wyf0625'
|
||||
# gitee_repo = 'ob-reposyncer-gitee'
|
||||
|
@ -26,7 +27,7 @@ def synchronize_issues_gitee_to_gitlink(gitee_owner, gitlink_owner, gitee_repo,
|
|||
# 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(cursor)
|
||||
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")
|
||||
|
|
|
@ -3,26 +3,23 @@ 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="120.27.216.107",
|
||||
user="gitlink",
|
||||
password="gitlink",
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="251226X",
|
||||
database="reposyncer"
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# gitlink_owner = 'wuyifan'
|
||||
# gitlink_repo = 'wuyifan-ob-reposyncer'
|
||||
gitlink_token = '2j0LVeSr1OQP6dbCC9D7V2G_4XpVR2bFg0VNemHoLRY'
|
||||
|
||||
# gitee_owner = 'wyf0625'
|
||||
# gitee_repo = 'ob-reposyncer-gitee'
|
||||
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