|
@@ -0,0 +1,43 @@
|
|
|
+#!/usr/bin/env python
|
|
|
+# -*- encoding: utf-8 -*-
|
|
|
+'''
|
|
|
+@Author : liuyuqi
|
|
|
+@Contact : liuyuqi.gov@msn.cn
|
|
|
+@Time : 2020/06/08 04:32:47
|
|
|
+@Version : 1.0
|
|
|
+@License : Copyright © 2017-2020 liuyuqi. All Rights Reserved.
|
|
|
+@Desc : 批量查询git远程状态是否有代码更新
|
|
|
+'''
|
|
|
+
|
|
|
+import os
|
|
|
+import sys
|
|
|
+import time
|
|
|
+import re
|
|
|
+
|
|
|
+depth = 2
|
|
|
+
|
|
|
+
|
|
|
+def getStatus(root):
|
|
|
+ files = os.listdir(root)
|
|
|
+ dirs = []
|
|
|
+ for file in files:
|
|
|
+ file_path = os.path.join(root, file)
|
|
|
+ if os.path.isdir(file_path):
|
|
|
+ dirs.append(file)
|
|
|
+ if ".git" in dirs:
|
|
|
+ os.chdir(root)
|
|
|
+ with os.popen("git status") as p:
|
|
|
+ output = p.read()
|
|
|
+ resData = re.split("\n", output)
|
|
|
+ if len(resData) > 2:
|
|
|
+ print(root, "", resData[1])
|
|
|
+ else:
|
|
|
+ for dir in dirs:
|
|
|
+ getStatus(os.path.join(root, dir))
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ folders = ['D:/liuyuqi/github/vue.js']
|
|
|
+ for stuff in folders:
|
|
|
+ stuff = os.path.abspath(os.path.expanduser(os.path.expandvars(stuff)))
|
|
|
+ getStatus(stuff)
|