Skip to content

Commit

Permalink
build: pre-push refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Jan 5, 2024
1 parent 4a824df commit 3f4392f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .githooks/pre-push.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Linux, Windows and MacOS)

# #!/bin/sh
# echo 'execute .githooks/pre-push.py' >> .githooks/hooks.log
# python3 .githooks/pre-push.py

import subprocess
Expand All @@ -28,13 +29,12 @@

def main():
local_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], universal_newlines=True).strip()
wip_prefix = "^#\d+(?:\b.*)$"
message = 'The branch {local_branch} can not be pushed as it starts with a '#' which marks it as work in progress'

wip_prefix = '^#\\d+(?:\\b.*)$'
if re.match(wip_prefix, local_branch):
print(message)
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__":
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.githooks/hooks.log
.hugo_build.lock
exampleSite/public*
exampleSite/hugo*.exe
Expand Down

0 comments on commit 3f4392f

Please sign in to comment.