|
@@ -0,0 +1,39 @@
|
|
1
|
+#!/home/dirk/bin/venv/bin/python
|
|
2
|
+# -*- coding: UTF-8 -*-
|
|
3
|
+
|
|
4
|
+import optparse
|
|
5
|
+import os
|
|
6
|
+
|
|
7
|
+repolist = []
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+def findrepos(p, **kwargs):
|
|
11
|
+ depth = kwargs.get('depth', 0)
|
|
12
|
+ max_depth = kwargs.get('max_depth')
|
|
13
|
+ ld = os.listdir(p)
|
|
14
|
+ if '.git' in ld:
|
|
15
|
+ if os.path.isdir(os.path.join(p, '.git')):
|
|
16
|
+ repolist.append(p)
|
|
17
|
+ return
|
|
18
|
+ else:
|
|
19
|
+ for entry in ld:
|
|
20
|
+ np = os.path.join(p, entry)
|
|
21
|
+ if os.path.isdir(np):
|
|
22
|
+ findrepos(np, depth=depth+1, max_depth=max_depth)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+if __name__ == "__main__":
|
|
26
|
+ parser = optparse.OptionParser("usage: %%prog target_path [opions]")
|
|
27
|
+ parser.add_option("-d", "--depth", dest="depth", default=None, type="int", help="Folder depth to search for a repo")
|
|
28
|
+ parser.add_option("-p", "--human-readable", dest="human_readable", action="store_true", default=False, help="Print a human readable list")
|
|
29
|
+ (options, args) = parser.parse_args()
|
|
30
|
+
|
|
31
|
+ if len(args) != 1:
|
|
32
|
+ parser.print_help()
|
|
33
|
+ else:
|
|
34
|
+ findrepos(args[0])
|
|
35
|
+ repolist.sort()
|
|
36
|
+ if options.human_readable:
|
|
37
|
+ print('- ' + '\n- '.join(repolist), '\n')
|
|
38
|
+ else:
|
|
39
|
+ print(' '.join(repolist))
|