Skip to content

Commit 0a39f37

Browse files
Cull insanely overengineered pre-push hook
1 parent 10726ad commit 0a39f37

1 file changed

Lines changed: 2 additions & 71 deletions

File tree

scripts/.githooks/pre-push

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,3 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env bash
22

3-
import subprocess
4-
import sys
5-
6-
remote = sys.argv[1]
7-
url = sys.argv[2]
8-
9-
## This hook is called with the following parameters:
10-
##
11-
## $1 -- Name of the remote to which the push is being done
12-
## $2 -- URL to which the push is being done
13-
print("Running pre-push hook...")
14-
# The stdin will receive the local ref, local oid, remote ref, and remote oid
15-
try:
16-
while True:
17-
line = input()
18-
local_ref, local_oid, remote_ref, remote_oid = line.strip().split(' ')
19-
if local_ref == "refs/heads/main" or local_ref == "refs/heads/dev":
20-
result = subprocess.run(["npm", "run", "build"], capture_output=True, text=True)
21-
if result.returncode != 0:
22-
print(result.stdout)
23-
print(result.stderr, file=sys.stderr)
24-
exit(result.returncode)
25-
else:
26-
exit(0)
27-
except EOFError:
28-
pass
29-
exit(0)
30-
31-
##!/bin/sh
32-
# The equivalent script in bash, I think
33-
## An example hook script to verify what is about to be pushed. Called by "git
34-
## push" after it has checked the remote status, but before anything has been
35-
## pushed. If this script exits with a non-zero status nothing will be pushed.
36-
##
37-
## This hook is called with the following parameters:
38-
##
39-
## $1 -- Name of the remote to which the push is being done
40-
## $2 -- URL to which the push is being done
41-
##
42-
## If pushing without using a named remote those arguments will be equal.
43-
##
44-
## Information about the commits which are being pushed is supplied as lines to
45-
## the standard input in the form:
46-
##
47-
## <local ref> <local oid> <remote ref> <remote oid>
48-
##
49-
## This sample shows how to prevent push of commits where the log message starts
50-
## with "WIP" (work in progress).
51-
#
52-
#remote="$1"
53-
#url="$2"
54-
#
55-
#while read local_ref local_oid remote_ref remote_oid; do
56-
# if test "$local_ref" = "refs/heads/main" -o "$local_ref" = "refs/heads/dev"; then
57-
# echo "got here, good"
58-
# hi=$(npm run build)
59-
# build_status=$?
60-
# echo "$build_status"
61-
# if test $build_status -ne 0; then
62-
# echo "$?"
63-
# echo >&2 "Build unsuccessful."
64-
# fi
65-
# exit 1
66-
# else
67-
# exit 1
68-
# fi
69-
#done
70-
#echo "got here, no good"
71-
#
72-
#exit 0
3+
npm run build

0 commit comments

Comments
 (0)