-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
33 lines (29 loc) · 886 Bytes
/
util.py
File metadata and controls
33 lines (29 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/local/bin/python3.8
import os
import subprocess
def get_home_dir():
return os.path.expanduser("~git")
def get_git_dirs(dir=None):
if dir is None:
dir = get_home_dir()
pass
git_dirs = []
for item in os.listdir(dir):
a_path = os.path.join(dir, item)
if not os.path.isdir(a_path):
continue
if item[-4:] != ".git":
git_dirs = git_dirs + get_git_dirs(a_path)
continue
cmd = 'git --git-dir="{}" rev-parse --is-bare-repository'.format(a_path)
git = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
if git.returncode == 0:
if git.stdout == b'true\n':
git_dirs.append(a_path)
pass
pass
else:
print(git.stderr)
pass
pass
return git_dirs