-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #59
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
HOOK_FILE = os.path.join(ROOTDIR, ".pre-commit-hooks.yaml") | ||
|
||
|
||
def iter_hook_names(): | ||
with open(HOOK_FILE) as fp: | ||
for line in fp: | ||
line = line.strip() | ||
if line.startswith(("name: ", "- name: ")): | ||
name = line.partition(":")[2].strip() | ||
if name.startswith("'"): | ||
yield name.strip("'") | ||
elif name.startswith('"'): | ||
yield name.strip('"') | ||
else: | ||
yield name | ||
|
||
|
||
def main(): | ||
success = True | ||
for hook_name in iter_hook_names(): | ||
if len(hook_name) > 50: | ||
print(f"ERROR: hook name too long: '{hook_name}'") | ||
success = False | ||
if not success: | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |