mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
build: add time stamp for git hook logging
This commit is contained in:
parent
9c13f0b514
commit
82767b6557
1 changed files with 8 additions and 6 deletions
|
@ -9,12 +9,13 @@
|
||||||
# Call this script from your ".git/hooks/pre-push" file like this (supporting
|
# Call this script from your ".git/hooks/pre-push" file like this (supporting
|
||||||
# Linux, Windows and MacOS)
|
# Linux, Windows and MacOS)
|
||||||
|
|
||||||
# #!/bin/sh
|
# #!/bin/sh
|
||||||
# echo 'execute .githooks/pre-push.py' >> .githooks/hooks.log
|
# echo 'execute .githooks/pre-push.py' >> .githooks/hooks.log
|
||||||
# python3 .githooks/pre-push.py
|
# python3 .githooks/pre-push.py
|
||||||
|
|
||||||
import subprocess
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# This hook is called with the following parameters:
|
# This hook is called with the following parameters:
|
||||||
# $1 -- Name of the remote to which the push is being done
|
# $1 -- Name of the remote to which the push is being done
|
||||||
|
@ -28,13 +29,14 @@ import re
|
||||||
# an "#" (which are work in progress).
|
# an "#" (which are work in progress).
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip()
|
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip()
|
||||||
wip_prefix = '^#\\d+(?:\\b.*)$'
|
wip_prefix = '^#\\d+(?:\\b.*)$'
|
||||||
if re.match(wip_prefix, local_branch):
|
if re.match(wip_prefix, local_branch):
|
||||||
print(f'The branch {local_branch} can not be pushed as it starts with a "#" which marks it as work in progress', file=open(".githooks/hooks.log", "a"))
|
print(f'{time}: The branch {local_branch} can not be pushed as it starts with a "#" which marks it as work in progress', file=open(".githooks/hooks.log", "a"))
|
||||||
print(f'The branch {local_branch} can not be pushed as it starts with a "#" which marks it as work in progress')
|
print(f'The branch {local_branch} can not be pushed as it starts with a "#" which marks it as work in progress')
|
||||||
exit(1)
|
exit(1)
|
||||||
print(f'Pushing branch {local_branch}', file=open(".githooks/hooks.log", "a"))
|
print(f'{time}: Pushing branch {local_branch}', file=open(".githooks/hooks.log", "a"))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue