[project]
name = "greenbone-feed-sync"
version = "25.1.3.dev1"
description = "A tool for downloading the Greenbone Community Feed"
authors = [
  {name = "Björn Ricks", email = "bjoern.ricks@greenbone.net"}
]
license = "GPL-3.0-or-later"
readme = "README.md"

[tool.poetry]
name = "greenbone-feed-sync"
version = "25.1.4.dev1"
description = "A tool for downloading the Greenbone Community Feed"
authors = ["Björn Ricks <bjoern.ricks@greenbone.net>"]
license = "GPL-3.0-or-later"
readme = "README.md"

classifiers = [
  # Full list: https://pypi.org/pypi?%3Aaction=list_classifiers
  "Development Status :: 5 - Production/Stable",
  "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", # pylint: disable=line-too-long
  "Environment :: Console",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Operating System :: OS Independent",
  "Topic :: Utilities",
]

packages = [
  { include = "greenbone" },
  { include = "tests", format = "sdist" },
  { include = "poetry.lock", format = "sdist" },
]

[tool.poetry.dependencies]
python = "^3.9"
rich = ">=13.2.0"
tomli = { version = ">=2.0.1", python = "<3.11" }
shtab = ">=1.6.5"

[tool.poetry.group.dev.dependencies]
autohooks-plugin-black = ">=22.11.0"
autohooks-plugin-ruff = ">=23.6.0"
autohooks-plugin-mypy = ">=23.3.0"
pontos = ">=22.12.2"
coverage = { extras = ["toml"], version = ">=7.1.0" }
git-cliff = "^2.8.0"

[tool.poetry.scripts]
greenbone-feed-sync = 'greenbone.feed.sync.main:main'
greenbone-nvt-sync = 'greenbone.feed.sync.main:main'
greenbone-scapdata-sync = 'greenbone.feed.sync.main:main'
greenbone-certdata-sync = 'greenbone.feed.sync.main:main'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 80
target-version = ['py39', 'py310', 'py311', 'py312']
exclude = '''
/(
    \.git
  | \.venv
  | \.github
  | \.vscode
  | _build
  | build
  | dist
  | docs
)/
'''

[tool.autohooks]
pre-commit = [
  'autohooks.plugins.black',
  'autohooks.plugins.ruff',
  'autohooks.plugins.mypy',
]
mode = "poetry"

[tool.pontos.version]
version-module-file = "greenbone/feed/sync/__version__.py"

[tool.isort]
profile = "black"
line_length = 80

[tool.ruff]
line-length = 80
target-version = "py39"

[tool.ruff.lint]
extend-select = ["I", "PLE", "PLW"]

[tool.coverage.run]
omit = ["tests/*", "*/__init__.py"]
source = ["greenbone"]

[tool.mypy]
files = "greenbone"
ignore_missing_imports = true
explicit_package_bases = true

[tool.git-cliff.changelog]
# template for the changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{%- macro remote_url() -%}
  https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}

{% if version -%}
    ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
    ## [Unreleased]
{% endif -%}

{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | upper_first }}
    {% for commit in commits %}
        - {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
            {% if commit.remote.username %} by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }}){%- endif -%}
            {% if commit.remote.pr_number %} in \
            [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
            {% elif commit.id %} in \
            [{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }})\
            {%- endif -%}
    {% endfor %}
{% endfor -%}
"""
# template for the changelog footer
footer = """
{%- macro remote_url() -%}
  https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}

{% for release in releases %}
    {% if release.version -%}
        {% if release.previous.version -%}
            [{{ release.version | trim_start_matches(pat="v") }}]: \
                {{ self::remote_url() }}/compare/{{ release.previous.version }}..{{ release.version }}
        {% endif -%}
    {% else -%}
        [unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}..HEAD
    {% endif -%}
{%- endfor -%}
"""
# remove the leading and trailing whitespace from the templates
trim = true

[tool.git-cliff.git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not following the conventional commits format
filter_unconventional = false
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
  # remove issue numbers from commits
  { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
]
# regex for parsing and grouping commits
commit_parsers = [
  { message = "^[a|A]dd", group = "<!-- 1 -->:sparkles: Added" },
  { message = "^[c|C]hange", group = "<!-- 2 -->:construction_worker: Changed" },
  { message = "^[f|F]ix", group = "<!-- 3 -->:bug: Bug Fixes" },
  { message = "^[r|R]emove", group = "<!-- 4 -->:fire: Removed" },
  { message = "^[d|D]rop", group = "<!-- 4 -->:fire: Removed" },
  { message = "^[d|D]oc", group = "<!-- 5 -->:books: Documentation" },
  { message = "^[t|T]est", group = "<!-- 6 -->:white_check_mark: Testing" },
  { message = "^[c|C]hore", group = "<!-- 7 -->:wrench: Miscellaneous" },
  { message = "^[c|C]i", group = "<!-- 7 -->️:wrench: Miscellaneous" },
  { message = "^[m|M]isc", group = "<!-- 7 -->:wrench: Miscellaneous" },
  { message = "^[d|D]eps", group = "<!-- 8 -->:ship: Dependencies" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
