refs: and we're logging...
commit5bf07ca371d85e510f7476f32afaf02166130c64
authorKyle J. McKay <mackyle@gmail.com>
Tue, 6 Sep 2016 01:05:03 +0000 (5 18:05 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 6 Sep 2016 01:05:03 +0000 (5 18:05 -0700)
tree6558a005393cce7c4b4b99489113820c32f135c1
parentcecc7971d799a96ff39bc161a67b00261391ff30
refs: and we're logging...

Log ref changes made to both push and mirror projects.

We log push changes in the pre-receive hook to guarantee that we get
them recorded before the old ref value is allowed to become unreachable
even though that means we could record some changes that were later
disallowed by the update hook.

Waiting until the post-receive hook would mean that the old ref value
could have become unreachable before we recorded it and if there's a
problem writing the log or Git fails to run the post-receive hook
because the client disconnects at just the right time, we could end up
with updates to the repository that were not logged at all.

Future changes to move away from the "-A" option of git repack will
require that we do not miss any updates.  It would be possible to log
the changes a second time in the post-receive hook to confirm which ones
actually did take place, but the same caveat applies in that we might
fail to confirm some updates that actually did take place for the
reasons already mentioned above about why the logging must be in the
pre-receive hook in the first place.

Logging takes place to UTC-timestamp-named files.  The update.sh script
has it easy in that it just appends to the "YYYYMMDD" named file located
in the reflogs subdirectory.  As only one update.sh process should ever
be running at a time for any given project.

The pre-receive script initially logs to "tmp_YYYYMMDD_HHMMSS.$$" and
after logging is finished moves that to "YYYYMMDD_HHMMSS.$$".  The gc.sh
script is responsible for coalescing the "*_HHMMSS.*" files into the
proper "YYYYMMDD" file and pruning any log files older than the
$Girocco::Config::reflogs_lifetime days config setting.

Log file entries have the form of one change per line in the format
"HHMMSS old new refname".  When the HHMMSS of a log entry is combined
with the YYYYMMDD of the log file name the UTC timestamp of the change
is recovered.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Girocco/Config.pm
Girocco/Project.pm
hooks/pre-receive
jailsetup.sh
jobd/gc.sh
jobd/update.sh
toolbox/update-all-config.sh