mirror of
https://git.alemi.dev/gitshell.git
synced 2024-11-21 23:14:53 +01:00
feat: add command to update times manually
This commit is contained in:
parent
9b7462b45f
commit
604a455b39
2 changed files with 29 additions and 1 deletions
3
help
3
help
|
@ -5,7 +5,7 @@ echo " $ ls list all repositories, marks hidden
|
||||||
echo " $ new <name> create new repository"
|
echo " $ new <name> create new repository"
|
||||||
echo " $ mirror <url> [name] mirror remote repository"
|
echo " $ mirror <url> [name] mirror remote repository"
|
||||||
echo " $ upstream <repo> <url> set repository to push to a given remote"
|
echo " $ upstream <repo> <url> set repository to push to a given remote"
|
||||||
echo " $ sync push and pull all mirrored repositories"
|
echo " $ fetch-mirrors push and pull all mirrored repositories"
|
||||||
echo " $ tree <repo> show file tree of repo at HEAD"
|
echo " $ tree <repo> show file tree of repo at HEAD"
|
||||||
echo " $ log <repo> show commit log of repo"
|
echo " $ log <repo> show commit log of repo"
|
||||||
echo " $ head <repo> <name> change default branch of repository"
|
echo " $ head <repo> <name> change default branch of repository"
|
||||||
|
@ -14,5 +14,6 @@ echo " $ owner <repo> [owner] set or unset owner for repository"
|
||||||
echo " $ group <repo> [group] set or unset group for repository"
|
echo " $ group <repo> [group] set or unset group for repository"
|
||||||
echo " $ page <repo> [page] set or unset homepage for repository"
|
echo " $ page <repo> [page] set or unset homepage for repository"
|
||||||
echo " $ pic <repo> [href] set or unset picture url for repository"
|
echo " $ pic <repo> [href] set or unset picture url for repository"
|
||||||
|
echo " $ update-time force update idle times for all repos"
|
||||||
echo " $ show <repo> make repository public"
|
echo " $ show <repo> make repository public"
|
||||||
echo " $ hide <repo> hide public repository"
|
echo " $ hide <repo> hide public repository"
|
||||||
|
|
27
update-time
Executable file
27
update-time
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/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)
|
||||||
|
|
Loading…
Reference in a new issue