33 lines
853 B
Python
33 lines
853 B
Python
import sys, os
|
|
import subprocess as xsub
|
|
import time
|
|
from typing import List
|
|
|
|
|
|
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
|
|
|
|
files_path:List[str] = []
|
|
for o in outlist:
|
|
modified_flag = r"\tmodified:"
|
|
if o.startswith(modified_flag):
|
|
has_changed = True
|
|
files_path.append(o[len(modified_flag):])
|
|
|
|
elif o.startswith(r"\tnew file:"):
|
|
has_changed = True
|
|
|
|
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()) |