mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
Merge branch '#0'
This commit is contained in:
commit
1a1f49ea59
2 changed files with 42 additions and 0 deletions
41
.githooks/pre-push.py
Normal file
41
.githooks/pre-push.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# This script avoids to push branches starting with a "#". This is the way
|
||||
# how I store ticket related feature branches that are work in progress.
|
||||
|
||||
# Once a feature branch is finished, it will be rebased to mains HEAD,
|
||||
# its commits squashed, merged into main and the branch deleted afterwards.
|
||||
|
||||
# Call this script from your ".git/hooks/pre-push" file like this (supporting
|
||||
# Linux, Windows and MacOS)
|
||||
|
||||
# #!/bin/sh
|
||||
# echo 'execute .githooks/pre-push.py' >> .githooks/hooks.log
|
||||
# python3 .githooks/pre-push.py
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
# This hook is called with the following parameters:
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
# If pushing without using a named remote, those arguments will be equal.
|
||||
|
||||
# Information about the commits being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
# <local ref> <local sha1> <remote ref> <remote sha1>
|
||||
# This hook prevents the push of commits that belong to branches starting with
|
||||
# an "#" (whiwork in progress).
|
||||
|
||||
def main():
|
||||
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip()
|
||||
wip_prefix = '^#\\d+(?:\\b.*)$'
|
||||
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'The branch {local_branch} can not be pushed as it starts with a "#" which marks it as work in progress')
|
||||
exit(1)
|
||||
print(f'Pushing branch {local_branch}', file=open(".githooks/hooks.log", "a"))
|
||||
exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.DS_Store
|
||||
.githooks/hooks.log
|
||||
.hugo_build.lock
|
||||
exampleSite/public*
|
||||
exampleSite/hugo*.exe
|
||||
|
|
Loading…
Reference in a new issue