source: expand_date@ eede1a3

11.0 ken/refactor-virt lazarus qt5new trunk
Last change on this file since eede1a3 was 84de88e, checked in by Xi Ruoyao <xry111@…>, 6 months ago

Add mechanism for cron job $Date$ handling

  • Property mode set to 100755
File size: 728 bytes
RevLine 
[84de88e]1#!/usr/bin/env python3
2
3from os import getcwd
4from subprocess import check_output, DEVNULL
5from sys import stdin, stdout, argv
6
7content = stdin.read()
8
9# To editors:
10# The usage of FETCH_HEAD here is very tricky. This is only intended for
11# the cron job running "git pull" periodically. Humans should NOT rely on
12# this script at all. Do NOT add "dater" filter into your .git/config.
13# For editors, just use `git log ${path}` to show the history of a file.
14cmd = [ 'git', 'log', '-1', '--pretty=%ad', 'FETCH_HEAD', '--', argv[1] ]
15try:
16 date = check_output(cmd, cwd = getcwd(), stderr=DEVNULL).decode().rstrip()
17 content = content.replace('$Date$', '$Date: %s$' % date)
18except Exception:
19 pass
20stdout.write(content)
Note: See TracBrowser for help on using the repository browser.