-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_status_all.py
More file actions
46 lines (37 loc) · 1.44 KB
/
git_status_all.py
File metadata and controls
46 lines (37 loc) · 1.44 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import subprocess
import argparse
def is_git_repo(path):
return os.path.isdir(os.path.join(path, ".git"))
def git_status_in_subfolders(base_dir="."):
for folder in sorted(os.listdir(base_dir)):
full_path = os.path.join(base_dir, folder)
if not os.path.isdir(full_path):
continue
if not is_git_repo(full_path):
continue
result = subprocess.run(
["git", "-C", full_path, "status", "--short"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
text=True
)
branch_result = subprocess.run(
["git", "-C", full_path, "branch", "--show-current"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
text=True
)
branch = branch_result.stdout.strip()
output = result.stdout.strip()
if output:
print(f"📂 {folder} [{branch}] – Änderungen:")
for line in output.splitlines():
print(f" {line}")
else:
print(f"✅ {folder} [{branch}] – sauber")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Zeige git status für alle Git-Repos in einem Verzeichnis.")
parser.add_argument("basedir", nargs="?", default=".", help="Pfad zum Basisverzeichnis (optional, Standard: aktuelles Verzeichnis)")
args = parser.parse_args()
git_status_in_subfolders(args.basedir)