The Problem

The documented way to get the author of a wikipage set is to use the meta plugin as in [[!meta author="Georg Lehner" authorurl="http://jorge.at.anteris.net/"]].

There have been questions on the IkiWiki Wiki, how to set the meta author automatically. The answer is: it is not possible.

While the answer might be right, it does not address the usecase of automating Author information for a post.

IkiWiki could retrieve authorship for a page from the verson control system and put it into a template variable. The templates can be modified in a way, that this authorship information is inserted, unless the author of the page overrides it with the meta plugins author parameter.

Although this could seem to be feasable, it is not trivial either. First there are several “authors” to choose from:

  • If a page is created via the Webinterface, the author might, or might not be known. If she is known, it is a username, which looks e.g. like this one: jorge <jorge@web>.
  • If a page is created on a clone of the repository, it depends on the user to set up authorship info in the revision control system (rcs). But there arises also a second question: Is the author the user who issued the first commit or the last change. In fact, we might be interested in both informations.

Anyway, the author might be the same, but show up with different author information, depending on which clone of the repository she has been working, including the clone used by the web-server

IkiWiki itself does not provide a function to get authorship information for a file from the rcs.

Author information in RCS’

Here we collect information on how to get the authorship information out of some rcs’, in order to propose means how to implement this function.

git

The following commandline will retrieve the hash of the first commit and then print the relevant information in machine readable format (“porcelain”).

git log $(git rev-list --reverse HEAD -- filename |head -1) \
filename | grep ^Author:

which yields something like:

Author: jorge <jorge@web>

To get the last contributor (comitter) use:

git log -1 HEAD filename |grep ^Author:

CVS

The cvs log command gives information about the respective author:

cvs log -N -r1.1 filename | grep ^date:

This commandline assumes that ‘1.1’ is always the first version of filename. It prints a line similar to the following:

date: 2016-06-13 20:1:16 -0600;  author: leg;  state: Exp;

To get the last comitter use:

cvs log -N -rHEAD  filename | grep ^date

SVN

Similar to CVS you can use `svn log’. Revisions start at number 1.

svn log -r1  filename | grep ^r

yields something like:

r1 | jorge | 2016-07-15 13:10:10 -0600 (Fri, 15 Jul 2016) | 2 lines

The last comitter is obtained by:

svn log -rHEAD filename | grep ^r