File: hatch_build.py

package info (click to toggle)
gitlint 0.19.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,140 kB
  • sloc: python: 6,728; sh: 74; makefile: 17; javascript: 5
file content (13 lines) | stat: -rw-r--r-- 719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
# hatch_build.py is executed by hatch at build-time and can contain custom build logic hooks
import os
from hatchling.metadata.plugin.interface import MetadataHookInterface


class CustomMetadataHook(MetadataHookInterface):
    """Custom metadata hook for hatch that ensures that gitlint and gitlint-core[trusted-deps] versions always match"""

    def update(self, metadata: dict) -> None:
        # Only enforce versioning matching outside of the 'dev' environment, this allows for re-use of the 'dev'
        # environment between different git branches.
        if os.environ.get("HATCH_ENV_ACTIVE", "not-dev") != "dev":
            metadata["dependencies"] = [f"gitlint-core[trusted-deps]=={metadata['version']}"]