diff --git a/help b/help index dd08080..d927420 100755 --- a/help +++ b/help @@ -6,7 +6,7 @@ echo " $ new create new repository" echo " $ mirror [name] mirror remote repository" echo " $ upstream set repository to push to a given remote" echo " $ downstream set repository to fetch from a given remote" -echo " $ sync push and pull all mirrored repositories" +echo " $ fetch-mirrors push and pull all mirrored repositories" echo " $ tree show file tree of repo at HEAD" echo " $ log show commit log of repo" echo " $ head change default branch of repository" @@ -15,5 +15,6 @@ echo " $ owner [owner] set or unset owner for repository" echo " $ group [group] set or unset group for repository" echo " $ page [page] set or unset homepage for repository" echo " $ pic [href] set or unset picture url for repository" +echo " $ update-time force update idle times for all repos" echo " $ show make repository public" echo " $ hide hide public repository" diff --git a/update-time b/update-time new file mode 100755 index 0000000..0c1f6c7 --- /dev/null +++ b/update-time @@ -0,0 +1,30 @@ +#!/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) -> str: + 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: + f.write(time) + return time + +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"): + time = update_time(full_path) + print(f"last update for '{element.replace('.git','')}': {time}") + elif os.path.isdir(root / element): + run_on_all_repos(root / element) + +if __name__ == "__main__": + run_on_all_repos(GIT_ROOT) +