|
@@ -18,13 +18,22 @@ class AutoCommit(object):
|
|
|
def _commit(self, path):
|
|
|
""" git commit """
|
|
|
os.chdir(path)
|
|
|
- print(f"{bcolors.OKGREEN}commiting {path}{bcolors.ENDC}")
|
|
|
+ print(f"{bcolors.OKGREEN} commiting {path}{bcolors.ENDC}")
|
|
|
os.system("git add .")
|
|
|
os.system("git commit -m \"Automatic Commit By liuyuqi\"")
|
|
|
- print(f"{bcolors.OKGREEN}commit success{bcolors.ENDC}")
|
|
|
+ print(f"{bcolors.OKGREEN} commit finish{bcolors.ENDC}")
|
|
|
# os.chdir(work_dir)
|
|
|
|
|
|
- def run(self):
|
|
|
+ def _sync(self, path):
|
|
|
+ """ git pull """
|
|
|
+ os.chdir(path)
|
|
|
+ print(f"{bcolors.OKGREEN} syncing {path}{bcolors.ENDC}")
|
|
|
+ os.system("git pull")
|
|
|
+ os.system("git push")
|
|
|
+ print(f"{bcolors.OKGREEN} sync finish{bcolors.ENDC}")
|
|
|
+ # os.chdir(work_dir)
|
|
|
+
|
|
|
+ def commit(self):
|
|
|
""" run """
|
|
|
if ".git" in os.listdir(self.params['path']):
|
|
|
self._commit(self.params['path'])
|
|
@@ -32,4 +41,14 @@ class AutoCommit(object):
|
|
|
for root, dirs, files in os.walk(self.params['path']):
|
|
|
if ".git" in dirs:
|
|
|
self._commit(root)
|
|
|
- os.system("pause")
|
|
|
+ os.system("pause")
|
|
|
+
|
|
|
+ def sync(self):
|
|
|
+ """ sync """
|
|
|
+ if ".git" in os.listdir(self.params['path']):
|
|
|
+ self._sync(self.params['path'])
|
|
|
+ else:
|
|
|
+ for root, dirs, files in os.walk(self.params['path']):
|
|
|
+ if ".git" in dirs:
|
|
|
+ self._sync(root)
|
|
|
+ os.system("pause")
|