27 lines
705 B
Python
27 lines
705 B
Python
|
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
|
||
|
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())
|