gimp3
lazarus
trunk
xry111/for-12.3
xry111/spidermonkey128
Last change
on this file since 7c8aded 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
|
Rev | Line | |
---|
[84de88e] | 1 | #!/usr/bin/env python3
|
---|
| 2 |
|
---|
| 3 | from os import getcwd
|
---|
| 4 | from subprocess import check_output, DEVNULL
|
---|
| 5 | from sys import stdin, stdout, argv
|
---|
| 6 |
|
---|
| 7 | content = 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.
|
---|
| 14 | cmd = [ 'git', 'log', '-1', '--pretty=%ad', 'FETCH_HEAD', '--', argv[1] ]
|
---|
| 15 | try:
|
---|
| 16 | date = check_output(cmd, cwd = getcwd(), stderr=DEVNULL).decode().rstrip()
|
---|
| 17 | content = content.replace('$Date$', '$Date: %s$' % date)
|
---|
| 18 | except Exception:
|
---|
| 19 | pass
|
---|
| 20 | stdout.write(content)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.