mirror of
https://git.alemi.dev/gitshell.git
synced 2024-11-23 07:54:50 +01:00
feat: update-time shows the times, also fix
This commit is contained in:
parent
604a455b39
commit
d1993254d3
1 changed files with 7 additions and 4 deletions
11
update-time
11
update-time
|
@ -6,10 +6,13 @@ from pathlib import Path
|
||||||
|
|
||||||
GIT_ROOT = Path(os.environ.get("GIT_ROOT_DIR") or "/srv/git/")
|
GIT_ROOT = Path(os.environ.get("GIT_ROOT_DIR") or "/srv/git/")
|
||||||
|
|
||||||
def update_time(repo: Path):
|
def update_time(repo: Path) -> str:
|
||||||
cmd = ["git", "for-each-ref", "--sort=-authordate", "--count=1", "--format='%(authordate:iso8601)'" ]
|
cmd = ["git", "for-each-ref", "--sort=-authordate", "--count=1", "--format='%(authordate:iso8601)'" ]
|
||||||
|
proc = subprocess.run(cmd, cwd=repo, stdout=subprocess.PIPE)
|
||||||
|
time = proc.stdout.decode().strip()
|
||||||
with open(repo / "info" / "web" / "last-modified", "w") as f:
|
with open(repo / "info" / "web" / "last-modified", "w") as f:
|
||||||
subprocess.run(cmd, stdout=f)
|
f.write(time)
|
||||||
|
return time
|
||||||
|
|
||||||
def run_on_all_repos(root: Path):
|
def run_on_all_repos(root: Path):
|
||||||
for element in os.listdir(root):
|
for element in os.listdir(root):
|
||||||
|
@ -17,8 +20,8 @@ def run_on_all_repos(root: Path):
|
||||||
if element.startswith("."):
|
if element.startswith("."):
|
||||||
pass # ignore hidden files
|
pass # ignore hidden files
|
||||||
elif element.endswith(".git"):
|
elif element.endswith(".git"):
|
||||||
print(f"updating idle time for {element.replace('.git','')}")
|
time = update_time(full_path)
|
||||||
update_time(full_path)
|
print(f"last update for '{element.replace('.git','')}': {time}")
|
||||||
elif os.path.isdir(root / element):
|
elif os.path.isdir(root / element):
|
||||||
run_on_all_repos(root / element)
|
run_on_all_repos(root / element)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue