From a145175e78eebb9cc22c19234f018d4159ae6ec1 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 10:12:06 +0200 Subject: [PATCH 01/44] added pre-commit-config --- .pre-commit-config.yaml | 180 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..471395f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,180 @@ +minimum_pre_commit_version: "1.15" +default_stages: [commit, push] +default_language_version: + python: python3.8 + +repos: + #: code unspecific out-of-the-box hooks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 + hooks: + - id: no-commit-to-branch + args: [--branch, staging, --branch, master, --pattern, release/.*] + - id: check-case-conflict + - id: name-tests-test + args: ["--django"] + - id: check-json + - id: pretty-format-json + args: ["--indent=4", "--autofix"] + - id: check-toml + - id: check-yaml + - id: detect-private-key + - id: trailing-whitespace + stages: [commit, push] + - id: end-of-file-fixer + stages: [commit, push] + + #: several python code regex hooks + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.5.1 + hooks: + - id: python-no-log-warn + - id: python-no-eval + + #: setup-cfg-fmt - format python setup.cfg + - repo: https://github.com/asottile/setup-cfg-fmt + rev: v1.9.0 + hooks: + - id: setup-cfg-fmt + #: C/C++-Extensions make problems with py38 on win - here: "editdistance" + language_version: python3.7 + + #: pyupgrade - upgrade old python syntax to new + - repo: https://github.com/asottile/pyupgrade + rev: v2.4.1 + hooks: + - id: pyupgrade + args: [--py36-plus] + + #: seed-isort-config - fill isort's known_third_party config + - repo: https://github.com/asottile/seed-isort-config + rev: v2.1.1 + hooks: + - id: seed-isort-config + args: [--application-directories, "src:."] + + #: isort - sort imports + - repo: https://github.com/timothycrosley/isort + rev: 4.3.21 + hooks: + - id: isort + args: [--apply, --recursive] + additional_dependencies: [toml>=0.10.1] + + #: blacken-docs - black for python code in docs + - repo: https://github.com/asottile/blacken-docs + rev: v1.7.0 + hooks: + - id: blacken-docs + additional_dependencies: [black==19.10b0] + + #: black - python formatter + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + args: [--safe] + +# TODO: 16.04.2020: Currently bandit is unusable with pre-commit .. wait for fix .. remove in tox then +# #: bandit - python code security analyzer +# - repo: https://github.com/PyCQA/bandit +# rev: 1.6.2 +# hooks: +# - id: bandit +# args: ["--exclude ./.tox/*,./.eggs/*,./tests/*"] + + #: flake8 - python linter + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.1 + hooks: + - id: flake8 + args: [ + --count, + --statistics, + "--extend-exclude=*venv*/,*.egg,build/", + --extend-ignore=E203, + --max-line-length=88, + --max-complexity=20, + --pytest-fixture-no-parentheses, + "--format=${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s", + ] + additional_dependencies: + #: Colored output - needs custom format + - "flake8-colors" + #: Check for python builtins being used as variables or parameters. + #: A001-A002 + - "flake8-builtins==1.5.2" + #: Finding likely bugs and design problems + #: B001-B014 | B301-B306 | B901-B903,B950 + - "flake8-bugbear==20.1.4" + #: Write better list/set/dict comprehensions + #: C400-C416 + - "flake8-comprehensions==3.2.2" + #: Check docstrings with PEP257 + #: D100-D107 | D200-D215 | D300-D302 | D400-D417 +# TODO: 16.04.2020: Wait for https://github.com/PyCQA/pydocstyle/pull/446 to fix problem with noqa before module docstrings + # - "flake8-docstrings==1.5.0" + #: Find dead/out-commented code + #: E800 + - "flake8-eradicate==0.3.0" + #: Validate (lack of) logging format strings + #: G001-G004, G010 | G100 | G200-G202 + - "flake8-logging-format==0.6.0" + #: Find line breaks with '\' + #: N400 + - "flake8-broken-line==0.2.0" + #: Check your code against PEP 8 naming conventions + #: N801-N807, N811-N817 + - "pep8-naming==0.10.0" + #: Find mutable default assignments in func/class definitions + #: M511 + - "flake8-mutable==1.2.0" + #: Check common style issues or inconsistencies with pytest-based tests + #: PT001-PT019 + - "flake8-pytest-style==1.1.1" + #: Check if typing imports are properly guarded + #: TYP001 - TYP006 + - "flake8-typing-imports==1.9.0" + #: Find strings with leading 'u' + #: UPS + - "flake8-no-u-prefixed-strings==0.2" + #: Make more readable variables names + #: VNE001-VNE003 + - "flake8-variables-names==0.0.3" + #: Checks for misuse of sys.version or sys.version_info (Py 3.10 / 4.0 coming) + #: YTT101-YTT103 | YTT201-YTT204 | YTT301-YTT303 + - "flake8-2020==1.6.0" + + + #: Hooks managed via tox `pre-commit` venv + - repo: local + hooks: + #: pylint - python linter + - id: pylint + name: pylint + entry: ./.pre-commit-scripts/run_pylint + language: system + types: [python] + #: mypy - python type checker + - id: mypy + args: ["--warn-unused-ignores"] # , --scripts-are-modules, --ignore-missing-imports] + name: mypy + entry: ./.pre-commit-scripts/run_mypy + language: system + types: [python] + exclude: > + (?x)^( + setup.py| + docs/source/conf.py + )$ + + + #: Meta hooks + - repo: meta + hooks: + - id: identity + stages: [manual] + - id: check-hooks-apply + stages: [manual] + - id: check-useless-excludes + stages: [manual] From 69968b035aca0e3581e37c6c4135886484d66a9d Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 10:25:57 +0200 Subject: [PATCH 02/44] added travis & codecov conf --- .travis.yml | 16 ++++++++++++++++ codecov.yml | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 .travis.yml create mode 100644 codecov.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0ad6e61 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: + - "3.6" + - "3.7" + - "3.8" + +notifications: + email: false + +install: + - pip install -U tox-travis coverage codecov + +script: + - tox + +after_success: coverage combine && codecov diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..a969a76 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,7 @@ +codecov: + require_ci_to_pass: true + +coverage: + precision: 2 + round: down + range: "90...100" From 54390a6c34510f3cb69d2c499abb41ba25e2a31c Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 10:27:06 +0200 Subject: [PATCH 03/44] updated gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9ef208f..cbe306f 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,6 @@ version.py # Local backup dir .backupfiles + +# poetry lockfile +poetry.lock From 8add0754faf18b6cdffacff8d01c7edc5ee29af6 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 10:29:35 +0200 Subject: [PATCH 04/44] added pre-commit run scripts --- .pre-commit-scripts/run_mypy | 21 +++++++++++++++++++++ .pre-commit-scripts/run_pylint | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 .pre-commit-scripts/run_mypy create mode 100755 .pre-commit-scripts/run_pylint diff --git a/.pre-commit-scripts/run_mypy b/.pre-commit-scripts/run_mypy new file mode 100755 index 0000000..7d3efcb --- /dev/null +++ b/.pre-commit-scripts/run_mypy @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Script to call local installation of `mypy`. + +Script considers OS and calls mypy accordingly. +""" + +import subprocess +import sys + + +def main(): + """Call mypy""" + if sys.platform == "win32": + cmd = (".tox/pre-commit/Scripts/mypy.exe", *sys.argv[1:]) + else: + cmd = (".tox/pre-commit/bin/mypy", *sys.argv[1:]) + return subprocess.call(cmd) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.pre-commit-scripts/run_pylint b/.pre-commit-scripts/run_pylint new file mode 100755 index 0000000..4ec4ca8 --- /dev/null +++ b/.pre-commit-scripts/run_pylint @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Script to call local installation of `pylint`. + +Script considers OS and calls pylint accordingly. +""" + +import subprocess +import sys + + +def main(): + """Call pylint""" + if sys.platform == "win32": + cmd = (".tox/pre-commit/Scripts/pylint.exe", *sys.argv[1:]) + else: + cmd = (".tox/pre-commit/bin/pylint", *sys.argv[1:]) + return subprocess.call(cmd) + + +if __name__ == "__main__": + sys.exit(main()) From 53f7761a031efe1b08f82d3123f651c733c8543d Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 10:31:38 +0200 Subject: [PATCH 05/44] added configs to pyproject.toml --- pyproject.toml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1db8392..595fb46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,3 +31,64 @@ click = "^7.1.2" [tool.poetry.scripts] jira_commit_msg = "check_jira_tag:main" + + +# -- BLACK CONFIG ---------------------------------------------------------------------- +[tool.black] +line-length = 88 +exclude = "venv/" + + +# -- ISORT CONFIG ---------------------------------------------------------------------- +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +lines_after_imports = 2 +lines_between_types = 1 +known_first_party = ["check_jira_tag", "tests"] +known_third_party = [] +skip = ["venv"] + + +# -- COVERAGE CONFIG ------------------------------------------------------------------- +[tool.coverage.run] +branch = true +parallel = true +source = ["src/"] +[tool.coverage.report] +fail_under = 100 +skip_covered = false +show_missing = true +exclude_lines = [ + "pragma: no cover", + "def __str__", + "def __repr__", + "if self.debug:", + "if settings.DEBUG", + "raise AssertionError", + "raise NotImplementedError", + "if 0:", + "if __name__ == .__main__.:", +] +omit = [ + "venv/*", + "tests/*", + "setup.py", + "*/__main__.py", +] +[tool.coverage.paths] +source = [ + "src/color_space_visualizer", + "*/.tox/*/lib/python*/site-packages/color_space_visualizer", + "*/.tox/pypy*/site-packages/color_space_visualizer", + "*/.tox\\*\\Lib\\site-packages\\color_space_visualizer", + "*/src/color_space_visualizer", + "*\\src\\color_space_visualizer", +] + + +# -- PYLINT CONFIG --------------------------------------------------------------------- +[tool.pylint."MESSAGES CONTROL"] +disable = [ + "C0330", # Indentation | deactivated for black +] From 33805dff647bebc84073068c4943f0f462073d03 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:00:21 +0200 Subject: [PATCH 06/44] moved script into own dir --- commit_msg_jira_hook/__init__.py | 29 +++++++++++++++++++ .../check_jira_tag.py | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 commit_msg_jira_hook/__init__.py rename check_jira_tag.py => commit_msg_jira_hook/check_jira_tag.py (98%) diff --git a/commit_msg_jira_hook/__init__.py b/commit_msg_jira_hook/__init__.py new file mode 100644 index 0000000..9fc4e0f --- /dev/null +++ b/commit_msg_jira_hook/__init__.py @@ -0,0 +1,29 @@ +# ====================================================================================== +# Copyright (c) 2020 Christian Riedel +# +# This file '__init__.py' created 2020-05-19 +# is part of the project/program 'commit-msg-jira-hook'. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Github: https://github.com/Cielquan/ +# ====================================================================================== +""" + commit_msg_jira_hook + ~~~~~~~~~~~~~~~~~~~~ + + Check commit message for valid issue tag + + :copyright: (c) 2020 Christian Riedel + :license: GPLv3, see LICENSE for more details +""" diff --git a/check_jira_tag.py b/commit_msg_jira_hook/check_jira_tag.py similarity index 98% rename from check_jira_tag.py rename to commit_msg_jira_hook/check_jira_tag.py index 1dad20d..8503674 100755 --- a/check_jira_tag.py +++ b/commit_msg_jira_hook/check_jira_tag.py @@ -21,8 +21,8 @@ # Github: https://github.com/Cielquan/ # ====================================================================================== """ - check_jira_tag - ~~~~~~~~~~~~~~ + commit_msg_jira_hook.check_jira_tag + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Check commit message for valid issue tag From 549bea33799b029aef47ab791224eadf66e97bf8 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:00:29 +0200 Subject: [PATCH 07/44] removed highlight directives from readme --- README.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.rst b/README.rst index 70c7702..b210f2f 100644 --- a/README.rst +++ b/README.rst @@ -27,8 +27,6 @@ Usage Add this to your project's ``.pre-commit-config.yaml`` file: -.. highlight:: yaml - .. code-block:: yaml repos: @@ -47,8 +45,6 @@ Exchange the placeholders with your actual config. may be ``https://jira.a Then add a ``.jira.ini`` file to your home directory with the following config: -.. highlight:: ini - .. code-block:: ini [jira] @@ -60,8 +56,6 @@ Get api token from here: https://id.atlassian.com/manage/api-tokens Lastly install the hook: -.. highlight:: console - .. code-block:: console $ pre-commit install -t commit-msg @@ -119,5 +113,3 @@ but I cannot promise a quick response time. :target: https://github.com/Cielquan/commit-msg-jira-hook/graphs/contributors .. BADGES END - -.. highlight:: default From f3f9de0d5100519b71dd56a662c115cbf603a989 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:02:02 +0200 Subject: [PATCH 08/44] updated pyproject with new script dir --- pyproject.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 595fb46..e836ffc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,9 +18,6 @@ classifiers = [ ] repository = "https://github.com/Cielquan/commit-msg-jira-hook" readme = "README.rst" -packages = [ - { include = "check_jira_tag.py" }, -] [tool.poetry.dependencies] python = "^3.6" @@ -30,7 +27,7 @@ click = "^7.1.2" [tool.poetry.dev-dependencies] [tool.poetry.scripts] -jira_commit_msg = "check_jira_tag:main" +jira_commit_msg = "commit_msg_jira_hook.check_jira_tag:main" # -- BLACK CONFIG ---------------------------------------------------------------------- From 8c1b3943cec601a9ee500bacf5995a84deb8e31f Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:07:00 +0200 Subject: [PATCH 09/44] added dev+test deps --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e836ffc..1b53412 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,8 +23,15 @@ readme = "README.rst" python = "^3.6" jira = "^2.0.0" click = "^7.1.2" +pytest = {version = "^5.4.2", optional = true} +pytest-cov = {version = "^2.8.1", optional = true} +toml = {version = "^0.10.1", optional = true} [tool.poetry.dev-dependencies] +devtools = "^0.5.1" + +[tool.poetry.extras] +testing = ["pytest", "pytest-cov", "toml"] [tool.poetry.scripts] jira_commit_msg = "commit_msg_jira_hook.check_jira_tag:main" From 86112292f71e8af28fd91a67ee49b03193df9639 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:12:22 +0200 Subject: [PATCH 10/44] added empty test file --- tests/test_check_jira_tag.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 tests/test_check_jira_tag.py diff --git a/tests/test_check_jira_tag.py b/tests/test_check_jira_tag.py new file mode 100755 index 0000000..4da6755 --- /dev/null +++ b/tests/test_check_jira_tag.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# ====================================================================================== +# Copyright (c) 2020 Christian Riedel +# +# This file 'test_check_jira_tag.py' created 2020-05-19 +# is part of the project/program 'commit-msg-jira-hook'. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Github: https://github.com/Cielquan/ +# ====================================================================================== +""" + tests.test_check_jira_tag + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + test check_jira_tag + + :copyright: (c) 2020 Christian Riedel + :license: GPLv3, see LICENSE for more details +""" +import pytest +import commit_msg_jira_hook.check_jira_tag From 42a7c9571e23fff739de59ab7e1255972713f93f Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:18:29 +0200 Subject: [PATCH 11/44] added known_third_party to pyproject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1b53412..3997668 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ include_trailing_comma = true lines_after_imports = 2 lines_between_types = 1 known_first_party = ["check_jira_tag", "tests"] -known_third_party = [] +known_third_party = ["click", "jira", "pytest"] skip = ["venv"] From 2432096ee3d394314fc27f72be266a8a38f29828 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:20:14 +0200 Subject: [PATCH 12/44] added tox --- tox.ini | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..48e00fd --- /dev/null +++ b/tox.ini @@ -0,0 +1,106 @@ +# -- TOX CONFIG ------------------------------------------------------------------------ +[tox] +minversion = 3.15.0 +#: For locally skipping missing interpreters use `tox -s false` +skip_missing_interpreters = False +#: Activate isolated build environment - PEP-517 and PEP-518. +isolated_build = True +#: Application -> True; Library -> False +skipsdist = False + +envlist = + pre-commit + bandit + py3{8,7,6} + coverage + package + + +[testenv] +description = basic config env +setenv = + PIP_DISABLE_VERSION_CHECK = 1 + COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} +passenv = + PYTEST_* + HOME + CI + TRAVIS + TRAVIS_* +download = True + + +[testenv:pre-commit] +description = format and check the code +passenv = + SSH_AUTH_SOCK +deps = + pre-commit>=2,<3 + mypy==0.770 + pylint>=2.4,<3 +commands = + pre-commit run --all-files --show-diff-on-failure + python -c 'import pathlib;print("HINT: run \"\{\} install\" to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}")/"bin"/"pre-commit"))' + + +[testenv:bandit] +description = run bandit for security checks +deps = bandit >= 1.6.2, < 2 +commands = bandit -x ./.tox/*,./venv/*,./.eggs/*,./tests/* -r . + + +[testenv:py3{8,7,6}] +description = run tests with {basepython} +extras = testing +commands = + pytest \ + --basetemp="{envtmpdir}" \ + --cov "{envsitepackagesdir}/commit_msg_jira_hook" \ + {posargs:tests} + + +[testenv:coverage] +description = combine coverage data and create report; generates a diff coverage + against origin/master (can be changed by setting DIFF_AGAINST env var) +deps = + coverage[toml]>=5,<6 + diff_cover +skip_install = True +passenv = + {[testenv]passenv} + DIFF_AGAINST +setenv = COVERAGE_FILE={toxworkdir}/.coverage +commands = + coverage combine + coverage report -m + coverage xml -o {toxworkdir}/coverage.xml + coverage html -d {toxworkdir}/htmlcov + diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml +depends = + pytest +parallel_show_output = True + + +[testenv:package] +skip_install = True +deps = + twine + poetry>=0.12 +commands = + poetry build + twine check dist/* + + +# -- TRAVIS CONFIG --------------------------------------------------------------------- +[travis] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38, pre-commit, bandit, package + + +# -- PYTEST CONFIG --------------------------------------------------------------------- +# support for pyproject.toml for 5.5 planned +[pytest] +addopts = -ra --showlocals +mock_use_standalone_module = True From 5dfb357a424ed8854d36ff5f08f2aebe02766177 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:20:58 +0200 Subject: [PATCH 13/44] blacked script --- commit_msg_jira_hook/check_jira_tag.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/commit_msg_jira_hook/check_jira_tag.py b/commit_msg_jira_hook/check_jira_tag.py index 8503674..a66fbcf 100755 --- a/commit_msg_jira_hook/check_jira_tag.py +++ b/commit_msg_jira_hook/check_jira_tag.py @@ -58,9 +58,7 @@ ) @click.argument("commit-msg-file", required=True, nargs=1) @click.pass_context -def main( - ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str -) -> None: +def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str) -> None: """Check commit messages for issue tags COMMIT_MSG_FILE: Path to file with commit-msg. Passed by pre-commit." From 6c851c1d619b31096e2dad253355b98908fdbd99 Mon Sep 17 00:00:00 2001 From: Christian Riedel Date: Tue, 19 May 2020 12:29:54 +0200 Subject: [PATCH 14/44] moved pre-commit to py37 in travis --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 48e00fd..8c4806d 100644 --- a/tox.ini +++ b/tox.ini @@ -95,8 +95,8 @@ commands = [travis] python = 3.6: py36 - 3.7: py37 - 3.8: py38, pre-commit, bandit, package + 3.7: py37, pre-commit + 3.8: py38, bandit, package # -- PYTEST CONFIG --------------------------------------------------------------------- From 64860a3d3ef8767084d59292fe56b6892385e571 Mon Sep 17 00:00:00 2001 From: Christian Riedel Date: Tue, 19 May 2020 12:32:36 +0200 Subject: [PATCH 15/44] removed py38 as default - pre-commit --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 471395f..58197e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,5 @@ minimum_pre_commit_version: "1.15" default_stages: [commit, push] -default_language_version: - python: python3.8 repos: #: code unspecific out-of-the-box hooks From f73e725611fbf150c5944462b6c00618d83ceac4 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:38:32 +0200 Subject: [PATCH 16/44] removed MANIFEST.in --- MANIFEST.in | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index a84042b..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -# exclude maintenance files tracked by setuptools-scm -exclude .gitignore .gitattributes .editorconfig -exclude .pre-commit-config.yaml tox.ini -exclude azure-pipelines.yml .travis.yml appveyor.yml codecov.yml -exclude .readthedocs.yaml -exclude MANIFEST.in From 6842b84bdeee994e518c9d4edd094f0eb8f36e8e Mon Sep 17 00:00:00 2001 From: Cielquan Date: Tue, 19 May 2020 12:52:25 +0200 Subject: [PATCH 17/44] added tox dev env | added pre-commit extras - poetry --- pyproject.toml | 6 +++++- tox.ini | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3997668..91c3cef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,18 +20,22 @@ repository = "https://github.com/Cielquan/commit-msg-jira-hook" readme = "README.rst" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.6.1" jira = "^2.0.0" click = "^7.1.2" pytest = {version = "^5.4.2", optional = true} pytest-cov = {version = "^2.8.1", optional = true} toml = {version = "^0.10.1", optional = true} +pre-commit = {version = "^2.4", optional = true} +mypy = {version = "0.770", optional = true} +pylint = {version = "^2.4", optional = true} [tool.poetry.dev-dependencies] devtools = "^0.5.1" [tool.poetry.extras] testing = ["pytest", "pytest-cov", "toml"] +pre-commit = ["pre-commit", "mypy", "pylint"] [tool.poetry.scripts] jira_commit_msg = "commit_msg_jira_hook.check_jira_tag:main" diff --git a/tox.ini b/tox.ini index 8c4806d..79f4fae 100644 --- a/tox.ini +++ b/tox.ini @@ -34,10 +34,7 @@ download = True description = format and check the code passenv = SSH_AUTH_SOCK -deps = - pre-commit>=2,<3 - mypy==0.770 - pylint>=2.4,<3 +extras = pre-commit commands = pre-commit run --all-files --show-diff-on-failure python -c 'import pathlib;print("HINT: run \"\{\} install\" to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}")/"bin"/"pre-commit"))' @@ -91,6 +88,15 @@ commands = twine check dist/* +[testenv:dev] +skip_install = True +whitelist_externals = poetry +commands = + poetry install -E "testing pre-commit" + python -m pip list --format=columns + python -c "print('PYTHON INTERPRETER LOCATION: ' + r'{envpython}')" + + # -- TRAVIS CONFIG --------------------------------------------------------------------- [travis] python = From 0dc6689b2dbe4b7177638a79c4b021475c4fc922 Mon Sep 17 00:00:00 2001 From: Christian Riedel Date: Tue, 19 May 2020 20:43:08 +0200 Subject: [PATCH 18/44] added some tests --- tests/test_check_jira_tag.py | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/test_check_jira_tag.py b/tests/test_check_jira_tag.py index 4da6755..ff3e829 100755 --- a/tests/test_check_jira_tag.py +++ b/tests/test_check_jira_tag.py @@ -29,5 +29,41 @@ :copyright: (c) 2020 Christian Riedel :license: GPLv3, see LICENSE for more details """ +import configparser + +from pathlib import Path + import pytest -import commit_msg_jira_hook.check_jira_tag + +from click.testing import CliRunner + +from commit_msg_jira_hook.check_jira_tag import main + + +def test_missing_jira_url(): + runner = CliRunner() + result = runner.invoke(main, ["--jira-tag=TAG", "--verify", "TESTFILE"]) + assert result.exit_code == 1 + assert "Please provide '--jira-url'" in result.output + + +def test_missing_ini_file(monkeypatch): + monkeypatch.setattr(Path, "is_file", lambda _: False) + runner = CliRunner() + result = runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", "--verify", "TESTFILE"] + ) + assert result.exit_code == 1 + assert "No '~/.jira.ini' file found." in result.output + + +def test_missing_jira_section(monkeypatch): + monkeypatch.setattr(Path, "is_file", lambda _: True) + monkeypatch.setattr(configparser.ConfigParser, "read", lambda self, _: "") + # mock jira ini file + runner = CliRunner() + result = runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", "--verify", "TESTFILE"] + ) + assert result.exit_code == 1 + assert "No 'jira' section" in result.output From 1376d3acf06c8487f68c24d6e5390c579632e0d1 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Wed, 20 May 2020 11:45:17 +0200 Subject: [PATCH 19/44] fixed pylint error for ver 2.5.2 --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 91c3cef..3c4fc81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,6 +97,4 @@ source = [ # -- PYLINT CONFIG --------------------------------------------------------------------- [tool.pylint."MESSAGES CONTROL"] -disable = [ - "C0330", # Indentation | deactivated for black -] +disable = "C0330" # Indentation | deactivated for black From 30020855905e6e87169d7996e4bdf0c7f34d43cc Mon Sep 17 00:00:00 2001 From: Cielquan Date: Wed, 20 May 2020 11:47:22 +0200 Subject: [PATCH 20/44] made pre-commit install hint always appear - tox --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 79f4fae..74e28a2 100644 --- a/tox.ini +++ b/tox.ini @@ -35,6 +35,7 @@ description = format and check the code passenv = SSH_AUTH_SOCK extras = pre-commit +ignore_errors = True commands = pre-commit run --all-files --show-diff-on-failure python -c 'import pathlib;print("HINT: run \"\{\} install\" to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}")/"bin"/"pre-commit"))' From 0c32810915c0c4a3f9512f96f4e4b00f1b3fdc16 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Thu, 21 May 2020 09:30:38 +0200 Subject: [PATCH 21/44] fixed coverage config --- pyproject.toml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3c4fc81..64ce833 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ testing = ["pytest", "pytest-cov", "toml"] pre-commit = ["pre-commit", "mypy", "pylint"] [tool.poetry.scripts] -jira_commit_msg = "commit_msg_jira_hook.check_jira_tag:main" +jira_commit_msg = "commit_msg_jira_hook.commit_msg_jira_hook:main" # -- BLACK CONFIG ---------------------------------------------------------------------- @@ -53,7 +53,7 @@ multi_line_output = 3 include_trailing_comma = true lines_after_imports = 2 lines_between_types = 1 -known_first_party = ["check_jira_tag", "tests"] +known_first_party = ["commit_msg_jira_hook", "tests"] known_third_party = ["click", "jira", "pytest"] skip = ["venv"] @@ -86,12 +86,12 @@ omit = [ ] [tool.coverage.paths] source = [ - "src/color_space_visualizer", - "*/.tox/*/lib/python*/site-packages/color_space_visualizer", - "*/.tox/pypy*/site-packages/color_space_visualizer", - "*/.tox\\*\\Lib\\site-packages\\color_space_visualizer", - "*/src/color_space_visualizer", - "*\\src\\color_space_visualizer", + "src/commit_msg_jira_hook", + "*/.tox/*/lib/python*/site-packages/commit_msg_jira_hook", + "*/.tox/pypy*/site-packages/commit_msg_jira_hook", + "*/.tox\\*\\Lib\\site-packages\\commit_msg_jira_hook", + "*/src/commit_msg_jira_hook", + "*\\src\\commit_msg_jira_hook", ] From aeab82299627e6b6c0944952368e11eedb9df98c Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 11:49:12 +0200 Subject: [PATCH 22/44] changed config reading to use `ConfigParser.get()` --- commit_msg_jira_hook/check_jira_tag.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/commit_msg_jira_hook/check_jira_tag.py b/commit_msg_jira_hook/check_jira_tag.py index a66fbcf..3d9f8c7 100755 --- a/commit_msg_jira_hook/check_jira_tag.py +++ b/commit_msg_jira_hook/check_jira_tag.py @@ -38,7 +38,7 @@ import click -from jira import JIRA +from jira import JIRA # type: ignore from jira import exceptions as jira_exc @@ -81,17 +81,15 @@ def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str) jira_user_conf = configparser.ConfigParser() jira_user_conf.read(jira_user_conf_file) - #: Check for 'jira' section in ini file - if "jira" not in jira_user_conf: - click.echo("No 'jira' section found in '~/.jira.ini' file.") - ctx.abort() - #: Extract configs from ini file jira_user_conf_dict: Dict[str, str] = {} for config_key in ("JIRA_USERNAME", "JIRA_TOKEN"): try: - jira_user_conf_dict[config_key] = jira_user_conf["jira"][config_key] - except KeyError: + jira_user_conf_dict[config_key] = jira_user_conf.get("jira", config_key) + except configparser.NoSectionError: + click.echo("No 'jira' section found in '~/.jira.ini' file.") + ctx.abort() + except configparser.NoOptionError: click.echo(f"Missing '{config_key}' in '~/.jira.ini' file.") ctx.abort() @@ -114,12 +112,12 @@ def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str) ctx.abort() #: Check if tag has a number - if extract.group(2) is None: + if extract.group(2) is None: # type: ignore click.echo(f"'{jira_tag.upper()}' tag but no number found in commit message.") ctx.abort() #: Get tag from extract - issue = str(extract.group(0)) + issue = str(extract.group(0)) # type: ignore #: Exit with 0 when online check is disabled if not verify: @@ -150,4 +148,4 @@ def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str) if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) # pylint: disable=E1120 From 071d9c650d18d1bf05031aff360e9a14b59f1298 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 12:57:06 +0200 Subject: [PATCH 23/44] updatedd tox.ini to new std --- tox.ini | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 74e28a2..1e8eb22 100644 --- a/tox.ini +++ b/tox.ini @@ -74,12 +74,12 @@ commands = coverage xml -o {toxworkdir}/coverage.xml coverage html -d {toxworkdir}/htmlcov diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml -depends = - pytest +depends = py3{8,7,6} parallel_show_output = True [testenv:package] +description = check sdist and wheel skip_install = True deps = twine @@ -90,10 +90,13 @@ commands = [testenv:dev] +description = create dev env skip_install = True whitelist_externals = poetry commands = poetry install -E "testing pre-commit" + #: HACK: Create `_debug.pth` in venv site-packages assigning `devtools.debug()` to `__builtins__` + python -c "f=open(r'{envsitepackagesdir}'+'/_debug.pth','w');f.write('import devtools;__builtins__[\'debug\'] = devtools.debug\n');f.close()" python -m pip list --format=columns python -c "print('PYTHON INTERPRETER LOCATION: ' + r'{envpython}')" From 4d47188ee49479e19e7e122c4119e9b8882584d2 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:06:36 +0200 Subject: [PATCH 24/44] removed useless echo --- commit_msg_jira_hook/check_jira_tag.py | 1 - 1 file changed, 1 deletion(-) diff --git a/commit_msg_jira_hook/check_jira_tag.py b/commit_msg_jira_hook/check_jira_tag.py index 3d9f8c7..a05079e 100755 --- a/commit_msg_jira_hook/check_jira_tag.py +++ b/commit_msg_jira_hook/check_jira_tag.py @@ -96,7 +96,6 @@ def main(ctx, jira_tag: str, jira_url: str, verify: bool, commit_msg_file: str) #: Get commit msg with open(commit_msg_file) as cm_file: c_msg = cm_file.read() - click.echo(c_msg) #: Abort with empty commit-msg if c_msg == "": From 8846ff3284c397d820a8ef905a181c68b7465c06 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:31:09 +0200 Subject: [PATCH 25/44] updated dev deps --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 64ce833..c0e39f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ mypy = {version = "0.770", optional = true} pylint = {version = "^2.4", optional = true} [tool.poetry.dev-dependencies] -devtools = "^0.5.1" +devtools = {version = "^0.5", extras = ["pygments"]} [tool.poetry.extras] testing = ["pytest", "pytest-cov", "toml"] From cef1540c7622f7149a1b07e80f22337fa5638822 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:36:40 +0200 Subject: [PATCH 26/44] added more tests --- tests/test_check_jira_tag.py | 164 ++++++++++++++++++++++++++++++----- 1 file changed, 144 insertions(+), 20 deletions(-) diff --git a/tests/test_check_jira_tag.py b/tests/test_check_jira_tag.py index ff3e829..2e8c95e 100755 --- a/tests/test_check_jira_tag.py +++ b/tests/test_check_jira_tag.py @@ -29,41 +29,165 @@ :copyright: (c) 2020 Christian Riedel :license: GPLv3, see LICENSE for more details """ -import configparser - +# pylint: disable=W0613,W0621 from pathlib import Path -import pytest +import pytest # type: ignore from click.testing import CliRunner +from jira import JIRA # type: ignore +from jira import exceptions as jira_exc from commit_msg_jira_hook.check_jira_tag import main -def test_missing_jira_url(): - runner = CliRunner() - result = runner.invoke(main, ["--jira-tag=TAG", "--verify", "TESTFILE"]) +@pytest.fixture +def cli_runner(): + """Yield click cli test runner""" + yield CliRunner() + + +@pytest.fixture +def mock_home(monkeypatch, tmp_path): + """Yield `home` dir mock path""" + home = tmp_path / "~" + home.mkdir() + monkeypatch.setattr(Path, "home", lambda: home) + yield home + + +@pytest.fixture +def mock_ini(mock_home): + """Yield '.jira.ini' mock path in `home` dir mock""" + ini = mock_home / ".jira.ini" + ini.write_text("[jira]\nJIRA_USERNAME=USERNAME\nJIRA_TOKEN=TOKEN\n") + yield ini + + +@pytest.fixture +def mock_commit_msg_file(mock_home): + """Yield 'COMMIT_MSG' path in `home` dir mock""" + commit_msg_file = mock_home / "COMMIT_MSG" + yield commit_msg_file + + +def test_missing_jira_url(cli_runner): + """Assert error on missing jira-url when `--verify`""" + result = cli_runner.invoke(main, ["--jira-tag=TAG", "--verify", "NO_FILE"]) assert result.exit_code == 1 assert "Please provide '--jira-url'" in result.output -def test_missing_ini_file(monkeypatch): - monkeypatch.setattr(Path, "is_file", lambda _: False) - runner = CliRunner() - result = runner.invoke( - main, ["--jira-tag=TAG", "--jira-url=URL", "--verify", "TESTFILE"] - ) +def test_missing_ini_file(mock_home, cli_runner): + """Assert error on missing '~/.jira.ini' file""" + result = cli_runner.invoke(main, ["--jira-tag=TAG", "--jira-url=URL", "NO_FILE"]) assert result.exit_code == 1 assert "No '~/.jira.ini' file found." in result.output -def test_missing_jira_section(monkeypatch): - monkeypatch.setattr(Path, "is_file", lambda _: True) - monkeypatch.setattr(configparser.ConfigParser, "read", lambda self, _: "") - # mock jira ini file - runner = CliRunner() - result = runner.invoke( - main, ["--jira-tag=TAG", "--jira-url=URL", "--verify", "TESTFILE"] - ) +def test_missing_jira_section(mock_home, cli_runner): + """Assert error on missing 'jira' section in '~/.jira.ini' file""" + mock_ini = mock_home / ".jira.ini" + mock_ini.write_text("") + + result = cli_runner.invoke(main, ["--jira-tag=TAG", "--jira-url=URL", "NO_FILE"]) assert result.exit_code == 1 assert "No 'jira' section" in result.output + + +def test_missing_conf_key(mock_home, cli_runner): + """Assert error on missing conf key in 'jira' section""" + mock_ini = mock_home / ".jira.ini" + mock_ini.write_text("[jira]\nJIRA_USERNAME=USERNAME\n") + + result = cli_runner.invoke(main, ["--jira-tag=TAG", "--jira-url=URL", "NO_FILE"]) + + assert result.exit_code == 1 + assert "Missing 'JIRA_TOKEN'" in result.output + + +def test_empty_commit_msg(mock_ini, mock_commit_msg_file, cli_runner): + """Assert error on empty commit msg""" + mock_commit_msg_file.write_text("") + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 1 + assert "Commit message is empty." in result.output + + +@pytest.mark.parametrize("commit_msg", ["message", "tag", "tag-", "#tag", "#tag-123"]) +def test_missing_tag(commit_msg, mock_ini, mock_commit_msg_file, cli_runner): + """Assert error on missing tag""" + mock_commit_msg_file.write_text(commit_msg) + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 1 + assert "'TAG' tag not found" in result.output + + +@pytest.mark.parametrize("commit_msg", ["TAG", "TAG-", "#TAG", "#TAG-"]) +def test_missing_tag_number(commit_msg, mock_ini, mock_commit_msg_file, cli_runner): + """Assert error on missing tag number""" + mock_commit_msg_file.write_text(commit_msg) + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 1 + assert "'TAG' tag but no number" in result.output + + +def test_jira_error(mock_ini, mock_commit_msg_file, monkeypatch, cli_runner): + """Assert error on jira api login""" + mock_commit_msg_file.write_text("TAG-123") + + def mock_init(*args, **kwargs): + raise jira_exc.JIRAError() + + monkeypatch.setattr(JIRA, "__init__", mock_init) + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 1 + assert "Error connecting to jira." in result.output + + +def test_jira_issue_error(mock_ini, mock_commit_msg_file, monkeypatch, cli_runner): + """Assert error on jira issue api call""" + mock_commit_msg_file.write_text("TAG-123") + + def mock_init(*args, **kwargs): + pass + + def mock_issue(*args, **kwargs): + raise jira_exc.JIRAError() + + monkeypatch.setattr(JIRA, "__init__", mock_init) + monkeypatch.setattr(JIRA, "issue", mock_issue) + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--jira-url=URL", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 1 + assert "TAG-123 does not exist or no permission" in result.output + + +def test_no_verify(mock_ini, mock_commit_msg_file, cli_runner): + """Assert no error on --no-verify""" + mock_commit_msg_file.write_text("TAG-123") + + result = cli_runner.invoke( + main, ["--jira-tag=TAG", "--no-verify", str(mock_commit_msg_file)] + ) + + assert result.exit_code == 0 From 0d2f21264a6abcb06697a8e7fa75171881af31cf Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:43:22 +0200 Subject: [PATCH 27/44] updated pre-commit-config with new tool runner script --- .pre-commit-config.yaml | 11 +++----- .pre-commit-scripts/run_mypy | 21 --------------- .pre-commit-scripts/run_pylint | 21 --------------- .pre_commit_tool_runner | 47 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 50 deletions(-) delete mode 100755 .pre-commit-scripts/run_mypy delete mode 100755 .pre-commit-scripts/run_pylint create mode 100755 .pre_commit_tool_runner diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 58197e3..ee1cf39 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -79,7 +79,7 @@ repos: # rev: 1.6.2 # hooks: # - id: bandit -# args: ["--exclude ./.tox/*,./.eggs/*,./tests/*"] +# args: ["--exclude ./.tox/*,./venv/*,./.eggs/*,./tests/*"] #: flake8 - python linter - repo: https://gitlab.com/pycqa/flake8 @@ -150,21 +150,16 @@ repos: #: pylint - python linter - id: pylint name: pylint - entry: ./.pre-commit-scripts/run_pylint + entry: ./.pre_commit_tool_runner pylint pre-commit,dev language: system types: [python] #: mypy - python type checker - id: mypy args: ["--warn-unused-ignores"] # , --scripts-are-modules, --ignore-missing-imports] name: mypy - entry: ./.pre-commit-scripts/run_mypy + entry: ./.pre_commit_tool_runner mypy pre-commit,dev language: system types: [python] - exclude: > - (?x)^( - setup.py| - docs/source/conf.py - )$ #: Meta hooks diff --git a/.pre-commit-scripts/run_mypy b/.pre-commit-scripts/run_mypy deleted file mode 100755 index 7d3efcb..0000000 --- a/.pre-commit-scripts/run_mypy +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -"""Script to call local installation of `mypy`. - -Script considers OS and calls mypy accordingly. -""" - -import subprocess -import sys - - -def main(): - """Call mypy""" - if sys.platform == "win32": - cmd = (".tox/pre-commit/Scripts/mypy.exe", *sys.argv[1:]) - else: - cmd = (".tox/pre-commit/bin/mypy", *sys.argv[1:]) - return subprocess.call(cmd) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/.pre-commit-scripts/run_pylint b/.pre-commit-scripts/run_pylint deleted file mode 100755 index 4ec4ca8..0000000 --- a/.pre-commit-scripts/run_pylint +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -"""Script to call local installation of `pylint`. - -Script considers OS and calls pylint accordingly. -""" - -import subprocess -import sys - - -def main(): - """Call pylint""" - if sys.platform == "win32": - cmd = (".tox/pre-commit/Scripts/pylint.exe", *sys.argv[1:]) - else: - cmd = (".tox/pre-commit/bin/pylint", *sys.argv[1:]) - return subprocess.call(cmd) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/.pre_commit_tool_runner b/.pre_commit_tool_runner new file mode 100755 index 0000000..6fbe289 --- /dev/null +++ b/.pre_commit_tool_runner @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +"""Script to call executables in `tox` envs + +The script takes two mandatory arguments: +1. the executable to call like e.g. `pylint` +2. a string with comma separated `tox` envs to check for the executable + +All other arguments after are passed to the tool on call. + +The script considers OS and calls the tool accordingly. +""" +import subprocess +import sys + +from pathlib import Path + + +def main(): + """Call given `tool` form given `tox` env""" + tool = sys.argv[1] + + if sys.platform == "win32": + exe = Path("Scripts/" + tool + ".exe") + else: + exe = Path("bin/" + tool) + + tox = Path(".tox") + envs = sys.argv[2].split(",") + + cmd = None + for env in envs: + path = Path(tox / env / exe) + if path.is_file(): + cmd = (str(path), *sys.argv[3:]) + + if cmd is None: + print( + "No '{}' executable found. Make sure one of the " + "following `tox` envs is accessible: {}".format(tool, envs) + ) + return 1 + + return subprocess.call(cmd) + + +if __name__ == "__main__": + sys.exit(main()) From 6071939c69199ffc3d585117452211911bf1ee3a Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:49:24 +0200 Subject: [PATCH 28/44] updated codecov config --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index a969a76..d915d2b 100644 --- a/codecov.yml +++ b/codecov.yml @@ -4,4 +4,4 @@ codecov: coverage: precision: 2 round: down - range: "90...100" + range: "100" From 1c91521c8b3f642593fd6385fd8ae43d80866f9e Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:50:08 +0200 Subject: [PATCH 29/44] added issue template --- .github/ISSUE_TEMPLATE.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5974836 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,16 @@ +* commit-msg-jira-hook version: +* Python version: +* Operating System: +* [ ] I check open and closed issues. + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` From ca9780b8993d8af4788f7a36b549d679bcf8029d Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 14:51:34 +0200 Subject: [PATCH 30/44] moved source into src dir --- {commit_msg_jira_hook => src/commit_msg_jira_hook}/__init__.py | 0 .../commit_msg_jira_hook}/check_jira_tag.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {commit_msg_jira_hook => src/commit_msg_jira_hook}/__init__.py (100%) rename {commit_msg_jira_hook => src/commit_msg_jira_hook}/check_jira_tag.py (100%) diff --git a/commit_msg_jira_hook/__init__.py b/src/commit_msg_jira_hook/__init__.py similarity index 100% rename from commit_msg_jira_hook/__init__.py rename to src/commit_msg_jira_hook/__init__.py diff --git a/commit_msg_jira_hook/check_jira_tag.py b/src/commit_msg_jira_hook/check_jira_tag.py similarity index 100% rename from commit_msg_jira_hook/check_jira_tag.py rename to src/commit_msg_jira_hook/check_jira_tag.py From 1bfb104934f32aa65d8334bf8e5fd9c430b805d8 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:01:37 +0200 Subject: [PATCH 31/44] added __version__ to root-__init__ --- pyproject.toml | 1 + src/commit_msg_jira_hook/__init__.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c0e39f5..36d44f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ readme = "README.rst" [tool.poetry.dependencies] python = "^3.6.1" +importlib-metadata = {version = "^1.6", python = "<3.8"} jira = "^2.0.0" click = "^7.1.2" pytest = {version = "^5.4.2", optional = true} diff --git a/src/commit_msg_jira_hook/__init__.py b/src/commit_msg_jira_hook/__init__.py index 9fc4e0f..8fcbd33 100644 --- a/src/commit_msg_jira_hook/__init__.py +++ b/src/commit_msg_jira_hook/__init__.py @@ -27,3 +27,12 @@ :copyright: (c) 2020 Christian Riedel :license: GPLv3, see LICENSE for more details """ +try: + from importlib.metadata import version +except ModuleNotFoundError: + from importlib_metadata import version # type: ignore + +try: + __version__ = version(__name__) +except Exception: # pylint: disable=W0703 + pass From ded665d861f9247157e4cac209ad55145752718d Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:04:20 +0200 Subject: [PATCH 32/44] indented pyproject.toml --- pyproject.toml | 143 +++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 36d44f2..2f51e4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,101 +1,102 @@ [build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" + requires = ["poetry>=0.12"] + build-backend = "poetry.masonry.api" # -- POETRY CONFIG --------------------------------------------------------------------- [tool.poetry] -name = "commit-msg-jira-hook" -version = "0.6.0" -description = "commit-msg hook for jira issue verification with pre-commit." -authors = ["Cielquan "] -license = "GPL-3.0-or-later" -keywords = ["pre-commit", "hook", "git", "commit-msg"] -classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Topic :: Software Development :: Version Control :: Git", -] -repository = "https://github.com/Cielquan/commit-msg-jira-hook" -readme = "README.rst" + name = "commit-msg-jira-hook" + version = "0.6.0" + description = "commit-msg hook for jira issue verification with pre-commit." + authors = ["Cielquan "] + license = "GPL-3.0-or-later" + keywords = ["pre-commit", "hook", "git", "commit-msg"] + classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Software Development :: Version Control :: Git", + ] + repository = "https://github.com/Cielquan/commit-msg-jira-hook" + readme = "README.rst" [tool.poetry.dependencies] -python = "^3.6.1" -importlib-metadata = {version = "^1.6", python = "<3.8"} -jira = "^2.0.0" -click = "^7.1.2" -pytest = {version = "^5.4.2", optional = true} -pytest-cov = {version = "^2.8.1", optional = true} -toml = {version = "^0.10.1", optional = true} -pre-commit = {version = "^2.4", optional = true} -mypy = {version = "0.770", optional = true} -pylint = {version = "^2.4", optional = true} + python = "^3.6.1" + importlib-metadata = {version = "^1.6", python = "<3.8"} + jira = "^2.0.0" + click = "^7.1.2" + pytest = {version = "^5.4.2", optional = true} + pytest-cov = {version = "^2.8.1", optional = true} + toml = {version = "^0.10.1", optional = true} + pre-commit = {version = "^2.4", optional = true} + mypy = {version = "0.770", optional = true} + pylint = {version = "^2.4", optional = true} -[tool.poetry.dev-dependencies] -devtools = {version = "^0.5", extras = ["pygments"]} + [tool.poetry.dev-dependencies] + devtools = {version = "^0.5", extras = ["pygments"]} -[tool.poetry.extras] -testing = ["pytest", "pytest-cov", "toml"] -pre-commit = ["pre-commit", "mypy", "pylint"] + [tool.poetry.extras] + testing = ["pytest", "pytest-cov", "toml"] + pre-commit = ["pre-commit", "mypy", "pylint"] -[tool.poetry.scripts] -jira_commit_msg = "commit_msg_jira_hook.commit_msg_jira_hook:main" + [tool.poetry.scripts] + jira_commit_msg = "commit_msg_jira_hook.commit_msg_jira_hook:main" # -- BLACK CONFIG ---------------------------------------------------------------------- [tool.black] -line-length = 88 -exclude = "venv/" + line-length = 88 + exclude = "venv/" # -- ISORT CONFIG ---------------------------------------------------------------------- [tool.isort] -multi_line_output = 3 -include_trailing_comma = true -lines_after_imports = 2 -lines_between_types = 1 + multi_line_output = 3 + include_trailing_comma = true + lines_after_imports = 2 + lines_between_types = 1 + skip = ["venv"] known_first_party = ["commit_msg_jira_hook", "tests"] known_third_party = ["click", "jira", "pytest"] -skip = ["venv"] + # -- COVERAGE CONFIG ------------------------------------------------------------------- [tool.coverage.run] -branch = true -parallel = true -source = ["src/"] + branch = true + parallel = true + source = ["src/"] [tool.coverage.report] -fail_under = 100 -skip_covered = false -show_missing = true -exclude_lines = [ - "pragma: no cover", - "def __str__", - "def __repr__", - "if self.debug:", - "if settings.DEBUG", - "raise AssertionError", - "raise NotImplementedError", - "if 0:", - "if __name__ == .__main__.:", -] -omit = [ - "venv/*", - "tests/*", - "setup.py", - "*/__main__.py", -] + fail_under = 100 + skip_covered = false + show_missing = true + exclude_lines = [ + "pragma: no cover", + "def __str__", + "def __repr__", + "if self.debug:", + "if settings.DEBUG", + "raise AssertionError", + "raise NotImplementedError", + "if 0:", + "if __name__ == .__main__.:", + ] + omit = [ + "venv/*", + "tests/*", + "setup.py", + "*/__main__.py", + ] [tool.coverage.paths] -source = [ - "src/commit_msg_jira_hook", - "*/.tox/*/lib/python*/site-packages/commit_msg_jira_hook", - "*/.tox/pypy*/site-packages/commit_msg_jira_hook", - "*/.tox\\*\\Lib\\site-packages\\commit_msg_jira_hook", - "*/src/commit_msg_jira_hook", - "*\\src\\commit_msg_jira_hook", -] + source = [ + "src/commit_msg_jira_hook", + "*/.tox/*/lib/python*/site-packages/commit_msg_jira_hook", + "*/.tox/pypy*/site-packages/commit_msg_jira_hook", + "*/.tox\\*\\Lib\\site-packages\\commit_msg_jira_hook", + "*/src/commit_msg_jira_hook", + "*\\src\\commit_msg_jira_hook", + ] # -- PYLINT CONFIG --------------------------------------------------------------------- [tool.pylint."MESSAGES CONTROL"] -disable = "C0330" # Indentation | deactivated for black + disable = "C0330" # Indentation | deactivated for black From 5203708ec31167d049faa226d918859c0e14b225 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:05:55 +0200 Subject: [PATCH 33/44] added package conf to poetry --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2f51e4d..96f8b8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,9 @@ ] repository = "https://github.com/Cielquan/commit-msg-jira-hook" readme = "README.rst" + packages = [ + { include = "commit_msg_jira_hook", from = "src" }, + ] [tool.poetry.dependencies] python = "^3.6.1" From ebdda3b992bd661a6fa746fd4a798cec950e4c20 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:21:34 +0200 Subject: [PATCH 34/44] fixed __version__ --- src/commit_msg_jira_hook/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/commit_msg_jira_hook/__init__.py b/src/commit_msg_jira_hook/__init__.py index 8fcbd33..8a3fc75 100644 --- a/src/commit_msg_jira_hook/__init__.py +++ b/src/commit_msg_jira_hook/__init__.py @@ -32,7 +32,4 @@ except ModuleNotFoundError: from importlib_metadata import version # type: ignore -try: - __version__ = version(__name__) -except Exception: # pylint: disable=W0703 - pass +__version__ = version(__name__) From 710fc8b1f4ba2f19121ccdac9083caff34bcd454 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:22:49 +0200 Subject: [PATCH 35/44] fixed tox tests --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 1e8eb22..0def2dd 100644 --- a/tox.ini +++ b/tox.ini @@ -54,6 +54,7 @@ commands = pytest \ --basetemp="{envtmpdir}" \ --cov "{envsitepackagesdir}/commit_msg_jira_hook" \ + --cov-fail-under 0 \ {posargs:tests} From 27b84e28f719cf0556cffe93b9a74d2fa57f2b45 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:33:14 +0200 Subject: [PATCH 36/44] added towncrier conf --- docs/.changes/template.jinja2 | 35 +++++++++++++++++++++++++++ pyproject.toml | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 docs/.changes/template.jinja2 diff --git a/docs/.changes/template.jinja2 b/docs/.changes/template.jinja2 new file mode 100644 index 0000000..ff23c1b --- /dev/null +++ b/docs/.changes/template.jinja2 @@ -0,0 +1,35 @@ +{% for section, _ in sections.items() %} +{% set underline = underlines[0] %}{% if section %}{{section}} +{{ underline * section|length }}{% set underline = underlines[1] %} + +{% endif %} + +{% if sections[section] %} +{% for category, val in definitions.items() if category in sections[section]%} +{{ definitions[category]['name'] }} +{{ underline * definitions[category]['name']|length }} + +{% if definitions[category]['showcontent'] %} +{% for text, values in sections[section][category].items() %} +- {{ text }} + {{ values|join(', ') }} +{% endfor %} + +{% else %} +- {{ sections[section][category]['']|join(', ') }} + +{% endif %} +{% if sections[section][category]|length == 0 %} +No significant changes. + +{% else %} +{% endif %} + +{% endfor %} +{% else %} +No significant changes. + + +{% endif %} +{% endfor %} +---- diff --git a/pyproject.toml b/pyproject.toml index 96f8b8a..ee14bce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ [tool.poetry.dev-dependencies] devtools = {version = "^0.5", extras = ["pygments"]} + towncrier = {version = "19.9.0rc1"} [tool.poetry.extras] testing = ["pytest", "pytest-cov", "toml"] @@ -45,6 +46,50 @@ jira_commit_msg = "commit_msg_jira_hook.commit_msg_jira_hook:main" +# -- TOWNCRIER CONFIG ---------------------------------------------------------------------- +[tool.towncrier] + package = "commit_msg_jira_hook" + package_dir = "src" + filename = "CHANGELOG.rst" + directory = "docs/.changes" + template = "docs/.changes/template.jinja2" + title_format = "v{version} ({project_date})" + issue_format = "`#{issue} `_" + underlines = ["-", "~"] + wrap = false # Wrap text to 79 characters + all_bullets = true # make all fragments bullet points + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bugfixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "feature" + name = "New Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "breaking" + name = "Backwards incompatible changes" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations (removal in next major release)" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "misc" + name = "Miscellaneous" + showcontent = true + + # -- BLACK CONFIG ---------------------------------------------------------------------- [tool.black] line-length = 88 From 45519334836905def4e4daa3cb6f5b5bc04e5929 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 15:40:12 +0200 Subject: [PATCH 37/44] added badge to readme --- README.rst | 95 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 22 deletions(-) diff --git a/README.rst b/README.rst index b210f2f..6fe0ab5 100644 --- a/README.rst +++ b/README.rst @@ -2,11 +2,19 @@ commit-msg-jira-hook ==================== -| |maintenance| |license| |black| -| -| |release| |commits_since| |last_commit| -| |stars| |forks| |contributors| -| ++---------------+----------------------------------------------------------------------+ +| **General** | |maintenance| |license| |black| | ++---------------+----------------------------------------------------------------------+ +| **Pipeline** | |travis| |codecov| | ++---------------+----------------------------------------------------------------------+ +| **Tools** | |poetry| |tox| |pytest| | ++---------------+----------------------------------------------------------------------+ +| **VC** | |vcs| |gpg| |semver| |pre-commit| | ++---------------+----------------------------------------------------------------------+ +| **Github** | |gh_release| |gh_commits_since| |gh_last_commit| | +| +----------------------------------------------------------------------+ +| | |gh_stars| |gh_forks| |gh_contributors| |gh_watchers| | ++---------------+----------------------------------------------------------------------+ commit-msg hook for pre-commit to verify jira issues in commit messages. @@ -71,45 +79,88 @@ but I cannot promise a quick response time. .. .############################### LINKS ############################### -.. BADGES START .. General .. |maintenance| image:: https://img.shields.io/badge/No%20Maintenance%20Intended-X-red.svg?style=flat-square :target: http://unmaintained.tech/ :alt: Maintenance - not intended -.. |license| image:: https://img.shields.io/github/license/Cielquan/commit-msg-jira-hook.svg?style=flat-square +.. |license| image:: https://img.shields.io/github/license/Cielquan/commit-msg-jira-hook.svg?style=flat-square&label=License :alt: License :target: https://github.com/Cielquan/commit-msg-jira-hook/blob/master/LICENSE.rst -.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square - :alt: Code Style: Black +.. |black| image:: https://img.shields.io/badge/Code%20Style-black-000000.svg?style=flat-square + :alt: Code Style - Black :target: https://github.com/psf/black +.. Pipeline +.. |travis| image:: https://img.shields.io/travis/com/Cielquan/commit-msg-jira-hook/master.svg?style=flat-square&logo=travis-ci&logoColor=FBE072 + :alt: Travis - Build Status + :target: https://travis-ci.com/Cielquan/commit-msg-jira-hook + +.. |codecov| image:: https://img.shields.io/codecov/c/github/Cielquan/commit-msg-jira-hook/master.svg?style=flat-square&logo=codecov + :alt: Codecov - Test Coverage + :target: https://codecov.io/gh/Cielquan/commit-msg-jira-hook + + +.. Tools +.. |poetry| image:: https://img.shields.io/badge/Packaging-poetry-brightgreen.svg?style=flat-square + :target: https://python-poetry.org/ + :alt: Poetry + +.. |tox| image:: https://img.shields.io/badge/Automation-tox-brightgreen.svg?style=flat-square + :target: https://tox.readthedocs.io/en/latest/ + :alt: tox + +.. |pytest| image:: https://img.shields.io/badge/Test%20framework-pytest-brightgreen.svg?style=flat-square + :target: https://docs.pytest.org/en/latest/ + :alt: Pytest + + +.. VC +.. |vcs| image:: https://img.shields.io/badge/VCS-git-orange.svg?style=flat-square&logo=git + :target: https://git-scm.com/ + :alt: VCS + +.. |gpg| image:: https://img.shields.io/badge/GPG-signed-blue.svg?style=flat-square&logo=gnu-privacy-guard + :target: https://gnupg.org/ + :alt: Website + +.. |semver| image:: https://img.shields.io/badge/Versioning-semantic-brightgreen.svg?style=flat-square + :alt: Versioning - semantic + :target: https://semver.org/ + +.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=flat-square&logo=pre-commit&logoColor=yellow + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit + + .. Github -.. |release| image:: https://img.shields.io/github/v/release/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github - :alt: Github Latest Release +.. |gh_release| image:: https://img.shields.io/github/v/release/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Latest Release :target: https://github.com/Cielquan/commit-msg-jira-hook/releases/latest -.. |commits_since| image:: https://img.shields.io/github/commits-since/Cielquan/commit-msg-jira-hook/latest.svg?style=flat-square&logo=github - :alt: GitHub commits since latest release +.. |gh_commits_since| image:: https://img.shields.io/github/commits-since/Cielquan/commit-msg-jira-hook/latest.svg?style=flat-square&logo=github + :alt: Github - Commits since latest release :target: https://github.com/Cielquan/commit-msg-jira-hook/commits/master -.. |last_commit| image:: https://img.shields.io/github/last-commit/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github - :alt: GitHub last commit +.. |gh_last_commit| image:: https://img.shields.io/github/last-commit/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Last Commit :target: https://github.com/Cielquan/commit-msg-jira-hook/commits/master -.. |stars| image:: https://img.shields.io/github/stars/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github - :alt: Github stars +.. |gh_stars| image:: https://img.shields.io/github/stars/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Stars :target: https://github.com/Cielquan/commit-msg-jira-hook/stargazers -.. |forks| image:: https://img.shields.io/github/forks/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github - :alt: Github forks +.. |gh_forks| image:: https://img.shields.io/github/forks/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Forks :target: https://github.com/Cielquan/commit-msg-jira-hook/network/members -.. |contributors| image:: https://img.shields.io/github/contributors/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github - :alt: Github Contributors +.. |gh_contributors| image:: https://img.shields.io/github/contributors/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Contributors :target: https://github.com/Cielquan/commit-msg-jira-hook/graphs/contributors -.. BADGES END +.. |gh_watchers| image:: https://img.shields.io/github/watchers/Cielquan/commit-msg-jira-hook.svg?style=flat-square&logo=github + :alt: Github - Watchers + :target: https://github.com/Cielquan/commit-msg-jira-hook/watchers From 640c669773e966eab1bcd86f0f532dea2d600069 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:11:52 +0200 Subject: [PATCH 38/44] shortend towncrier type names --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ee14bce..03eb5c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ showcontent = true [[tool.towncrier.type]] - directory = "feature" + directory = "feat" name = "New Features" showcontent = true @@ -75,7 +75,7 @@ showcontent = true [[tool.towncrier.type]] - directory = "deprecation" + directory = "depr" name = "Deprecations (removal in next major release)" showcontent = true From e36861a51f0e163f9b76a03727008607ccd37bbe Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:16:40 +0200 Subject: [PATCH 39/44] fixed towncrier conf --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 03eb5c6..6ee3344 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ directory = "docs/.changes" template = "docs/.changes/template.jinja2" title_format = "v{version} ({project_date})" - issue_format = "`#{issue} `_" + issue_format = "`#{issue} `_" underlines = ["-", "~"] wrap = false # Wrap text to 79 characters all_bullets = true # make all fragments bullet points From bb14dd27f26db4a6ba01debbccdc7aa58a745f53 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:17:44 +0200 Subject: [PATCH 40/44] rewrote changelog --- CHANGELOG.rst | 65 +++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6883721..3eff0f6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,67 +5,54 @@ commit-msg-jira-hook Change Log Version numbers follow the `SemVer `__ principle. See the `tags on this repository `__ for all available versions. -.. note:: - Not all commits are linked. Commits are only linked when they match the specific note. - -.. _changelog: +.. towncrier release notes start -.. _changelog_060: -Release 0.6.0 -------------- -*Released: 19.05.2020* - -- Switched from ``setuptools`` to ``poetry`` (`commit `__) -- Updated Readme +.. note:: + Release notes below were written by hand prior usage of ``towncrier``. -.. _changelog_050: -Release 0.5.0 -------------- -*Released: 11.05.2020* +v0.6.0 (19.05.2020) +------------------- -- Added "--verify" switch (issue #1) (`commit `__) -- Improved error message for missing tag or tag-number (issue #2) (`commit `__) -- Fixed link in changelog for v0.4.0 (`commit `__) +- Switched from ``setuptools`` to ``poetry`` - Updated Readme -.. _changelog_040: +v0.5.0 (11.05.2020) +------------------- -Release 0.4.0 -------------- -*Released: 25.04.2020* - -- Rewrote script as click command (`commit `__) +- Added "--verify" switch + `#1 `_ +- Improved error message for missing tag or tag-number + `#2 `_ +- Fixed link in changelog for v0.4.0 - Updated Readme -.. _changelog_030: +v0.4.0 (25.04.2020) +------------------- -Release 0.3.0 -------------- -*Released: 05.03.2020* +- Rewrote script as click command +- Updated Readme -- Improved output for missing keys in ini files (`commit `__) -- Fixed CHANGELOG.rst +v0.3.0 (05.03.2020) +------------------- -.. _changelog_020: +- Improved output for missing keys in ini files +- Fixed CHANGELOG.rst -Release 0.2.0 -------------- -*Released: 06.02.2020* -- Split content of jira.ini file into two files (`commit `__) +v0.2.0 (06.02.2020) +------------------- +- Split content of jira.ini file into two files -.. _changelog__010: -Release 0.1.0 -------------- -*Released: 05.02.2020* +v0.1.0 (05.02.2020) +------------------- - Initial release From 4152e756d422d00fcdfc5a07e23aff2e5df8f4ea Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:19:50 +0200 Subject: [PATCH 41/44] bump ver to 0.6.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6ee3344..f8d6d71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ # -- POETRY CONFIG --------------------------------------------------------------------- [tool.poetry] name = "commit-msg-jira-hook" - version = "0.6.0" + version = "0.6.1" description = "commit-msg hook for jira issue verification with pre-commit." authors = ["Cielquan "] license = "GPL-3.0-or-later" From 8ec1e199f9217b8df7c8f613e3302a5e8bd8fd2b Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:21:17 +0200 Subject: [PATCH 42/44] updated changelog v0.6.1 --- CHANGELOG.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3eff0f6..efc932b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,25 @@ commit-msg-jira-hook Change Log .. towncrier release notes start +v0.6.1 (2020-05-22) +------------------- + +Miscellaneous +~~~~~~~~~~~~~ + +- Added `pytest` tests with 100% coverage + `#3 `_ +- Added cielquan's default `pre-commit` config + `#4 `_ +- Added test automation with `tox` + `#5 `_ +- Added CI config to run `tox` in a pipeline + `#6 `_ +- Added `towncrier` for changelog updates + `#7 `_ + +---- .. note:: From 0c94fcfcc0122857acf225660d642a1aabc74b9a Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:38:49 +0200 Subject: [PATCH 43/44] pipeline fix - added testing extras to pre-commit - tox --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 0def2dd..5540551 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,9 @@ download = True description = format and check the code passenv = SSH_AUTH_SOCK -extras = pre-commit +extras = + pre-commit + testing ignore_errors = True commands = pre-commit run --all-files --show-diff-on-failure From 38af60a7e3e793834e1d475e1a1475b46d7f4da3 Mon Sep 17 00:00:00 2001 From: Cielquan Date: Fri, 22 May 2020 16:43:47 +0200 Subject: [PATCH 44/44] CI fix - removed setup-cfg-fmt hook & moved pre-commit tox to py3.8 --- .pre-commit-config.yaml | 8 -------- tox.ini | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee1cf39..e632111 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,14 +29,6 @@ repos: - id: python-no-log-warn - id: python-no-eval - #: setup-cfg-fmt - format python setup.cfg - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.9.0 - hooks: - - id: setup-cfg-fmt - #: C/C++-Extensions make problems with py38 on win - here: "editdistance" - language_version: python3.7 - #: pyupgrade - upgrade old python syntax to new - repo: https://github.com/asottile/pyupgrade rev: v2.4.1 diff --git a/tox.ini b/tox.ini index 5540551..87bc13a 100644 --- a/tox.ini +++ b/tox.ini @@ -108,8 +108,8 @@ commands = [travis] python = 3.6: py36 - 3.7: py37, pre-commit - 3.8: py38, bandit, package + 3.7: py37 + 3.8: py38, bandit, package, pre-commit # -- PYTEST CONFIG ---------------------------------------------------------------------