source: expand_date@ 7c95cc15

11.0 11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 7c95cc15 was 84de88e, checked in by Xi Ruoyao <xry111@…>, 3 years ago

Add mechanism for cron job $Date$ handling

  • Property mode set to 100755
File size: 728 bytes
Line 
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.