Skip to content
61 changes: 61 additions & 0 deletions client-data-lastmod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This script updates data/clients.json by cloning every referenced git
# repository and noting the time of the most recent commit. The new
# JSON data is saved into data/clients.json.new.

import git
import json
import sys
import tempfile
import time

try:
clients = json.load(open("data/clients.json"))
except FileNotFoundError:
print("Could not open data/clients.json; wrong working dir?")
sys.exit(1)

for client in clients["list"]:
name = client["name"]
if "url" in client:
url = client["url"]
# Remove any prior last_commit data, in case the repository can't be
# cloned this time.
if "last_commit" in client:
del client["last_commit"]
if "github.com/" in url or "gitlab.com/" in url or \
"codeberg" in url or url.startswith("https://git."):
with tempfile.TemporaryDirectory() as tempdir:
try:
print(name, "Cloning", url)
repo = git.Repo.clone_from(url, tempdir)
# committed_date is potentially newer than authored_date
committed_date = repo.commit().committed_date
committed_datetime = repo.commit().committed_datetime
print(name, committed_datetime)
client["last_commit"] = committed_date
# If the repo didn't work before but did work this time,
# remove the error notation.
if "repo_error" in client:
del client["repo_error"]
except Exception as e:
# If the repo didn't work this time, note the error.
print(name, "Error:", e)
client["repo_error"] = 1
else:
print(name, "No detected git URL for client")
else:
print(name, "No URL for client")

json.dump(clients, open("data/clients.json.new", "w"), indent="\t")

# Sample jq processing:
#
# jq -r '."list"[] | select(."last_commit")? | "\(now - .last_commit | round): \(.name)" ' < clients.json.new | sort -n
#
# We could also do this in native Python. The age of the last commit, in
# seconds, would be
#
# int(time.time() - repo.commit().committed_date)
#
# so an action could be taken based on this (removing the entry, saving
# it in a different file, giving it an additional field, etc.).
35 changes: 35 additions & 0 deletions client-data-prune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This script updates data/clients.json by removing all clients
# with last_commit older than a specified value. The new JSON data
# is saved into data/clients.json.new.

year = 365 * 86400
cutoff = 2 * year

import json
import sys
import time

try:
clients = json.load(open("data/clients.json"))
except FileNotFoundError:
print("Could not open data/clients.json; wrong working dir?")
sys.exit(1)

new_list = []
old_clients = len(clients["list"])
for client in clients["list"]:
name = client["name"]
if "last_commit" in client:
age = int(time.time() - client["last_commit"])
if age < cutoff:
new_list.append(client)
else:
print("Dropping {} (age = {})".format(name, age))
else:
# No last_commit data for this client
new_list.append(client)

print("Old: {} New: {}".format(old_clients, len(new_list)))
clients["list"] = new_list

json.dump(clients, open("data/clients.json.new", "w"), indent="\t")
4 changes: 3 additions & 1 deletion content/en/docs/client-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ Before submitting a pull request please make sure:
1. The client respects the [Let's Encrypt trademark policy](https://www.abetterinternet.org/trademarks).
1. The client is not browser-based and supports automatic renewals.
1. The client performs [routine renewals at randomized times](/docs/integration-guide#when-to-renew), or encourages that configuration.
1. Your commit adds your client to the **end** of the relevant sections (Don't forget the "acme_v2" if appropriate!).
1. Your commit adds your client to the **end** of the relevant sections.
1. Your commit updates the `lastmod` date stamp at the top of `clients.json`.

We may periodically remove listings of projects that appear to be no longer developed. If development work on a project resumes, feel free to submit a new pull request to add that project again.
Loading