Skip to content

Commit ac53cb8

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8c3f329 + fb6a830 commit ac53cb8

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

scripts/rules_config.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ match=Surge/Ruleset/**
2121
url=https://github.com/NobyDa/Script
2222
branch=master
2323
match=Surge/*.list
24+
25+
[lhie1]
26+
url=https://github.com/dler-io/Rules
27+
branch=main
28+
match=Surge/Surge 3/Provider/**

scripts/update_rules.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def update_rules(repo_path: str, save_path: str, matches: list[str], keep_tree:
2626
os.makedirs(save_path, exist_ok=True)
2727
for pattern in matches:
2828
files = glob.glob(os.path.join(repo_path, pattern), recursive=True)
29+
if len(files) == 0:
30+
logging.warn(f"no files found for pattern {pattern}")
31+
continue
2932
for file in files:
3033
if os.path.isdir(file):
3134
continue
@@ -68,15 +71,19 @@ def main():
6871
else:
6972
logging.info(f"repo {repo_path} exists")
7073

71-
if commit is not None:
72-
logging.info(f"checking out to commit {commit}")
73-
r.git.checkout(commit)
74-
elif branch is not None:
75-
logging.info(f"checking out to branch {branch}")
76-
r.branches[branch].checkout()
77-
else:
78-
logging.info(f"checking out to default branch")
79-
r.active_branch.checkout()
74+
try:
75+
if commit is not None:
76+
logging.info(f"checking out to commit {commit}")
77+
r.git.checkout(commit)
78+
elif branch is not None:
79+
logging.info(f"checking out to branch {branch}")
80+
r.git.checkout(branch)
81+
else:
82+
logging.info(f"checking out to default branch")
83+
r.active_branch.checkout()
84+
except Exception as e:
85+
logging.error(f"checkout failed {e}")
86+
continue
8087

8188
update_rules(repo_path, save_path, matches, keep_tree)
8289

0 commit comments

Comments
 (0)