Skip to content

Commit 42b796a

Browse files
authored
Merge pull request #89 from yzxiu/main
Fix the issue of being unable to read the SUPPORTED_EXTENSIONS enviro…
2 parents 13d2a00 + 6d7856b commit 42b796a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

biz/github/webhook_handler.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
from biz.utils.log import logger
99

10-
# 从环境变量中获取支持的文件扩展名
11-
SUPPORTED_EXTENSIONS = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
1210

1311

1412
def filter_changes(changes: list):
1513
'''
1614
过滤数据,只保留支持的文件类型以及必要的字段信息
1715
专门处理GitHub格式的变更
1816
'''
17+
# 从环境变量中获取支持的文件扩展名
18+
supported_extensions = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
19+
1920
# 筛选出未被删除的文件
2021
not_deleted_changes = []
2122
for change in changes:
@@ -37,7 +38,7 @@ def filter_changes(changes: list):
3738

3839
not_deleted_changes.append(change)
3940

40-
logger.info(f"SUPPORTED_EXTENSIONS: {SUPPORTED_EXTENSIONS}")
41+
logger.info(f"SUPPORTED_EXTENSIONS: {supported_extensions}")
4142
logger.info(f"After filtering deleted files: {not_deleted_changes}")
4243

4344
# 过滤 `new_path` 以支持的扩展名结尾的元素, 仅保留diff和new_path字段
@@ -47,7 +48,7 @@ def filter_changes(changes: list):
4748
'new_path': item['new_path']
4849
}
4950
for item in not_deleted_changes
50-
if any(item.get('new_path', '').endswith(ext) for ext in SUPPORTED_EXTENSIONS)
51+
if any(item.get('new_path', '').endswith(ext) for ext in supported_extensions)
5152
]
5253
logger.info(f"After filtering by extension: {filtered_changes}")
5354
return filtered_changes

biz/gitlab/webhook_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
from biz.utils.log import logger
99

10-
# 从环境变量中获取支持的文件扩展名
11-
SUPPORTED_EXTENSIONS = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
12-
1310

1411
def filter_changes(changes: list):
1512
'''
1613
过滤数据,只保留支持的文件类型以及必要的字段信息
1714
'''
15+
# 从环境变量中获取支持的文件扩展名
16+
supported_extensions = os.getenv('SUPPORTED_EXTENSIONS', '.java,.py,.php').split(',')
17+
1818
filter_deleted_files_changes = [change for change in changes if change.get("deleted_file") == False]
1919

2020
# 过滤 `new_path` 以支持的扩展名结尾的元素, 仅保留diff和new_path字段
@@ -24,7 +24,7 @@ def filter_changes(changes: list):
2424
'new_path': item['new_path']
2525
}
2626
for item in filter_deleted_files_changes
27-
if any(item.get('new_path', '').endswith(ext) for ext in SUPPORTED_EXTENSIONS)
27+
if any(item.get('new_path', '').endswith(ext) for ext in supported_extensions)
2828
]
2929
return filtered_changes
3030

0 commit comments

Comments
 (0)