From e7a86828d98eaa7fdf43138d0a9e3f9c9e8cc0a5 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 28 May 2022 18:33:28 -0700 Subject: fix(cgit): generate a proper list of repositories The logic was previously incorrect. If a repository becomes hidden in gerrit, it will not be removed from the list. Instead, we create a temporary file which we use to dump the new list and then move it over the current list. Change-Id: I990588ac98ad4024ba144c4c76ad7e4ae27202bc Reviewed-on: https://cl.fcuny.net/c/world/+/121 Reviewed-by: Franck Cuny --- modules/services/cgit/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/services/cgit/default.nix b/modules/services/cgit/default.nix index 87cc72c..0ac6a58 100644 --- a/modules/services/cgit/default.nix +++ b/modules/services/cgit/default.nix @@ -55,11 +55,13 @@ in { serviceConfig.Type = "oneshot"; script = '' mkdir -p /var/lib/cgit/cache + tmplist=$(mktemp) # as per https://gerrit-review.googlesource.com/Documentation/rest-api.html#output we need to remove `)]}' from the response repos=$(${pkgs.curl}/bin/curl -s -H "Content-Type: application/json" "https://cl.fcuny.net/projects/?state=ACTIVE"|sed "s/^)]}'//"|${pkgs.jq}/bin/jq -r 'to_entries | .[] | .value | .id') for repo in ''${repos}; do - grep "/var/lib/gerrit/git/''${repo}.git" /var/lib/cgit/cache/projects.list || echo "/var/lib/gerrit/git/''${repo}.git" >> /var/lib/cgit/cache/projects.list + echo "/var/lib/gerrit/git/''${repo}.git" >> $tmplist done + mv $tmplist /var/lib/cgit/cache/projects.list ''; }; }; -- cgit 1.4.1