+- optionally, the review page can share the reviewers' edits (adjusted
+ verdicts and short notes) between all users of the same server, thanks to a
+ small CGI script storing them into a dedicated git repository. This part is
+ entirely optional: without it the page keeps working standalone, edits are
+ simply lost on reload as before. Three pieces are needed:
+
+ - the awk script from dev/patchbot/cgi (the server-side program).
+
+ - the storage repository, a plain git working tree which must also stay
+ outside the served directory. The CGI commits every change into it, so a
+ committer identity is required (git is the history: "git log" and "git
+ blame" tell who changed what and when, and the files are plain text, one
+ line per commit id, trivially hand-editable to fix anything):
+
+ mkdir ~/data/overlay
+ cd ~/data/overlay
+ git init
+ git config user.name patchbot
+ git config user.email patchbot@localhost
+ cd ~
+
+ Note that the example above assumes that the web server will be running
+ under the same user as the one owning the whole project, which is not
+ necessarily a great idea. A better approach consists in creating the
+ repository (and only it) under the web server's owner (e.g. "web" or
+ "nobody"). Start with the same actions as above, then:
+
+ sudo chown -R nobody ~/data/overlay
+
+ A group-shared access might also work for server that let the user set a
+ specific group (not tested). It's important to keep in mind that modern Git
+ versions are particularly picky about permissions and will even refuse to
+ read from another user's directory (and the safe.directory trick here
+ cannot work). If required, a trick consists in forcing GIT_DIR to point to
+ the .git dir, and GIT_WORK_TREE to the repo (only partially tested). E.g,
+ for local edition:
+
+ cd ~patchbot/data/overlay/
+ GIT_DIR=$PWD/.git GIT_WORK_TREE=$PWD git commit --amend
+
+ or more simply, when installed as nobody:
+
+ cd ~patchbot/data/overlay/
+ sudo -u git commit --amend
+
+ Also note that the identity really must be set in the repository's local
+ config as shown above and cannot be set globally (git config --global)
+ because CGI processes receive a minimal environment without HOME nor USER,
+ so git will not be able to read ~/.gitconfig and will fail to guess a valid
+ identity ("unable to auto-detect email address"), aborting every commit.
+
+ If only Git stops working, the file will continue to be updated but no
+ change history will be kept (a warning will be reported to the UI however).
+ This might be acceptable in some deployments and might become a deployment
+ option later if deemed useful.
+
+ - the "update.cgi" wrapper, copied from the haproxy tree into a "cgi-bin"
+ sub-directory in the served directory, next to the generated HTML pages
+ (the pages reach it with a relative URL). It's a small shell script holding
+ the local paths, to be adjusted after copying:
+
+ mkdir -p -m 711 ~/data/out/cgi-bin/
+ touch ~/data/out/cgi-bin/index.html
+ cp ~/data/in/haproxy/dev/patchbot/cgi/update.cgi ~/data/out/cgi-bin/
+ vi ~/data/out/cgi-bin/update.cgi # point it to the backend and the repo
+
+ Note that this wrapper also has a subtle role here: awk can easily die on
+ some errors (failure to write to certain files etc) without producing a
+ response. In this case the wrapper will detect it and report the error to
+ the CGI server so that the browser stays informed of server-side issues.
+
+ The web server must be able to execute CGI scripts for this file (e.g.
+ thttpd needs its "**.cgi" or "*/cgi-bin/*.cgi" pattern for it to be
+ executed and not served as text, which would expose the paths it contains).
+ This is the only web-exposed piece; the script and the repository must
+ never be.
+
+ The update-X.Y.sh script deduces the branch from its own file name and
+ passes it to post-ai.sh (-v) at generation time, which enables the syncing UI
+ on the page; a page generated without -v simply doesn't show it.
+
+ Each save is committed with a subject naming the branch and the first touched
+ commit, optionally followed with "+ N more" if more commits are updated, with
+ the full list in the commit body to ease search via git log --grep.
+