forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #506 from dataquest-dev/pre_commit
use checkstyle before commit
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: mvn-checkstyle | ||
verbose: true | ||
entry: python scripts/pre-commit/checkstyle.py | ||
name: Runs maven checkstyle | ||
language: python | ||
files: \.(java)$ |
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,23 @@ | ||
import sys | ||
import logging | ||
import subprocess | ||
|
||
_logger = logging.getLogger() | ||
logging.basicConfig(format='%(message)s', level=logging.DEBUG) | ||
|
||
|
||
if __name__ == '__main__': | ||
files = [x for x in sys.argv[1:] if x.lower().endswith('java')] | ||
_logger.info(f'Found [{len(files)}] files from [{len(sys.argv) - 1}] input files') | ||
|
||
cmd = "mvn checkstyle:check" | ||
|
||
try: | ||
with subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, text=True) as process: | ||
for line in process.stdout: | ||
print(line, end='') | ||
except Exception as e: | ||
_logger.critical(f'Error: {repr(e)}, ret code: {e.returncode}') | ||
|
||
# for filename in files: | ||
# pass |