========================
== Experimental Emacs ==
========================
Corwin's Emacs Blog


last-rev.pl

last-rev.pl

As returning readers will know, I produce (or try to produce) regular builds of Emacs for Windows. When things work, these produce pre-compiled binaries as an installer and unpack-and-run zip files. You can find links to the latest set for each branch in the box at the top-left each page on the site.

Today's post is about one program out from the middle of the bucket-brigade of data I have created, generally in an effort to avoid unneeded queries of the upstream (Savannah or Savannah mirrors hosted) repositories.

Without getting into the whole the architecture, Savannah sends a UDP datagram to certain IP and port, belonging to a low-cost VPS where several programs wait, crowed around the incoming port.

One of those programs is last-rev.pl.

last-rev.pl

The job of last-rev.pl is to let my CI query the most recent commit to each Emacs branch, fast and without any network interaction with Savannah (or the mirrors). Technically, the solution is very, very simple: another listener on the same port appends incoming commit data to an `emacs.jsonl', just formating as JSON and then adding to the end of the file. The jsonl file can be trimmed periodically by removing commits starting from the top, keeping each line only when the mentioned branch does not appear on any line following.

Each request to last-rev.pl, presented to the internet as CGI script, fetches last line of the file that matching all inputs. When passed the property parameter it strips the output down to just the value of the given field, otherwise it returns the whole line (which was written out as a valid JSON object).

Usage

https://test.comic.chat/last-rev.pl?project=emacs

Parameter Valid Values
project emacs
branch master (default), or emacs-31
property message, author, context, project, or revision

Example

Here are snippets from crude-ci.sh using last-rev.pl:

BASE_URI=$( printf '%s://%s/%s?project=%s&property=%s&' \
                   'https' \
                   'test.comic.chat' \
                   'last-rev.pl' \
                   'emacs' \
                   'revision' )

And then, later, to use this we have:

remote_rev=$( wget -qO - $BASE_URI'&'branch=$branch_name );

Conclusion

This has been working out pretty well for a few years now, so I thought I would put it out there and see what others thinks. I look forward to hearing your thoughts!

PS, you can often find me in #emacs on Libera.Chat if email isn't your thing.