2 Commits b886435d75 ... f0bc67d3c2

Author SHA1 Message Date
  liuyuqi-dellpc f0bc67d3c2 Merge branch 'release/0.6.0' 2 weeks ago
  liuyuqi-dellpc 0d8f515850 新增 check 命令,用于检查项目更新状态 2 weeks ago
4 changed files with 30 additions and 1 deletions
  1. 1 0
      README.md
  2. 25 0
      auto_commit/auto_commit.py
  3. 1 1
      auto_commit/options.py
  4. 3 0
      main.py

+ 1 - 0
README.md

@@ -5,6 +5,7 @@
 ```
 auto_commit commit --path <curpath>
 auto_commit sync --path <curpath>
+auto_commit check --path <curpath>
 ```
 
 ## License

+ 25 - 0
auto_commit/auto_commit.py

@@ -24,6 +24,20 @@ class AutoCommit(object):
         print(f"{bcolors.OKGREEN} commit finish{bcolors.ENDC}")
         # os.chdir(work_dir)
 
+    def _check(self, path):
+        """ git status """
+        os.chdir(path)
+        print(f"{bcolors.OKGREEN} checking {path}{bcolors.ENDC}")
+        os.system("git status")
+        # with os.popen("git status") as p:
+        #     output = p.read()
+        #     resData = re.split("\n", output)
+        #     if len(resData) > 2:
+        #         print(f"{bcolors.FAIL} check error: {resData} {bcolors.ENDC}")
+        #         exit(1)
+        # print(f"{bcolors.OKGREEN} check finish{bcolors.ENDC}")
+        # os.chdir(work_dir)
+
     def _sync(self, path):
         """ git pull """
         os.chdir(path)
@@ -33,6 +47,17 @@ class AutoCommit(object):
         print(f"{bcolors.OKGREEN} sync finish{bcolors.ENDC}")
         # os.chdir(work_dir)
 
+    def check(self):
+        """ check project update"""
+        if ".git" in os.listdir(self.params['path']):
+            self._check(self.params['path'])
+        else:
+            for root, dirs, files in os.walk(self.params['path']):
+                if ".git" in dirs:
+                    self._check(root)
+        os.system("pause")
+
+
     def commit(self):
         """ run """
         if ".git" in os.listdir(self.params['path']):

+ 1 - 1
auto_commit/options.py

@@ -23,7 +23,7 @@ def parse_args():
                                      ''', epilog="Believe that with the above description, " +
                                                             "you can start working right away. Wish you success")
     # group = parser.add_mutually_exclusive_group()
-    parser.add_argument('cmd',  help='cmd: commit, sync', choices=['commit','sync', 'help','version'] , default='help')
+    parser.add_argument('cmd',  help='cmd: commit, sync, check', choices=['commit','sync', 'check', 'help','version'] , default='help')
     parser.add_argument('--path', help='set a path')
     args = parser.parse_args()
 

+ 3 - 0
main.py

@@ -21,6 +21,9 @@ if __name__=='__main__':
             elif args['cmd'] == 'sync':
                 auto_commit = AutoCommit(params=args)
                 auto_commit.sync()
+            elif args['cmd'] == 'check':
+                auto_commit = AutoCommit(params=args)
+                auto_commit.check()
             elif args['cmd'] == 'help':
                 print('help')
             elif args['cmd'] == 'version':