mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 02:42:25 +00:00
Add lhie1 rules to auto update config
This commit is contained in:
@@ -21,3 +21,8 @@ match=Surge/Ruleset/**
|
|||||||
url=https://github.com/NobyDa/Script
|
url=https://github.com/NobyDa/Script
|
||||||
branch=master
|
branch=master
|
||||||
match=Surge/*.list
|
match=Surge/*.list
|
||||||
|
|
||||||
|
[lhie1]
|
||||||
|
url=https://github.com/dler-io/Rules
|
||||||
|
branch=main
|
||||||
|
match=Surge/Surge 3/Provider/**
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ def update_rules(repo_path: str, save_path: str, matches: list[str], keep_tree:
|
|||||||
os.makedirs(save_path, exist_ok=True)
|
os.makedirs(save_path, exist_ok=True)
|
||||||
for pattern in matches:
|
for pattern in matches:
|
||||||
files = glob.glob(os.path.join(repo_path, pattern), recursive=True)
|
files = glob.glob(os.path.join(repo_path, pattern), recursive=True)
|
||||||
|
if len(files) == 0:
|
||||||
|
logging.warn(f"no files found for pattern {pattern}")
|
||||||
|
continue
|
||||||
for file in files:
|
for file in files:
|
||||||
if os.path.isdir(file):
|
if os.path.isdir(file):
|
||||||
continue
|
continue
|
||||||
@@ -68,15 +71,19 @@ def main():
|
|||||||
else:
|
else:
|
||||||
logging.info(f"repo {repo_path} exists")
|
logging.info(f"repo {repo_path} exists")
|
||||||
|
|
||||||
if commit is not None:
|
try:
|
||||||
logging.info(f"checking out to commit {commit}")
|
if commit is not None:
|
||||||
r.git.checkout(commit)
|
logging.info(f"checking out to commit {commit}")
|
||||||
elif branch is not None:
|
r.git.checkout(commit)
|
||||||
logging.info(f"checking out to branch {branch}")
|
elif branch is not None:
|
||||||
r.git.checkout(branch)
|
logging.info(f"checking out to branch {branch}")
|
||||||
else:
|
r.git.checkout(branch)
|
||||||
logging.info(f"checking out to default branch")
|
else:
|
||||||
r.active_branch.checkout()
|
logging.info(f"checking out to default branch")
|
||||||
|
r.active_branch.checkout()
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"checkout failed {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
update_rules(repo_path, save_path, matches, keep_tree)
|
update_rules(repo_path, save_path, matches, keep_tree)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user