From 7ac69b748b2958f586e0200fa035adc032447ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sun, 12 May 2024 22:13:47 +0200 Subject: feat(roles/cgit): periodically generate age file --- roles/cgit/files/agefile-generator.sh | 16 ++++++++++++++++ roles/cgit/tasks/main.yml | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 roles/cgit/files/agefile-generator.sh diff --git a/roles/cgit/files/agefile-generator.sh b/roles/cgit/files/agefile-generator.sh new file mode 100644 index 0000000..b68a7a3 --- /dev/null +++ b/roles/cgit/files/agefile-generator.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# https://git.zx2c4.com/cgit/tree/contrib/hooks/post-receive.agefile + +set -xe + +find "${1}" -name HEAD -type f -exec dirname {} \; | while read -r GIT_DIR +do + export GIT_DIR + agefile="$(git rev-parse --git-dir)"/info/web/last-modified + + mkdir -p "$(dirname "$agefile")" + git for-each-ref \ + --sort=-authordate --count=1 \ + --format='%(authordate:iso8601)' \ + > "$agefile" +done diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml index 2fa9c97..55dd72d 100644 --- a/roles/cgit/tasks/main.yml +++ b/roles/cgit/tasks/main.yml @@ -63,13 +63,24 @@ remote_src: true loop: "{{ cgit__chroot_required_files }}" -- name: copy about-filter generator +- name: copy generators ansible.builtin.copy: - src: about-filter.sh - dest: "{{ cgit__chroot_dir }}/bin/about-filter.sh" + src: "{{ item }}" + dest: "{{ cgit__chroot_dir }}/bin/{{ item }}" owner: 0 group: 0 mode: "0755" + loop: + - about-filter.sh + - agefile-generator.sh + +- name: enable agefile generator + ansible.builtin.cron: + name: cgit agefile-generator + minute: "*/30" + job: "{{ cgit__chroot_dir }}/bin/agefile-generator.sh + {{ cgit__repositories_dir }}" + user: "{{ cgit__user }}" - name: start and enable slowcgi service ansible.builtin.service: -- cgit v1.2.3