Version source plugins¶バージョンソースプラグイン¶
Known third-party¶既知のサードパーティ¶
- hatch-vcs - uses your preferred version control system (like Git)hatch-vcs - お好みのバージョン管理システム(Gitなど)を使用します
- hatch-nodejs-version - uses the
versionfield of NodeJSpackage.jsonfileshatch-nodejs-version - NodeJSのpackage.jsonファイルのversionフィールドを使用します - hatch-regex-commit - automatically creates a Git commit and tag after version bumpinghatch-regex-commit - バージョンを上げた後に自動的にGitコミットとタグを作成します
- versioningit - determines version from Git or Mercurial tags, with customizable version formattingversioningit - GitまたはMercurialのタグからバージョンを決定し、カスタマイズ可能なバージョンフォーマットを提供します
VersionSourceInterface ¶VersionSourceInterface ¶
Example usage:使用例:
from hatchling.version.source.plugin.interface import VersionSourceInterface
class SpecialVersionSource(VersionSourceInterface):
PLUGIN_NAME = "special"
...
from hatchling.plugin import hookimpl
from .plugin import SpecialVersionSource
@hookimpl
def hatch_register_version_source():
return SpecialVersionSource
Source code in hatchling/version/source/plugin/interface.py
class VersionSourceInterface(ABC): # no cov
"""
Example usage:
```python tab="plugin.py"
from hatchling.version.source.plugin.interface import VersionSourceInterface
class SpecialVersionSource(VersionSourceInterface):
PLUGIN_NAME = "special"
...
```
```python tab="hooks.py"
from hatchling.plugin import hookimpl
from .plugin import SpecialVersionSource
@hookimpl
def hatch_register_version_source():
return SpecialVersionSource
```
"""
PLUGIN_NAME = ""
"""The name used for selection."""
def __init__(self, root: str, config: dict) -> None:
self.__root = root
self.__config = config
@property
def root(self) -> str:
"""
The root of the project tree as a string.
"""
return self.__root
@property
def config(self) -> dict:
"""
```toml config-example
[tool.hatch.version]
```
"""
return self.__config
@abstractmethod
def get_version_data(self) -> dict:
"""
This should return a mapping with a `version` key representing the current version of the project and will be
displayed when invoking the [`version`](../../cli/reference.md#hatch-version) command without any arguments.
The mapping can contain anything else and will be passed to
[set_version](reference.md#hatchling.version.source.plugin.interface.VersionSourceInterface.set_version)
when updating the version.
"""
def set_version(self, version: str, version_data: dict) -> None:
"""
This should update the version to the first argument with the data provided during retrieval.
"""
raise NotImplementedError
PLUGIN_NAME = '' class-attribute instance-attribute ¶PLUGIN_NAME = '' class-attribute instance-attribute ¶
The name used for selection.選択に使用される名前。
root: str property ¶root: str property ¶
The root of the project tree as a string.プロジェクトツリーのルートを文字列として表します。
get_version_data() -> dict abstractmethod ¶get_version_data() -> dict abstractmethod ¶
This should return a mapping with a version key representing the current version of the project and will be displayed when invoking the version command without any arguments.これは、プロジェクトの現在のバージョンを表す version キーを持つマッピングを返す必要があり、引数なしで version コマンドを呼び出すと表示されます。
The mapping can contain anything else and will be passed to set_version when updating the version.マッピングには他の何でも含めることができ、バージョンを更新する際に set_version に渡されます。
Source code in hatchling/version/source/plugin/interface.py
@abstractmethod
def get_version_data(self) -> dict:
"""
This should return a mapping with a `version` key representing the current version of the project and will be
displayed when invoking the [`version`](../../cli/reference.md#hatch-version) command without any arguments.
The mapping can contain anything else and will be passed to
[set_version](reference.md#hatchling.version.source.plugin.interface.VersionSourceInterface.set_version)
when updating the version.
"""
set_version(version: str, version_data: dict) -> None ¶set_version(version: str, version_data: dict) -> None ¶
This should update the version to the first argument with the data provided during retrieval.これは、取得時に提供されたデータを使用して、最初の引数にバージョンを更新する必要があります。
Source code in hatchling/version/source/plugin/interface.py
def set_version(self, version: str, version_data: dict) -> None:
"""
This should update the version to the first argument with the data provided during retrieval.
"""
raise NotImplementedError