Skip to content

Commit 962d9e7

Browse files
authored
Add git pre-push hook. NFC (#24753)
Currently this script just runs `ruff check` to avoid pushing anything with python lint errors (since ruff is super fast this seems like a reasonable thing to do).
1 parent e27b657 commit 962d9e7

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

bootstrap.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,21 @@ def main(args):
6767
parser = argparse.ArgumentParser(description=__doc__)
6868
parser.add_argument('-v', '--verbose', action='store_true', help='verbose', default=False)
6969
parser.add_argument('-n', '--dry-run', action='store_true', help='dry run', default=False)
70-
parser.add_argument('-i', '--install-post-checkout', action='store_true', help='install post checkout script', default=False)
70+
parser.add_argument('-i', '--install-git-hooks', action='store_true', help='install emscripten git hooks', default=False)
7171
args = parser.parse_args()
7272

73-
if args.install_post_checkout:
73+
if args.install_git_hooks:
7474
if not os.path.exists(utils.path_from_root('.git')):
75-
print('--install-post-checkout requires git checkout')
75+
print('--install-git-hooks requires git checkout')
7676
return 1
7777

78-
src = utils.path_from_root('tools/maint/post-checkout')
7978
dst = utils.path_from_root('.git/hooks')
8079
if not os.path.exists(dst):
8180
os.mkdir(dst)
82-
shutil.copy(src, dst)
81+
82+
src = utils.path_from_root('tools/maint/post-checkout')
83+
for src in ('tools/maint/post-checkout', 'tools/maint/pre-push'):
84+
shutil.copy(utils.path_from_root(src), dst)
8385
return 0
8486

8587
for name, deps, cmd in actions:

tools/maint/post-checkout

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66
# The bootstrap script itself is smart enough to basically do nothing unless
77
# one of the relevant files was updated (e.g. package.json).
8+
#
9+
# This script can be installed using `./boostrap -i`.
810

911
# Test for the existence of the bootstrap script itself to handle branches
1012
# that predate its existence.

tools/maint/pre-push

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
#
3+
# Git pre-push script that runs some quick/simple tests.
4+
#
5+
# This script can be installed using `./boostrap -i`.
6+
7+
exec ruff check -q

0 commit comments

Comments
 (0)