From df9615bac55ac6f1c3f516b66279ac0007175030 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 19 Mar 2020 15:00:14 +0100 Subject: Adding upstream version 0.13.1. Signed-off-by: Daniel Baumann --- .coveragerc | 2 + .flake8 | 11 + .github/ISSUE_TEMPLATE/issue-template.md | 22 + .github/workflows/checks.yml | 113 + .gitignore | 68 + .pre-commit-hooks.yaml | 5 + .pylintrc | 48 + CHANGELOG.md | 271 ++ CONTRIBUTING.md | 6 + Dockerfile | 15 + Dockerfile.dev | 17 + LICENSE | 22 + MANIFEST.in | 7 + README.md | 21 + Vagrantfile | 47 + doc-requirements.txt | 1 + docs/configuration.md | 432 +++ docs/contrib_rules.md | 67 + docs/contributing.md | 132 + docs/demos/asciicinema.json | 3798 ++++++++++++++++++++ docs/demos/scenario.txt | 75 + docs/extra.css | 4 + docs/images/RuleViolation.png | Bin 0 -> 27806 bytes docs/images/RuleViolations.graffle | Bin 0 -> 3291 bytes docs/index.md | 351 ++ docs/rules.md | 243 ++ docs/user_defined_rules.md | 312 ++ examples/commit-message-1 | 5 + examples/commit-message-10 | 6 + examples/commit-message-2 | 5 + examples/commit-message-3 | 3 + examples/commit-message-4 | 3 + examples/commit-message-5 | 1 + examples/commit-message-6 | 1 + examples/commit-message-7 | 4 + examples/commit-message-8 | 6 + examples/commit-message-9 | 7 + examples/gitlint | 58 + examples/my_commit_rules.py | 87 + examples/my_line_rules.py | 45 + gitlint/__init__.py | 1 + gitlint/cache.py | 57 + gitlint/cli.py | 338 ++ gitlint/config.py | 482 +++ gitlint/contrib/__init__.py | 0 gitlint/contrib/rules/__init__.py | 0 gitlint/contrib/rules/conventional_commit.py | 39 + gitlint/contrib/rules/signedoff_by.py | 18 + gitlint/display.py | 46 + gitlint/files/commit-msg | 81 + gitlint/files/gitlint | 106 + gitlint/git.py | 395 ++ gitlint/hooks.py | 62 + gitlint/lint.py | 108 + gitlint/options.py | 122 + gitlint/rule_finder.py | 137 + gitlint/rules.py | 363 ++ gitlint/shell.py | 76 + gitlint/tests/__init__.py | 0 gitlint/tests/base.py | 169 + gitlint/tests/cli/test_cli.py | 541 +++ gitlint/tests/cli/test_cli_hooks.py | 96 + gitlint/tests/config/test_config.py | 263 ++ gitlint/tests/config/test_config_builder.py | 203 ++ gitlint/tests/config/test_config_precedence.py | 100 + gitlint/tests/config/test_rule_collection.py | 64 + gitlint/tests/contrib/__init__.py | 0 gitlint/tests/contrib/test_contrib_rules.py | 72 + gitlint/tests/contrib/test_conventional_commit.py | 47 + gitlint/tests/contrib/test_signedoff_by.py | 32 + gitlint/tests/expected/test_cli/test_contrib_1 | 3 + gitlint/tests/expected/test_cli/test_debug_1 | 102 + .../tests/expected/test_cli/test_input_stream_1 | 3 + .../expected/test_cli/test_input_stream_debug_1 | 3 + .../expected/test_cli/test_input_stream_debug_2 | 71 + .../expected/test_cli/test_lint_multiple_commits_1 | 8 + .../test_cli/test_lint_multiple_commits_config_1 | 6 + .../test_cli/test_lint_staged_msg_filename_1 | 2 + .../test_cli/test_lint_staged_msg_filename_2 | 70 + .../expected/test_cli/test_lint_staged_stdin_1 | 3 + .../expected/test_cli/test_lint_staged_stdin_2 | 72 + gitlint/tests/git/test_git.py | 115 + gitlint/tests/git/test_git_commit.py | 535 +++ gitlint/tests/git/test_git_context.py | 89 + gitlint/tests/rules/__init__.py | 0 gitlint/tests/rules/test_body_rules.py | 180 + gitlint/tests/rules/test_configuration_rules.py | 71 + gitlint/tests/rules/test_meta_rules.py | 50 + gitlint/tests/rules/test_rules.py | 18 + gitlint/tests/rules/test_title_rules.py | 154 + gitlint/tests/rules/test_user_rules.py | 223 ++ gitlint/tests/samples/commit_message/fixup | 1 + gitlint/tests/samples/commit_message/merge | 3 + gitlint/tests/samples/commit_message/revert | 3 + gitlint/tests/samples/commit_message/sample1 | 14 + gitlint/tests/samples/commit_message/sample2 | 1 + gitlint/tests/samples/commit_message/sample3 | 6 + gitlint/tests/samples/commit_message/sample4 | 7 + gitlint/tests/samples/commit_message/sample5 | 7 + gitlint/tests/samples/commit_message/squash | 3 + gitlint/tests/samples/config/gitlintconfig | 15 + gitlint/tests/samples/config/invalid-option-value | 11 + gitlint/tests/samples/config/no-sections | 1 + .../samples/config/nonexisting-general-option | 13 + gitlint/tests/samples/config/nonexisting-option | 11 + gitlint/tests/samples/config/nonexisting-rule | 11 + gitlint/tests/samples/user_rules/bogus-file.txt | 2 + .../user_rules/import_exception/invalid_python.py | 3 + .../user_rules/incorrect_linerule/my_line_rule.py | 10 + .../tests/samples/user_rules/my_commit_rules.foo | 16 + .../tests/samples/user_rules/my_commit_rules.py | 26 + .../samples/user_rules/parent_package/__init__.py | 13 + .../user_rules/parent_package/my_commit_rules.py | 12 + gitlint/tests/test_cache.py | 57 + gitlint/tests/test_display.py | 74 + gitlint/tests/test_hooks.py | 136 + gitlint/tests/test_lint.py | 197 + gitlint/tests/test_options.py | 179 + gitlint/tests/test_utils.py | 78 + gitlint/utils.py | 105 + mkdocs.yml | 17 + qa/__init__.py | 0 qa/base.py | 178 + qa/expected/test_commits/test_ignore_commits_1 | 11 + qa/expected/test_commits/test_lint_head_1 | 8 + .../test_commits/test_lint_staged_msg_filename_1 | 73 + qa/expected/test_commits/test_lint_staged_stdin_1 | 75 + qa/expected/test_commits/test_violations_1 | 7 + qa/expected/test_config/test_config_from_file_1 | 5 + .../test_config/test_config_from_file_debug_1 | 77 + qa/expected/test_config/test_set_rule_option_1 | 3 + qa/expected/test_config/test_verbosity_1 | 3 + qa/expected/test_config/test_verbosity_2 | 3 + qa/expected/test_contrib/test_contrib_rules_1 | 4 + .../test_contrib/test_contrib_rules_with_config_1 | 4 + qa/expected/test_gitlint/test_msg_filename_1 | 3 + .../test_gitlint/test_msg_filename_no_tty_1 | 3 + qa/expected/test_gitlint/test_violations_1 | 3 + qa/expected/test_stdin/test_stdin_file_1 | 3 + qa/expected/test_stdin/test_stdin_pipe_1 | 3 + qa/expected/test_stdin/test_stdin_pipe_empty_1 | 3 + .../test_user_defined_rules_examples_1 | 5 + .../test_user_defined_rules_examples_with_config_1 | 6 + .../test_user_defined_rules_extra_1 | 5 + qa/requirements.txt | 4 + qa/samples/config/contrib-enabled | 0 qa/samples/config/gitlintconfig | 13 + qa/samples/config/ignore-release-commits | 7 + qa/samples/user_rules/extra/extra_rules.py | 29 + .../user_rules/incorrect_linerule/my_line_rule.py | 8 + qa/shell.py | 90 + qa/test_commits.py | 161 + qa/test_config.py | 67 + qa/test_contrib.py | 26 + qa/test_gitlint.py | 171 + qa/test_hooks.py | 153 + qa/test_stdin.py | 56 + qa/test_user_defined.py | 38 + qa/utils.py | 99 + requirements.txt | 5 + run_tests.sh | 539 +++ setup.cfg | 2 + setup.py | 105 + test-requirements.txt | 10 + tools/create-test-repo.sh | 35 + tools/windows/create-test-repo.bat | 35 + tools/windows/run_tests.bat | 15 + 167 files changed, 15302 insertions(+) create mode 100644 .coveragerc create mode 100644 .flake8 create mode 100644 .github/ISSUE_TEMPLATE/issue-template.md create mode 100644 .github/workflows/checks.yml create mode 100644 .gitignore create mode 100644 .pre-commit-hooks.yaml create mode 100644 .pylintrc create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 Dockerfile.dev create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 Vagrantfile create mode 100644 doc-requirements.txt create mode 100644 docs/configuration.md create mode 100644 docs/contrib_rules.md create mode 100644 docs/contributing.md create mode 100644 docs/demos/asciicinema.json create mode 100644 docs/demos/scenario.txt create mode 100644 docs/extra.css create mode 100644 docs/images/RuleViolation.png create mode 100644 docs/images/RuleViolations.graffle create mode 100644 docs/index.md create mode 100644 docs/rules.md create mode 100644 docs/user_defined_rules.md create mode 100644 examples/commit-message-1 create mode 100644 examples/commit-message-10 create mode 100644 examples/commit-message-2 create mode 100644 examples/commit-message-3 create mode 100644 examples/commit-message-4 create mode 100644 examples/commit-message-5 create mode 100644 examples/commit-message-6 create mode 100644 examples/commit-message-7 create mode 100644 examples/commit-message-8 create mode 100644 examples/commit-message-9 create mode 100644 examples/gitlint create mode 100644 examples/my_commit_rules.py create mode 100644 examples/my_line_rules.py create mode 100644 gitlint/__init__.py create mode 100644 gitlint/cache.py create mode 100644 gitlint/cli.py create mode 100644 gitlint/config.py create mode 100644 gitlint/contrib/__init__.py create mode 100644 gitlint/contrib/rules/__init__.py create mode 100644 gitlint/contrib/rules/conventional_commit.py create mode 100644 gitlint/contrib/rules/signedoff_by.py create mode 100644 gitlint/display.py create mode 100644 gitlint/files/commit-msg create mode 100644 gitlint/files/gitlint create mode 100644 gitlint/git.py create mode 100644 gitlint/hooks.py create mode 100644 gitlint/lint.py create mode 100644 gitlint/options.py create mode 100644 gitlint/rule_finder.py create mode 100644 gitlint/rules.py create mode 100644 gitlint/shell.py create mode 100644 gitlint/tests/__init__.py create mode 100644 gitlint/tests/base.py create mode 100644 gitlint/tests/cli/test_cli.py create mode 100644 gitlint/tests/cli/test_cli_hooks.py create mode 100644 gitlint/tests/config/test_config.py create mode 100644 gitlint/tests/config/test_config_builder.py create mode 100644 gitlint/tests/config/test_config_precedence.py create mode 100644 gitlint/tests/config/test_rule_collection.py create mode 100644 gitlint/tests/contrib/__init__.py create mode 100644 gitlint/tests/contrib/test_contrib_rules.py create mode 100644 gitlint/tests/contrib/test_conventional_commit.py create mode 100644 gitlint/tests/contrib/test_signedoff_by.py create mode 100644 gitlint/tests/expected/test_cli/test_contrib_1 create mode 100644 gitlint/tests/expected/test_cli/test_debug_1 create mode 100644 gitlint/tests/expected/test_cli/test_input_stream_1 create mode 100644 gitlint/tests/expected/test_cli/test_input_stream_debug_1 create mode 100644 gitlint/tests/expected/test_cli/test_input_stream_debug_2 create mode 100644 gitlint/tests/expected/test_cli/test_lint_multiple_commits_1 create mode 100644 gitlint/tests/expected/test_cli/test_lint_multiple_commits_config_1 create mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_msg_filename_1 create mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_msg_filename_2 create mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_stdin_1 create mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_stdin_2 create mode 100644 gitlint/tests/git/test_git.py create mode 100644 gitlint/tests/git/test_git_commit.py create mode 100644 gitlint/tests/git/test_git_context.py create mode 100644 gitlint/tests/rules/__init__.py create mode 100644 gitlint/tests/rules/test_body_rules.py create mode 100644 gitlint/tests/rules/test_configuration_rules.py create mode 100644 gitlint/tests/rules/test_meta_rules.py create mode 100644 gitlint/tests/rules/test_rules.py create mode 100644 gitlint/tests/rules/test_title_rules.py create mode 100644 gitlint/tests/rules/test_user_rules.py create mode 100644 gitlint/tests/samples/commit_message/fixup create mode 100644 gitlint/tests/samples/commit_message/merge create mode 100644 gitlint/tests/samples/commit_message/revert create mode 100644 gitlint/tests/samples/commit_message/sample1 create mode 100644 gitlint/tests/samples/commit_message/sample2 create mode 100644 gitlint/tests/samples/commit_message/sample3 create mode 100644 gitlint/tests/samples/commit_message/sample4 create mode 100644 gitlint/tests/samples/commit_message/sample5 create mode 100644 gitlint/tests/samples/commit_message/squash create mode 100644 gitlint/tests/samples/config/gitlintconfig create mode 100644 gitlint/tests/samples/config/invalid-option-value create mode 100644 gitlint/tests/samples/config/no-sections create mode 100644 gitlint/tests/samples/config/nonexisting-general-option create mode 100644 gitlint/tests/samples/config/nonexisting-option create mode 100644 gitlint/tests/samples/config/nonexisting-rule create mode 100644 gitlint/tests/samples/user_rules/bogus-file.txt create mode 100644 gitlint/tests/samples/user_rules/import_exception/invalid_python.py create mode 100644 gitlint/tests/samples/user_rules/incorrect_linerule/my_line_rule.py create mode 100644 gitlint/tests/samples/user_rules/my_commit_rules.foo create mode 100644 gitlint/tests/samples/user_rules/my_commit_rules.py create mode 100644 gitlint/tests/samples/user_rules/parent_package/__init__.py create mode 100644 gitlint/tests/samples/user_rules/parent_package/my_commit_rules.py create mode 100644 gitlint/tests/test_cache.py create mode 100644 gitlint/tests/test_display.py create mode 100644 gitlint/tests/test_hooks.py create mode 100644 gitlint/tests/test_lint.py create mode 100644 gitlint/tests/test_options.py create mode 100644 gitlint/tests/test_utils.py create mode 100644 gitlint/utils.py create mode 100644 mkdocs.yml create mode 100644 qa/__init__.py create mode 100644 qa/base.py create mode 100644 qa/expected/test_commits/test_ignore_commits_1 create mode 100644 qa/expected/test_commits/test_lint_head_1 create mode 100644 qa/expected/test_commits/test_lint_staged_msg_filename_1 create mode 100644 qa/expected/test_commits/test_lint_staged_stdin_1 create mode 100644 qa/expected/test_commits/test_violations_1 create mode 100644 qa/expected/test_config/test_config_from_file_1 create mode 100644 qa/expected/test_config/test_config_from_file_debug_1 create mode 100644 qa/expected/test_config/test_set_rule_option_1 create mode 100644 qa/expected/test_config/test_verbosity_1 create mode 100644 qa/expected/test_config/test_verbosity_2 create mode 100644 qa/expected/test_contrib/test_contrib_rules_1 create mode 100644 qa/expected/test_contrib/test_contrib_rules_with_config_1 create mode 100644 qa/expected/test_gitlint/test_msg_filename_1 create mode 100644 qa/expected/test_gitlint/test_msg_filename_no_tty_1 create mode 100644 qa/expected/test_gitlint/test_violations_1 create mode 100644 qa/expected/test_stdin/test_stdin_file_1 create mode 100644 qa/expected/test_stdin/test_stdin_pipe_1 create mode 100644 qa/expected/test_stdin/test_stdin_pipe_empty_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_examples_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_examples_with_config_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_extra_1 create mode 100644 qa/requirements.txt create mode 100644 qa/samples/config/contrib-enabled create mode 100644 qa/samples/config/gitlintconfig create mode 100644 qa/samples/config/ignore-release-commits create mode 100644 qa/samples/user_rules/extra/extra_rules.py create mode 100644 qa/samples/user_rules/incorrect_linerule/my_line_rule.py create mode 100644 qa/shell.py create mode 100644 qa/test_commits.py create mode 100644 qa/test_config.py create mode 100644 qa/test_contrib.py create mode 100644 qa/test_gitlint.py create mode 100644 qa/test_hooks.py create mode 100644 qa/test_stdin.py create mode 100644 qa/test_user_defined.py create mode 100644 qa/utils.py create mode 100644 requirements.txt create mode 100755 run_tests.sh create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 test-requirements.txt create mode 100755 tools/create-test-repo.sh create mode 100644 tools/windows/create-test-repo.bat create mode 100644 tools/windows/run_tests.bat diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..a2e4c8f --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit=*dist-packages*,*site-packages*,gitlint/tests/*,.venv/*,*virtualenv* \ No newline at end of file diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..df7800e --- /dev/null +++ b/.flake8 @@ -0,0 +1,11 @@ +[flake8] +# H307: like imports should be grouped together +# H405: multi line docstring summary not separated with an empty line +# H803: git title must end with a period +# H904: Wrap long lines in parentheses instead of a backslash +# H802: git commit title should be under 50 chars +# H701: empty localization string +extend-ignore = H307,H405,H803,H904,H802,H701 +# exclude settings files and virtualenvs +exclude = *settings.py,*.venv/*.py +max-line-length = 120 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/issue-template.md new file mode 100644 index 0000000..c178614 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-template.md @@ -0,0 +1,22 @@ +--- +name: Issue template +about: Bug reports, feature requests +title: '' +labels: '' +assignees: '' + +--- + + + +Enter your issue details here diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..348fb47 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,113 @@ +name: Tests and Checks + +on: [push] + +jobs: + checks: + runs-on: "ubuntu-latest" + strategy: + matrix: + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + os: ["macos-latest", "ubuntu-latest"] + steps: + - uses: actions/checkout@v2 + + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install requirements + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r test-requirements.txt + + - name: Unit Tests + run: ./run_tests.sh + + # Coveralls integration doesn't properly work at this point, also see below + # - name: Coveralls + # env: + # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + # run: coveralls + + - name: Integration Tests + run: ./run_tests.sh -i + + - name: Integration Tests (GITLINT_USE_SH_LIB=0) + env: + GITLINT_USE_SH_LIB: 0 + run: ./run_tests.sh -i + + - name: PEP8 + run: ./run_tests.sh -p + + - name: PyLint + run: ./run_tests.sh -l + + - name: Build tests + run: ./run_tests.sh --build + + # Coveralls GH Action currently doesn't support current non-LCOV reporting format + # For now, still using Travis for unit test coverage reporting + # https://github.com/coverallsapp/github-action/issues/30 + # - name: Coveralls + # uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Gitlint check + run: ./run_tests.sh -g + + windows-checks: + runs-on: windows-latest + strategy: + matrix: + python-version: [2.7, 3.5] + steps: + - uses: actions/checkout@v2 + + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: "Upgrade pip on Python 3" + if: matrix.python-version == '3.5' + run: python -m pip install --upgrade pip + + - name: Install requirements + run: | + pip install -r requirements.txt + pip install -r test-requirements.txt + + - name: gitlint --version + run: gitlint --version + + - name: Tests (sanity) + run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py::CLITests::test_lint" + + - name: Tests (ignore test_cli.py) + run: pytest --ignore gitlint\tests\cli\test_cli.py -rw -s gitlint + + - name: Tests (test_cli.py only - continue-on-error:true) + run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py" + continue-on-error: true # Known to fail at this point + + - name: Tests (all - continue-on-error:true) + run: tools\windows\run_tests.bat + continue-on-error: true # Known to fail at this point + + - name: Integration tests (continue-on-error:true) + run: pytest -rw -s qa + continue-on-error: true # Known to fail at this point + + - name: PEP8 + run: flake8 gitlint qa examples + + - name: PyLint + run: pylint gitlint qa --rcfile=".pylintrc" -r n + + - name: Gitlint check + run: gitlint --debug diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c350158 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +.pytest_cache + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +.venv* +virtualenv + +# Vagrant +.vagrant + + +# mkdocs +site/ diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..5b3d51a --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: gitlint + name: gitlint + language: python + entry: gitlint --staged --msg-filename + stages: [commit-msg] diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..dc54455 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,48 @@ +# The format of this file isn't really documented; just use --generate-rcfile +[MASTER] + +[Messages Control] +# C0111: Don't require docstrings on every method +# W0511: TODOs in code comments are fine. +# W0142: *args and **kwargs are fine. +# W0223: abstract methods don't need to be overwritten (i.e. when overwriting a Django REST serializer) +# W0622: Redefining id is fine. +# R0901: Too many ancestors (i.e. when subclassing test classes) +# R0801: Similar lines in files +# I0011: Informational: locally disabled pylint +# I0013: Informational: Ignoring entire file +disable=bad-option-value,C0111,W0511,W0142,W0622,W0223,W0212,R0901,R0801,I0011,I0013,anomalous-backslash-in-string,useless-object-inheritance,unnecessary-pass + +[Format] +max-line-length=120 + +[Basic] +# Variable names can be 1 to 31 characters long, with lowercase and underscores +variable-rgx=[a-z_][a-z0-9_]{0,30}$ + +# Argument names can be 2 to 31 characters long, with lowercase and underscores +argument-rgx=[a-z_][a-z0-9_]{1,30}$ + +# Method names should be at least 3 characters long +# and be lower-cased with underscores +method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$ + +# Allow 'id' as variable name everywhere +good-names=id,c,_ + +bad-names=__author__ + +# Ignore all variables that start with an underscore (e.g. unused _request variable in a view) +dummy-variables-rgx=_ + +[Design] +max-public-methods=100 +min-public-methods=0 +# Maximum number of attributes of a class +max-attributes=15 +max-args=10 +max-locals=20 + +[Typecheck] +# Allow the use of the Django 'objects' members +generated-members=sh.git diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0a3991d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,271 @@ +# Changelog # + +## v0.13.1 (2020-02-26) + +- Patch to enable `--staged` flag for pre-commit. +- Minor doc updates ([#109](https://github.com/jorisroovers/gitlint/issues/109)) + +## v0.13.0 (2020-02-25) + +- **Behavior Change**: Revert Commits are now recognized and ignored by default ([#99](https://github.com/jorisroovers/gitlint/issues/99)) +- ```--staged``` flag: gitlint can now detect meta-data (such as author details, changed files, etc) of staged/pre-commits. Useful when you use [gitlint's commit-msg hook](https://jorisroovers.github.io/gitlint/#using-gitlint-as-a-commit-msg-hook) or [precommit](https://jorisroovers.github.io/gitlint/#using-gitlint-through-pre-commit) ([#105](https://github.com/jorisroovers/gitlint/issues/105)) +- New branch properties on ```GitCommit``` and ```GitContext```, useful when writing your own user-defined rules: ```commit.branches``` and ```commit.context.current_branch``` ([#108](https://github.com/jorisroovers/gitlint/issues/108)) +- Python 3.8 support +- Python 3.4 no longer supported. Python 3.4 has [reached EOL](https://www.python.org/dev/peps/pep-0429/#id4) and an increasing + of gitlint's dependencies have dropped support which makes it hard to maintain. +- Improved Windows support: better unicode handling. [Issues remain](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows) but the basic functionality works. +- Bugfixes: + - Gitlint no longer crashes when acting on empty repositories (this only occurred in specific circumstances). + - Changed files are now better detected in repos that only have a root commit +- Improved performance and memory (gitlint now caches git properties) +- Improved `--debug` output +- Improved documentation +- Under-the-hood: dependencies updated, unit and integration test improvements, migrated from TravisCI to Github Actions. + +## v0.12.0 (2019-07-15) ## + +Contributors: +Special thanks to all contributors for this release, in particular [@rogalksi](https://github.com/rogalski) and [@byrney](https://github.com/byrney). + +- [Contrib Rules](http://jorisroovers.github.io/gitlint/contrib_rules): community-contributed rules that are disabled + by default, but can be enabled through configuration. Contrib rules are meant to augment default gitlint behavior by + providing users with rules for common use-cases without forcing these rules on all gitlint users. + - **New Contrib Rule**: ```contrib-title-conventional-commits``` enforces the [Conventional Commits](https://www.conventionalcommits.org) spec. Details in our [documentation](http://jorisroovers.github.io/gitlint/contrib_rules/#ct1-contrib-title-conventional-commits). + - **New Contrib Rule**: ```cc1-contrib-requires-signed-off-by``` ensures that all commit messages contain a ```Sign-Off-By``` line. Details in our [documentation](http://jorisroovers.github.io/gitlint/contrib_rules/#cc1-contrib-requires-signed-off-by). + - If you're interested in adding new Contrib rules to gitlint, please start by reading the + [Contributing](http://jorisroovers.github.io/gitlint/contributing/) page. Thanks for considering! +- *Experimental (!)* Windows support: Basic functionality is working, but there are still caveats. For more details, please refer to [#20](https://github.com/jorisroovers/gitlint/issues/20) and the [open issues related to Windows](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows). +- Python 3.3 no longer supported. Python 3.4 is likely to follow in a future release as it has [reached EOL](https://www.python.org/dev/peps/pep-0429/#id4) as well. +- PyPy 3.5 support +- Support for ```--ignore-stdin``` command-line flag to ignore any text send via stdin. ([#56](https://github.com/jorisroovers/gitlint/issues/56), [#89](https://github.com/jorisroovers/gitlint/issues/89)) +- Bugfixes: + - [#68: Can't use install-hooks in with git worktree](https://github.com/jorisroovers/gitlint/issues/68) + - [#59: gitlint failed with configured commentchar](https://github.com/jorisroovers/gitlint/issues/59) +- Under-the-hood: dependencies updated, experimental Dockerfile, github issue template. + +## v0.11.0 (2019-03-13) ## + +- Python 3.7 support +- Python 2.6 no longer supported +- Various dependency updates and under the hood fixes (see [#76](https://github.com/jorisroovers/gitlint/pull/76) for details). + +Special thanks to @pbregener for his contributions related to python 3.7 support and test fixes. + +## v0.10.0 (2018-04-15) ## +The 0.10.0 release adds the ability to ignore commits based on their contents, +support for [pre-commit](https://pre-commit.com/), and important fix for running gitlint in CI environments +(such as Jenkins, Gitlab, etc). + +Special thanks to [asottile](https://github.com/asottile), [bdrung](https://github.com/bdrung), [pbregener](https://github.com/pbregener), [torwald-sergesson](https://github.com/torwald-sergesson), [RykHawthorn](https://github.com/RykHawthorn), [SteffenKockel](https://github.com/SteffenKockel) and [tommyip](https://github.com/tommyip) for their contributions. + +**Since it's becoming increasingly hard to support Python 2.6 and 3.3, we'd like to encourage our users to upgrade their +python version to 2.7 or 3.3+. Future versions of gitlint are likely to drop support for Python 2.6 and 3.3.** + +Full Changelog: + +- **New Rule**: ```ignore-by-title``` allows users to +[ignore certain commits](http://jorisroovers.github.io/gitlint/#ignoring-commits) by matching a regex against +a commit message title. ([#54](https://github.com/jorisroovers/gitlint/issues/54), [#57](https://github.com/jorisroovers/gitlint/issues/57)). +- **New Rule**: ```ignore-by-body``` allows users to +[ignore certain commits](http://jorisroovers.github.io/gitlint/#ignoring-commits) by matching a regex against +a line in a commit message body. +- Gitlint now supports [pre-commit.com](https://pre-commit.com). +[Details in our documentation](http://jorisroovers.github.io/gitlint/#using-gitlint-through-pre-commit) +([#62](https://github.com/jorisroovers/gitlint/issues/62)). +- Gitlint now has a ```--msg-filename``` commandline flag that allows you to specify the commit message to lint via + a file ([#39](https://github.com/jorisroovers/gitlint/issues/39)). +- Gitlint will now be silent by default when a specified commit range is empty ([#46](https://github.com/jorisroovers/gitlint/issues/46)). +- Gitlint can now be installed on MacOS by brew via the [homebrew-devops](https://github.com/rockyluke/homebrew-devops) tap. To get the latest version of gitlint, always use pip for installation. +- If all goes well, +[gitlint will also be available as a package in the Ubuntu 18.04 repositories](https://launchpad.net/ubuntu/+source/gitlint). +- Bugfixes: + - We fixed a nasty and recurring issue with running gitlint in CI. Hopefully that's the end of it :-) ([#40](https://github.com/jorisroovers/gitlint/issues/40)). + - Fix for custom git comment characters ([#48](https://github.com/jorisroovers/gitlint/issues/48)). + +## v0.9.0 (2017-12-03) ## +The 0.9.0 release adds a new default ```author-valid-email``` rule, important bugfixes and special case handling. +Special thanks to [joshholl](https://github.com/joshholl), [ron8mcr](https://github.com/ron8mcr), +[omarkohl](https://github.com/omarkohl), [domo141](https://github.com/domo141), [nud](https://github.com/nud) +and [AlexMooney](https://github.com/AlexMooney) for their contributions. + +- New Rule: ```author-valid-email``` enforces a valid author email address. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/#m1-author-valid-email). +- **Breaking change**: The ```--commits``` commandline flag now strictly follows the refspec format as interpreted + by the [```git rev-list ```](https://git-scm.com/docs/git-rev-list) command. This means + that linting a single commit using ```gitlint --commits ``` won't work anymore. Instead, for single commits, + users now need to specificy ```gitlint --commits ^...```. On the upside, this change also means + that gitlint will now understand all refspec formatters, including ```gitlint --commits HEAD``` to lint all commits + in the repository. This fixes [#23](https://github.com/jorisroovers/gitlint/issues/23). +- **Breaking change**: Gitlint now always falls back on trying to read a git message from a local git repository, only + reading a commit message from STDIN if one is passed. Before, gitlint only read from the local git repository when + a TTY was present. This is likely the expected and desired behavior for anyone running gitlint in a CI environment. + This fixes [#40](https://github.com/jorisroovers/gitlint/issues/40) and + [#42](https://github.com/jorisroovers/gitlint/issues/42). +- **Behavior Change**: Gitlint will now by default + [ignore squash and fixup commits](http://jorisroovers.github.io/gitlint/#merge-fixup-and-squash-commits) + (fix for [#33: fixup messages should not trigger a gitlint violation](https://github.com/jorisroovers/gitlint/issues/33)) +- Support for custom comment characters ([#34](https://github.com/jorisroovers/gitlint/issues/34)) +- Support for [```git commit --cleanup=scissors```](https://git-scm.com/docs/git-commit#git-commit---cleanupltmodegt) + ([#34](https://github.com/jorisroovers/gitlint/issues/34)) +- Bugfix: [#37: Prevent Commas in text fields from breaking git log printing](https://github.com/jorisroovers/gitlint/issues/37) +- Debug output improvements + +## v0.8.2 (2017-04-25) ## + +The 0.8.2 release brings minor improvements, bugfixes and some under-the-hood changes. Special thanks to +[tommyip](https://github.com/tommyip) for his contributions. + +- ```--extra-path``` now also accepts a file path (in the past only directory paths where accepted). +Thanks to [tommyip](https://github.com/tommyip) for implementing this! +- gitlint will now show more information when using the ```--debug``` flag. This is initial work and will continue to +be improved upon in later releases. +- Bugfixes: + - [#24: --commits doesn't take commit specific config into account](https://github.com/jorisroovers/gitlint/issues/24) + - [#27: --commits returns the wrong exit code](https://github.com/jorisroovers/gitlint/issues/27) +- Development: better unit and integration test coverage for ```--commits``` + +## v0.8.1 (2017-03-16) ## + +The 0.8.1 release brings minor tweaks and some experimental features. Special thanks to +[tommyip](https://github.com/tommyip) for his contributions. + +- Experimental: Linting a range of commits. + [Documentation](http://jorisroovers.github.io/gitlint/#linting-a-range-of-commits). + Known Caveats: [#23](https://github.com/jorisroovers/gitlint/issues/23), + [#24](https://github.com/jorisroovers/gitlint/issues/24). + Closes [#14](https://github.com/jorisroovers/gitlint/issues/14). Thanks to [tommyip](https://github.com/tommyip) + for implementing this! +- Experimental: Python 3.6 support +- Improved Windows error messaging: gitlint will now show a more descriptive error message when ran on windows. + See [#20](https://github.com/jorisroovers/gitlint/issues/20) for details on the lack of Windows support. + +## v0.8.0 (2016-12-30) ## + +The 0.8.0 release is a significant release that has been in the works for a long time. Special thanks to +[Claymore](https://github.com/Claymore), [gernd](https://github.com/gernd) and +[ZhangYaxu](https://github.com/ZhangYaxu) for submitting bug reports and pull requests. + +- Full unicode support: you can now lint messages in any language! This fixes + [#16](https://github.com/jorisroovers/gitlint/issues/16) and [#18](https://github.com/jorisroovers/gitlint/pull/18). +- User-defined rules: you can now + [define your own custom rules](http://jorisroovers.github.io/gitlint/user_defined_rules/) + if you want to extend gitlint's functionality. +- Pypy2 support! +- Debug output improvements: Gitlint will now print your active configuration when using ```--debug``` +- The ```general.target``` option can now also be set via ```-c``` flags or a ```.gitlint``` file +- Bugfixes: + - Various important fixes related to configuration precedence + - [#17: Body MinLength is not working properly](https://github.com/jorisroovers/gitlint/issues/17). + **Behavior Change**: Gitlint now always applies this rule, even if the body has just a single line of content. + Also, gitlint now counts the body-length for the entire body, not just the length of the first line. +- Various documentation improvements +- Development: + - Pylint compliance for all supported python versions + - Updated dependencies to latest versions + - Various ```run_tests.sh``` improvements for developer convenience + +## v0.7.1 (2016-06-18) ## +Bugfixes: + +- **Behavior Change**: gitlint no longer prints the file path by default when using a ```.gitlint``` file. The path +will still be printed when using the new ```--debug``` flag. Special thanks to [Slipcon](https://github.com/slipcon) +for submitting this. +- Gitlint now prints a correct violation message for the ```title-match-regex``` rule. Special thanks to +[Slipcon](https://github.com/slipcon) for submitting this. +- Gitlint is now better at parsing commit messages cross-platform by taking platform specific line endings into account +- Minor documentation improvements + +## v0.7.0 (2016-04-20) ## +This release contains mostly bugfix and internal code improvements. Special thanks to +[William Turell](https://github.com/wturrell) and [Joe Grund](https://github.com/jgrund) for bug reports and pull +requests. + +- commit-msg hooks improvements: The new commit-msg hook now allows you to edit your message if it contains violations, + prints the commit message on aborting and is more compatible with GUI-based git clients such as SourceTree. + *You will need to uninstall and reinstall the commit-msg hook for these latest features*. +- Python 2.6 support +- **Behavior change**: merge commits are now ignored by default. The rationale is that the original commits + should already be linted and that many merge commits don't pass gitlint checks by default + (e.g. exceeding title length or empty body is very common). This behavior can be overwritten by setting the + general option ```ignore-merge-commit=false```. +- Bugfixes and enhancements: + - [#7: Hook compatibility with SourceTree](https://github.com/jorisroovers/gitlint/issues/7) + - [#8: Illegal option -e](https://github.com/jorisroovers/gitlint/issues/8) + - [#9: print full commit msg to stdout if aborted](https://github.com/jorisroovers/gitlint/issues/9) + - [#11 merge commit titles exceeding the max title length by default](https://github.com/jorisroovers/gitlint/issues/11) + - Better error handling of invalid general options +- Development: internal refactoring to extract more info from git. This will allow for more complex rules in the future. +- Development: initial set of integration tests. Test gitlint end-to-end after it is installed. +- Development: pylint compliance for python 2.7 + +## v0.6.1 (2015-11-22) ## + +- Fix: ```install-hook``` and ```generate-config``` commands not working when gitlint is installed from pypi. + +## v0.6.0 (2015-11-22) ## + +- Python 3 (3.3+) support! +- All documentation is now hosted on [http://jorisroovers.github.io/gitlint/]() +- New ```generate-config``` command generates a sample gitlint config file +- New ```--target``` flag allows users to lint different directories than the current working directory +- **Breaking change**: exit code behavior has changed. More details in the + [Exit codes section of the documentation](http://jorisroovers.github.io/gitlint/#exit-codes). +- **Breaking change**: ```--install-hook``` and ```--uninstall-hook``` have been renamed to ```install-hook``` and + ```uninstall-hook``` respectively to better express that they are commands instead of options. +- Better error handling when gitlint is executed in a directory that is not a git repository or + when git is not installed. +- The git commit message hook now uses pretty colored output +- Fix: ```--config``` option no longer accepts directories as value +- Development: unit tests are now ran using py.test + +## v0.5.0 (2015-10-04) ## + +- New Rule: ```title-match-regex```. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). +- Uninstall previously installed gitlint git commit hooks using: ```gitlint --uninstall-hook``` +- Ignore rules on a per commit basis by adding e.g.: ```gitlint-ignore: T1, body-hard-tab``` to your git commit message. + Use ```gitlint-ignore: all``` to disable gitlint all together for a specific commit. +- ```body-is-missing``` will now automatically be disabled for merge commits (use the ```ignore-merge-commit: false``` + option to disable this behavior) +- Violations are now sorted by line number first and then by rule id (previously the order of violations on the + same line was arbitrary). + +## v0.4.1 (2015-09-19) ## + +- Internal fix: added missing comma to setup.py which prevented pypi upload + +## v0.4.0 (2015-09-19) ## + +- New rules: ```body-is-missing```, ```body-min-length```, ```title-leading-whitespace```, + ```body-changed-file-mention```. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). +- The git ```commit-msg``` hook now allows you to keep or discard the commit when it fails gitlint validation +- gitlint is now also released as a [python wheel](http://pythonwheels.com/) on pypi. +- Internal: rule classes now have access to a gitcontext containing body the commit message and the files changed in the + last commit. + +## v0.3.0 (2015-09-11) ## +- ```title-must-not-contain-word``` now has a ```words``` option that can be used to specify which words should not + occur in the title +- gitlint violations are now printed to the stderr instead of stdout +- Various minor bugfixes +- gitlint now ignores commented out lines (i.e. starting with #) in your commit messages +- Experimental: git commit-msg hook support +- Under-the-hood: better test coverage :-) + +## v0.2.0 (2015-09-10) ## + - Rules can now have their behavior configured through options. + For example, the ```title-max-length``` rule now has a ```line-length``` option. + - Under-the-hood: The codebase now has a basic level of unit test coverage, increasing overall quality assurance + +## v0.1.1 (2015-09-08) ## +- Bugfix: added missing ```sh``` dependency + +## v0.1.0 (2015-09-08) ## +- Initial gitlint release +- Initial set of rules: title-max-length, title-trailing-whitespace, title-trailing-punctuation , title-hard-tab, + title-must-not-contain-word, body-max-line-length, body-trailing-whitespace, body-hard-tab +- General gitlint configuration through a ```gitlint``` file +- Silent and verbose mode +- Vagrantfile for easy development +- gitlint is available on [pypi](https://pypi.python.org/pypi/gitlint) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..892ff53 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Contributing + +Thanks for your interest in contributing to gitlint! + +Instructions on how to get started can be found on [http://jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing/). + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b66bb71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# User-facing Dockerfile. For development, see Dockerfile.dev and ./run_tests.sh -h + +# To lint your current working directory: +# docker run -v $(pwd):/repo jorisroovers/gitlint + +# With arguments: +# docker run -v $(pwd):/repo jorisroovers/gitlint --debug --ignore T1 + +FROM python:3.8-alpine +ARG GITLINT_VERSION + +RUN apk add git +RUN pip install gitlint==$GITLINT_VERSION + +ENTRYPOINT ["gitlint", "--target", "/repo"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..5cd1739 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,17 @@ +# Note: development using the local Dockerfile is still work-in-progress +# Getting started: http://jorisroovers.github.io/gitlint/contributing/ +ARG python_version_dotted + +FROM python:${python_version_dotted}-stretch + +RUN apt-get update +# software-properties-common contains 'add-apt-repository' +RUN apt-get install -y git silversearcher-ag jq curl + +ADD . /gitlint +WORKDIR /gitlint + +RUN pip install --ignore-requires-python -r requirements.txt +RUN pip install --ignore-requires-python -r test-requirements.txt + +CMD ["/bin/bash"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..122bd28 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Joris Roovers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..51a5598 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +include README.md +include LICENSE +exclude Vagrantfile +exclude *.yml *.sh *.txt +recursive-exclude examples * +recursive-exclude gitlint/tests * +recursive-exclude qa * \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..81f2ac9 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# gitlint: [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) # + +[![Tests](https://github.com/jorisroovers/gitlint/workflows/Tests%20and%20Checks/badge.svg)](https://github.com/jorisroovers/gitlint/actions?query=workflow%3A%22Tests+and+Checks%22) +[![PyPi Package](https://img.shields.io/pypi/v/gitlint.png)](https://pypi.python.org/pypi/gitlint) +![Supported Python Versions](https://img.shields.io/pypi/pyversions/gitlint.svg) + +Git commit message linter written in python (for Linux and Mac, experimental on Windows), checks your commit messages for style. + +**See [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) for full documentation.** + + + +## Contributing ## +All contributions are welcome and very much appreciated! + +**I'm looking for contributors that are interested in taking a more active co-maintainer role as it's becoming increasingly difficult for me to find time to maintain gitlint. Please open a PR if you're interested - Thanks!** + +See [jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing) for details on +how to get started - it's easy! + +We maintain a [loose roadmap on our wiki](https://github.com/jorisroovers/gitlint/wiki/Roadmap). diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..2a26aab --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,47 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +VAGRANTFILE_API_VERSION = "2" + +INSTALL_DEPS=<> /home/vagrant/.bashrc +grep 'source .venv27/bin/activate' /home/vagrant/.bashrc || echo 'source .venv27/bin/activate' >> /home/vagrant/.bashrc +EOF + +INSTALL_JENKINS=< /etc/apt/sources.list.d/jenkins.list' +sudo apt-get update +sudo apt-get install -y openjdk-8-jre +sudo apt-get install -y jenkins +EOF + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.box = "ubuntu/xenial64" + + config.vm.define "dev" do |dev| + dev.vm.provision "gitlint", type: "shell", inline: "#{INSTALL_DEPS}" + # Use 'vagrant provision --provision-with jenkins' to only run jenkins install + dev.vm.provision "jenkins", type: "shell", inline: "#{INSTALL_JENKINS}" + end + + config.vm.network "forwarded_port", guest: 8080, host: 9080 + + if Vagrant.has_plugin?("vagrant-cachier") + config.cache.scope = :box + end + +end diff --git a/doc-requirements.txt b/doc-requirements.txt new file mode 100644 index 0000000..baf208d --- /dev/null +++ b/doc-requirements.txt @@ -0,0 +1 @@ +mkdocs==1.0.4 \ No newline at end of file diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..641b361 --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,432 @@ +# Configuration +Gitlint can be configured through different means. + +# Config files # +You can modify gitlint's behavior by adding a ```.gitlint``` file to your git repository. + +Generate a default ```.gitlint``` config file by running: +```bash +gitlint generate-config +``` +You can also use a different config file like so: + +```bash +gitlint --config myconfigfile.ini +``` + +The block below shows a sample ```.gitlint``` file. Details about rule config options can be found on the +[Rules](rules.md) page, details about the ```[general]``` section can be found in the +[General Configuration](configuration.md#general-configuration) section of this page. + +```ini +# Edit this file as you like. +# +# All these sections are optional. Each section with the exception of [general] represents +# one rule and each key in it is an option for that specific rule. +# +# Rules and sections can be referenced by their full name or by id. For example +# section "[body-max-line-length]" could be written as "[B1]". Full section names are +# used in here for clarity. +# Rule reference documentation: http://jorisroovers.github.io/gitlint/rules/ +# +# Use 'gitlint generate-config' to generate a config file with all possible options +[general] +# Ignore certain rules (comma-separated list), you can reference them by their +# id or by their full name +ignore=title-trailing-punctuation, T3 + +# verbosity should be a value between 1 and 3, the commandline -v flags take +# precedence over this +verbosity = 2 + +# By default gitlint will ignore merge, revert, fixup and squash commits. +ignore-merge-commits=true +ignore-revert-commits=true +ignore-fixup-commits=true +ignore-squash-commits=true + +# Ignore any data send to gitlint via stdin +ignore-stdin=true + +# Fetch additional meta-data from the local repository when manually passing a +# commit message to gitlint via stdin or --commit-msg. Disabled by default. +staged=true + +# Enable debug mode (prints more output). Disabled by default. +debug=true + +# Enable community contributed rules +# See http://jorisroovers.github.io/gitlint/contrib_rules for details +contrib=contrib-title-conventional-commits,CC1 + +# Set the extra-path where gitlint will search for user defined rules +# See http://jorisroovers.github.io/gitlint/user_defined_rules for details +extra-path=examples/ + +# This is an example of how to configure the "title-max-length" rule and +# set the line-length it enforces to 80 +[title-max-length] +line-length=80 + +[title-must-not-contain-word] +# Comma-separated list of words that should not occur in the title. Matching is case +# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" +# will not cause a violation, but "WIP: my title" will. +words=wip + +[title-match-regex] +# python like regex (https://docs.python.org/2/library/re.html) that the +# commit-msg title must be matched to. +# Note that the regex can contradict with other rules if not used correctly +# (e.g. title-must-not-contain-word). +regex=^US[0-9]* + +[body-max-line-length] +line-length=120 + +[body-min-length] +min-length=5 + +[body-is-missing] +# Whether to ignore this rule on merge commits (which typically only have a title) +# default = True +ignore-merge-commits=false + +[body-changed-file-mention] +# List of files that need to be explicitly mentioned in the body when they are changed +# This is useful for when developers often erroneously edit certain files or git submodules. +# By specifying this rule, developers can only change the file when they explicitly reference +# it in the commit message. +files=gitlint/rules.py,README.md + +[author-valid-email] +# python like regex (https://docs.python.org/2/library/re.html) that the +# commit author email address should be matched to +# For example, use the following regex if you only want to allow email addresses from foo.com +regex=[^@]+@foo.com + +[ignore-by-title] +# Ignore certain rules for commits of which the title matches a regex +# E.g. Match commit titles that start with "Release" +regex=^Release(.*) + +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +ignore=T1,body-min-length + +[ignore-by-body] +# Ignore certain rules for commits of which the body has a line that matches a regex +# E.g. Match bodies that have a line that that contain "release" +# regex=(.*)release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +ignore=T1,body-min-length + +# This is a contrib rule - a community contributed rule. These are disabled by default. +# You need to explicitly enable them one-by-one by adding them to the "contrib" option +# under [general] section above. +[contrib-title-conventional-commits] +# Specify allowed commit types. For details see: https://www.conventionalcommits.org/ +types = bugfix,user-story,epic +``` + +# Commandline config # + +You can also use one or more ```-c``` flags like so: + +``` +$ gitlint -c general.verbosity=2 -c title-max-length.line-length=80 -c B1.line-length=100 +``` +The generic config flag format is ```-c .