On Mon, 11 Oct 2010, Tibor Simko wrote:
> * Note that the `Idle' time information printed on cgit web page is
> based on the master branch.  We may want to install a little
> post-commit hook that will update timestamp properly for any branch,
> but more on this later.

So, to solve the repo idle time information issue, please install a
post-receive hook that looks like this: (in Python)

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python

"""
This script is usable as a git repo `post-receive' hook.  It updates
`$GIT_DIR/info/web/last-modified' time-stamp file after any commit to
any branch of the repo.  Useful for cgit web interface repo idle time
information.

Tibor/2010-10-17
"""

from os import getenv, sep
from os.path import exists
from subprocess import Popen, PIPE

def update_info_web_lastmodified():
    """
    Update `$GIT_DIR/info/web/last-modified' time-stamp file after any
    commit to any branch of the repo.  Useful for cgit web interface
    repo idle time information.
    """
    # detect last-modified file location:
    outfile = getenv('GIT_DIR', '/tmp') + sep + 'info/web/last-modified'
    # detect last commit timestamp:
    process = Popen(['git', 'for-each-ref', '--format', '%(committerdate)',
                     '--sort', '-committerdate', '--count', '1'],
                    stdout=PIPE,
                    stderr=PIPE)
    out, dummy_err = process.communicate()
    # update last-modified file:
    if out and exists(outfile):
        fd_outfile = open(outfile, 'w')
        fd_outfile.write(out)
        fd_outfile.close()

if __name__ == '__main__':
    update_info_web_lastmodified()
--8<---------------cut here---------------end--------------->8---

into your {invenio,inspire} public repositories in the following way:

   $ cd ~/public/repo/cds-invenio.git
   $ mkdir info/web/
   $ touch info/web/last-modified
   $ cp tmp_above_hook.py hooks/post-receive
   $ chmod a+rx hooks/post-receive

after which the idle timestamp information should be set properly upon
your next commit.

P.S. I use Pythonic hook due to some other stuff in there, but
     alternatively you should be able to use a simpler shell version
     that would go like:

--8<---------------cut here---------------start------------->8---
#!/bin/sh
git for-each-ref --format="%(committerdate)" --sort=-committerdate --count=1 > 
$GIT_DIR/info/web/last-modified
--8<---------------cut here---------------end--------------->8---

Best regards
-- 
Tibor Simko

Reply via email to