Skip to content

Commit d92fa50

Browse files
committed
Add pre-commit hook for checkcopyrights
1 parent 7dd9c2c commit d92fa50

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: checkcopyrights
5+
name: Copyright check
6+
language: system
7+
entry: mx python-checkcopyrights --assumed-modified --fix --files

mx.graalpython/mx_graalpython.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,10 +2000,20 @@ def python_checkcopyrights(args):
20002000
if mx.is_windows():
20012001
# skip, broken with crlf stuff
20022002
return
2003+
files = None
2004+
if '--files' in args:
2005+
i = args.index('--files')
2006+
files = args[i + 1:]
2007+
args = args[:i]
20032008
# we wan't to ignore lib-python/3, because that's just crazy
20042009
listfilename = tempfile.mktemp()
20052010
with open(listfilename, "w") as listfile:
2006-
mx.run(["git", "ls-tree", "-r", "HEAD", "--name-only"], out=listfile)
2011+
if files is None:
2012+
mx.run(["git", "ls-tree", "-r", "HEAD", "--name-only"], out=listfile)
2013+
else:
2014+
for x in files:
2015+
listfile.write(x)
2016+
listfile.write('\n')
20072017
with open(listfilename, "r") as listfile:
20082018
content = listfile.read()
20092019
with open(listfilename, "w") as listfile:

0 commit comments

Comments
 (0)