From 96129c759a0f5c7f50dbc1af8467e20e311efde6 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 4 Jan 2014 13:50:49 +0000 Subject: mgagit: Attempt to write out a last-modified file for cgit. This means the Last Modified column in cgit will show the date of the last commit not the date of the last push (which can be completely unrelated, especially when doing rebases or forced pushes and fixups etc.) Note: If we stop using rsync for replication then this can be removed and replaced with a different hook on the receiving side. --- deployment/mgagit/templates/git-post-receive-hook | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'deployment/mgagit') diff --git a/deployment/mgagit/templates/git-post-receive-hook b/deployment/mgagit/templates/git-post-receive-hook index 71235254..d5bff729 100755 --- a/deployment/mgagit/templates/git-post-receive-hook +++ b/deployment/mgagit/templates/git-post-receive-hook @@ -167,4 +167,17 @@ class LinksRevision(git_multimail.Revision): git_multimail.Revision = LinksRevision if __name__ == '__main__': + # Attempt to write a last-updated file for cgit cosmetics + try: + git_dir = git_multimail.get_git_dir() + infowebdir = os.path.join(git_dir, 'info', 'web') + if not os.path.exists(infowebdir): + os.makedirs(infowebdir) + lastupdated = git_multimail.read_git_output( + ['for-each-ref', '--sort=-committerdate', "--format='%(committerdate:iso8601)'", '--count=1', 'refs/heads'], + ) + open(os.path.join(infowebdir, 'last-modified'), 'w').write(lastupdated).close() + except IOError: + pass + git_multimail.main(sys.argv[1:]) -- cgit v1.2.1