mirror of
https://git.alemi.dev/gitshell.git
synced 2024-11-21 23:14:53 +01:00
28 lines
782 B
Text
28 lines
782 B
Text
|
#!/usr/bin/env python3
|
||
|
|
||
|
import os
|
||
|
import subprocess
|
||
|
from pathlib import Path
|
||
|
|
||
|
GIT_ROOT = Path(os.environ.get("GIT_ROOT_DIR") or "/srv/git/")
|
||
|
|
||
|
def update_time(repo: Path):
|
||
|
cmd = ["git", "for-each-ref", "--sort=-authordate", "--count=1", "--format='%(authordate:iso8601)'" ]
|
||
|
with open(repo / "info" / "web" / "last-modified", "w") as f:
|
||
|
subprocess.run(cmd, stdout=f)
|
||
|
|
||
|
def run_on_all_repos(root: Path):
|
||
|
for element in os.listdir(root):
|
||
|
full_path = root / element
|
||
|
if element.startswith("."):
|
||
|
pass # ignore hidden files
|
||
|
elif element.endswith(".git"):
|
||
|
print(f"updating idle time for {element.replace('.git','')}")
|
||
|
update_time(full_path)
|
||
|
elif os.path.isdir(root / element):
|
||
|
run_on_all_repos(root / element)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
run_on_all_repos(GIT_ROOT)
|
||
|
|