mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-01-23 05:52:14 +08:00
Add mechanism for cron job $Date$ handling
This commit is contained in:
parent
17c9da822a
commit
84de88e1f4
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.xml filter=dater
|
20
expand_date
Executable file
20
expand_date
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from os import getcwd
|
||||
from subprocess import check_output, DEVNULL
|
||||
from sys import stdin, stdout, argv
|
||||
|
||||
content = stdin.read()
|
||||
|
||||
# To editors:
|
||||
# The usage of FETCH_HEAD here is very tricky. This is only intended for
|
||||
# the cron job running "git pull" periodically. Humans should NOT rely on
|
||||
# this script at all. Do NOT add "dater" filter into your .git/config.
|
||||
# For editors, just use `git log ${path}` to show the history of a file.
|
||||
cmd = [ 'git', 'log', '-1', '--pretty=%ad', 'FETCH_HEAD', '--', argv[1] ]
|
||||
try:
|
||||
date = check_output(cmd, cwd = getcwd(), stderr=DEVNULL).decode().rstrip()
|
||||
content = content.replace('$Date$', '$Date: %s$' % date)
|
||||
except Exception:
|
||||
pass
|
||||
stdout.write(content)
|
Loading…
Reference in New Issue
Block a user