diff --git a/.idea/misc.xml b/.idea/misc.xml
index e2c99dd41..7ce187f78 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/reposync.iml b/.idea/reposync.iml
index fff21e3f4..63f18ac03 100644
--- a/.idea/reposync.iml
+++ b/.idea/reposync.iml
@@ -4,7 +4,7 @@
-
+
diff --git a/decode.py b/decode.py
new file mode 100644
index 000000000..aee4b4eb0
--- /dev/null
+++ b/decode.py
@@ -0,0 +1,124 @@
+import re
+
+def parse_git_output(output):
+ # 定义正则表达式模式
+ commit_pattern = re.compile(r'commit\s+([a-f0-9]+)')
+ author_pattern = re.compile(r'Author:\s+(.+)')
+ date_pattern = re.compile(r'Date:\s+(.+)')
+
+ # 使用正则表达式搜索并提取信息
+ commit_hash = commit_pattern.search(output).group(1) if commit_pattern.search(output) else None
+ author = author_pattern.search(output).group(1) if author_pattern.search(output) else None
+ date = date_pattern.search(output).group(1) if date_pattern.search(output) else None
+
+ return commit_hash, author, date
+
+def extract_diff_content(git_diff_output):
+ # 定义正则表达式,匹配从 'diff --git' 开始到 'index' 之前的文本
+ pattern = re.compile(r'diff --git(.+?)(?=\nindex|$)', re.DOTALL)
+
+ # 使用正则表达式查找所有匹配项
+ matches = pattern.findall(git_diff_output)
+
+ # 存储截取的内容
+ extracted_contents = []
+
+ # 遍历所有匹配项
+ for match in matches:
+ # 去除每个匹配项中的空白行,并添加到结果列表
+ cleaned_match = '\n'.join(line for line in match.strip().split('\n') if line)
+ extracted_contents.append(cleaned_match)
+
+ return extracted_contents
+
+def extract_changes_since_last_diff(diff_output):
+ # 定义正则表达式,匹配 '+++ b' 后面的内容,直到下一个 'diff' 或文本末尾
+ pattern = re.compile(r'\+\+\+ b/(.+?)(?=\ndiff --git|$)', re.DOTALL)
+
+ # 使用正则表达式查找所有匹配项
+ matches = pattern.findall(diff_output)
+
+ # 处理匹配结果,每项匹配结果是一个元组,包含从 '+++ b/' 到下一个 'diff' 或文本末尾的内容
+ extracted_content = []
+ for match in matches:
+ # 去除匹配内容中的 '\ No newline at end of file' 行
+ content = '\n'.join([line for line in match.strip().split('\n') if line and line != '\\ No newline at end of file'])
+ extracted_content.append(content)
+
+ return extracted_content
+
+git_diff_output = """
+Last commit hash before push: commit d5f594d3bc9bf2fabf1f97cd375f1ca8be821d60
+Author: xmy <1926207361@qq.com>
+Date: Wed Jun 26 08:02:53 2024 +0800
+ closer
+diff --git a/src/Merry_Christmas.txt b/src/Merry_Christmas.txt
+new file mode 100644
+index 0000000..8f3694f
+--- /dev/null
++++ b/src/Merry_Christmas.txt
+@@ -0,0 +1 @@
++坂本龙一
+\ No newline at end of file
+diff --git a/src/changsha.txt b/src/changsha.txt
+index 7df336a..f007879 100644
+--- a/src/changsha.txt
++++ b/src/changsha.txt
+@@ -1 +1,3 @@
+-抗洪抢险 党员优先
+\ No newline at end of file
++抗洪抢险 党员优先
++
++新增调试
+\ No newline at end of file
+"""
+
+commit_hash, author, date = parse_git_output(git_diff_output)
+print("Commit Hash:", commit_hash)
+print("Author:", author)
+print("Date:", date)
+print("\n")
+
+extracted_contents = extract_diff_content(git_diff_output)
+
+# 提取 '+++ b' 后面的内容
+changes_since_last_diff = extract_changes_since_last_diff(git_diff_output)
+
+# 打印提取的内容
+for content in extracted_contents:
+ if 'new file' in content:
+ pattern = re.compile(r' b/(.+?)(?=\nnew|$)', re.DOTALL)
+ # 使用正则表达式查找所有匹配项
+ matches = pattern.findall(content)
+ # 存储截取的内容
+ add_files = []
+ # 遍历所有匹配项
+ for match in matches:
+ # 去除每个匹配项中的空白行,并添加到结果列表
+ cleaned_match = '\n'.join(line for line in match.strip().split('\n') if line)
+ add_files.append(cleaned_match)
+
+ print('ADD_FILES:', add_files)
+
+ for add_file in add_files:
+ for change in changes_since_last_diff:
+ if add_file in change:
+ print("\n"+change)
+ print("\n--- End of Extracted Content ---\n")
+ else:
+ pattern = re.compile(r'a/(.+?)(?=b|$)', re.DOTALL)
+ # 使用正则表达式查找所有匹配项
+ matches = pattern.findall(content)
+ # 存储截取的内容
+ modified_files = []
+ # 遍历所有匹配项
+ for match in matches:
+ # 去除每个匹配项中的空白行,并添加到结果列表
+ cleaned_match = '\n'.join(line for line in match.strip().split('\n') if line)
+ modified_files.append(cleaned_match)
+ print('MODIFIED_FILES:', modified_files)
+ for modified_file in modified_files:
+ for change in changes_since_last_diff:
+ if modified_file in change:
+ print("\n"+ change)
+ print("\n--- End of Extracted Content ---\n")
diff --git a/main.py b/main.py
index d51421048..2137653ad 100644
--- a/main.py
+++ b/main.py
@@ -25,7 +25,7 @@ app.include_router(LOG)
app.include_router(AUTH)
app.include_router(SYNC_CONFIG)
-app.mount("/", StaticFiles(directory="web"), name="static")
+# app.mount("/", StaticFiles(directory="web/dist"), name="static")
if __name__ == '__main__':
# workers 参数仅在命令行使用uvicorn启动时有效 或使用环境变量 WEB_CONCURRENCY
diff --git a/sql/20240408.sql b/sql/20240408.sql
index 32849ae3b..76cf55ad3 100644
--- a/sql/20240408.sql
+++ b/sql/20240408.sql
@@ -1,4 +1,3 @@
---同步仓库信息映射表
CREATE TABLE IF NOT EXISTS `sync_repo_mapping` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
@@ -13,7 +12,6 @@ CREATE TABLE IF NOT EXISTS `sync_repo_mapping` (
UNIQUE KEY (`repo_name`)
) DEFAULT CHARACTER SET = utf8mb4 COMMENT = '同步仓库映射表';
---同步分支信息映射表
CREATE TABLE IF NOT EXISTS `sync_branch_mapping`(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
@@ -26,7 +24,6 @@ CREATE TABLE IF NOT EXISTS `sync_branch_mapping`(
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET = utf8mb4 COMMENT = '同步分支映射表';
---日志信息表
CREATE TABLE IF NOT EXISTS `repo_sync_log`(
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
diff --git a/src/api/Sync_config.py b/src/api/Sync_config.py
index f621ac6ff..b6eee0115 100644
--- a/src/api/Sync_config.py
+++ b/src/api/Sync_config.py
@@ -38,11 +38,11 @@ class SyncDirection(Controller):
dto: SyncRepoDTO = Body(..., description="绑定同步仓库信息")
):
api_log(LogType.INFO, f"用户 {user} 使用 POST 方法访问接口 {request.url.path} ", user)
- if not base.check_addr(dto.external_repo_address) or not base.check_addr(dto.internal_repo_address):
- return SYNCResponse(
- code_status=Status.REPO_ADDR_ILLEGAL.code,
- msg=Status.REPO_ADDR_ILLEGAL.msg
- )
+ # if not base.check_addr(dto.external_repo_address) or not base.check_addr(dto.internal_repo_address):
+ # return SYNCResponse(
+ # code_status=Status.REPO_ADDR_ILLEGAL.code,
+ # msg=Status.REPO_ADDR_ILLEGAL.msg
+ # )
if dto.sync_granularity not in [1, 2]:
return SYNCResponse(code_status=Status.SYNC_GRAN_ILLEGAL.code, msg=Status.SYNC_GRAN_ILLEGAL.msg)
diff --git a/src/base/config.py b/src/base/config.py
index 28949c4aa..717588e21 100644
--- a/src/base/config.py
+++ b/src/base/config.py
@@ -35,9 +35,9 @@ DB = {
'test_env': {
'host': getenv('CEROBOT_MYSQL_HOST', 'localhost'),
'port': getenv('CEROBOT_MYSQL_PORT', 3306, int),
- 'user': getenv('CEROBOT_MYSQL_USER', 'rtsw'),
- 'passwd': getenv('CEROBOT_MYSQL_PWD', '123456'),
- 'dbname': getenv('CEROBOT_MYSQL_DB', 'reposyncer')
+ 'user': getenv('CEROBOT_MYSQL_USER', 'root'),
+ 'passwd': getenv('CEROBOT_MYSQL_PWD', '185102xmy'),
+ 'dbname': getenv('CEROBOT_MYSQL_DB', 'reposyncer3'),
},
'local': {
'host': getenv('CEROBOT_MYSQL_HOST', ''),
diff --git a/src/service/sync_config.py b/src/service/sync_config.py
index 64835173c..7b2ffa609 100644
--- a/src/service/sync_config.py
+++ b/src/service/sync_config.py
@@ -112,14 +112,14 @@ class SyncService(Service):
if repo is None:
return SYNCException(Status.REPO_NOTFOUND)
update_fields = {}
- if dto.internal_repo_address is not None:
- if not base.check_addr(dto.internal_repo_address):
- return SYNCException(Status.REPO_ADDR_ILLEGAL)
- update_fields['internal_repo_address'] = dto.internal_repo_address
- if dto.external_repo_address is not None:
- if not base.check_addr(dto.external_repo_address):
- return SYNCException(Status.REPO_ADDR_ILLEGAL)
- update_fields['external_repo_address'] = dto.external_repo_address
+ # if dto.internal_repo_address is not None:
+ # if not base.check_addr(dto.internal_repo_address):
+ # return SYNCException(Status.REPO_ADDR_ILLEGAL)
+ update_fields['internal_repo_address'] = dto.internal_repo_address
+ # if dto.external_repo_address is not None:
+ # if not base.check_addr(dto.external_repo_address):
+ # return SYNCException(Status.REPO_ADDR_ILLEGAL)
+ update_fields['external_repo_address'] = dto.external_repo_address
if dto.inter_token is not None:
update_fields['inter_token'] = dto.inter_token
if dto.exter_token is not None:
diff --git a/src/utils/sync_log.py b/src/utils/sync_log.py
index bc196b970..365049564 100644
--- a/src/utils/sync_log.py
+++ b/src/utils/sync_log.py
@@ -47,7 +47,6 @@ def sync_log(log_type: str, msg: str, log_name: str, user="robot"):
datefmt='%Y-%m-%d %H:%M:%S')
formatter.converter = time_formatter
file_handler.setFormatter(formatter)
-
# 创建一个logger
logger = logging.getLogger('logger')
logger.setLevel(logging.INFO)
diff --git a/新增文档尝试.txt b/新增文档尝试.txt
deleted file mode 100644
index 384126cda..000000000
--- a/新增文档尝试.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-2024.06.07 8.20提交
-检验是否同步
-
-8:28 第二次同步尝试
\ No newline at end of file
diff --git a/第三次新增push尝试.txt b/第三次新增push尝试.txt
deleted file mode 100644
index 01ce3a394..000000000
--- a/第三次新增push尝试.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-2024.06.07
-时间 8:31
\ No newline at end of file