StoryCheckTools/manage/NovelManage.py

29 lines
741 B
Python
Raw Normal View History

2024-07-29 03:52:28 +00:00
import sys, os
import subprocess as xsub
import time
def git_save(target_dir: str):
retls = xsub.run("git status", shell=True, capture_output=True)
print(retls.stdout)
outlist = str(retls.stdout).split(r'\n')
has_changed:bool = False
for o in outlist:
if o.startswith(r"\tmodified:"):
has_changed = True
break
elif o.startswith(r"\tnew file:"):
has_changed = True
break
if has_changed:
xsub.run("git add .", shell=True)
xsub.run(f"git commit -m 'save-at:{time.time()}'")
if __name__ == "__main__":
print(sys.argv)
cmd_line = ":".join(sys.argv[1:])
#wnss:-cmp
if cmd_line == "wnss:-cmp":
git_save(os.getcwd())