[scripts/generate_result] add '-g/--git' command-line option

This commit is contained in:
Mike Fährmann
2025-08-17 19:40:39 +02:00
parent d8e466da15
commit c38386f1ed
2 changed files with 8 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ def sort_key(key, value):
return 0
if isinstance(value, str) and "\n" in value:
return 7000
if isinstance(value, list):
if isinstance(value, list) and len(value) > 1:
return 8000
if isinstance(value, dict):
return 9000
@@ -159,6 +159,7 @@ def parse_args(args=None):
parser = argparse.ArgumentParser(args)
parser.add_argument("-c", "--comment", default=None)
parser.add_argument("-C", dest="comment", action="store_const", const="")
parser.add_argument("-g", "--git", action="store_true")
parser.add_argument("-l", "--limit_urls", type=int, default=10)
parser.add_argument("-m", "--metadata", action="store_true")
parser.add_argument("-o", "--option", dest="options", action="append")
@@ -197,6 +198,11 @@ def main():
with util.lazy(path) as fp:
fp.writelines(lines)
if args.git:
path = util.trim(path)
LOG.info("git add %s", path)
util.git("add", "--", path)
if __name__ == "__main__":
logging.basicConfig(

View File

@@ -32,6 +32,7 @@ def git(command, *args):
return subprocess.Popen(
["git", command, *args],
stdout=subprocess.PIPE,
cwd=ROOTDIR,
).communicate()[0].strip().decode()