mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 03:56:54 +00:00
add check_projen_files
This commit is contained in:
parent
887db502c6
commit
d1a0d9aea1
3 changed files with 31 additions and 0 deletions
|
|
@ -53,6 +53,13 @@
|
|||
language: python
|
||||
types: [text]
|
||||
stages: [commit, push, manual]
|
||||
- id: check_projen_files
|
||||
name: check projen files
|
||||
description: checks if projen files were not updated manually.
|
||||
entry: check_projen_files
|
||||
language: python
|
||||
types: [text]
|
||||
stages: [push, manual]
|
||||
- id: pretty-format-json
|
||||
name: pretty format json
|
||||
description: sets a standard for formatting json files.
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ Checks that scripts with shebangs are executable.
|
|||
#### `check-symlinks`
|
||||
Checks for symlinks which do not point to anything.
|
||||
|
||||
#### `check-projen-files`
|
||||
Checks for projen files that were updated manually.
|
||||
|
||||
#### `check-toml`
|
||||
Attempts to load all TOML files to verify syntax.
|
||||
|
||||
|
|
|
|||
21
pre_commit_hooks/check_projen_files.py
Normal file
21
pre_commit_hooks/check_projen_files.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def main():
|
||||
projen_process = subprocess.run('yarn projen', shell=True)
|
||||
|
||||
if projen_process.returncode != 0:
|
||||
print(f'Error: "yarn projen" failed with exit status {projen_process.returncode}')
|
||||
sys.exit(projen_process.returncode)
|
||||
|
||||
git_status = subprocess.run('git diff', capture_output=True, shell=True, text=True)
|
||||
if git_status.stdout.strip():
|
||||
print("Uncommitted changes found:")
|
||||
print(git_status.stdout)
|
||||
print('Have you forgotten to run "yarn projen" and commit changes?')
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue