diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..92c9bb29 --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +[flake8] +exclude = + .git, + __pycache__, + build, + dist, + versioneer.py, + labpdfproc/_version.py, + doc/manual/source/conf.py +max-line-length = 115 +# Ignore some style 'errors' produced while formatting by 'black' +ignore = W503 diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..e0926f42 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,4 @@ +[settings] +line_length = 115 +multi_line_output = 3 +include_trailing_comma = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3a8f4de5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +default_language_version: + python: python3 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + exclude: '\.(rst|txt)$' + - repo: https://github.com/ambv/black + rev: 23.3.0 + hooks: + - id: black + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--profile", "black"] + - repo: https://github.com/kynan/nbstripout + rev: 0.6.1 + hooks: + - id: nbstripout + - repo: local + hooks: + - id: prevent-commit-to-main + name: Prevent Commit to Main Branch + entry: ./prevent_commit_to_main.sh + language: script + stages: [commit] diff --git a/prevent_commit_to_main.sh b/prevent_commit_to_main.sh new file mode 100755 index 00000000..5237b16a --- /dev/null +++ b/prevent_commit_to_main.sh @@ -0,0 +1,9 @@ +#!/bin/sh +##!"C:\\Program Files\\Git\\usr\\bin\\bash.exe" + +branch="$(git rev-parse --abbrev-ref HEAD)" + +if [ "$branch" = "main" ]; then +echo "You are on the main branch. Committing to the main branch is not allowed." +exit 1 +fi