diff --git a/src/versioningit/config.py b/src/versioningit/config.py index 4a04fc5..72f3ed9 100644 --- a/src/versioningit/config.py +++ b/src/versioningit/config.py @@ -108,6 +108,12 @@ def parse_toml_file(cls, filepath: str | Path) -> Config: table = hatch_config elif table is None: table = hatch_config + if table.get("onbuild") is not None: + log.warning( + "onbuild configuration in versioningit table detected." + " When using Hatch, onbuild must be configured via" + " [tool.hatch.build.hooks.versioningit-onbuild]." + ) if table is None: raise NotVersioningitError("versioningit not enabled in pyproject.toml") return cls.parse_obj(table) diff --git a/test/data/repos/hatch/onbuild-both-config.json b/test/data/repos/hatch/onbuild-both-config.json new file mode 100644 index 0000000..346c440 --- /dev/null +++ b/test/data/repos/hatch/onbuild-both-config.json @@ -0,0 +1,18 @@ +{ + "version": "0.1.0.post1+g43ee9fd.d20380119", + "next_version": "0.2.0", + "files": [ + { + "sdist_path": "src/mypackage/__init__.py", + "wheel_path": "mypackage/__init__.py", + "in_project": false, + "contents": "\"\"\" A test package \"\"\"\n\n__version__ = \"0.1.0.post1+g43ee9fd.d20380119\"\n" + } + ], + "logmsgs": [ + { + "level": "WARNING", + "message": "onbuild configuration in versioningit table detected. When using Hatch, onbuild must be configured via [tool.hatch.build.hooks.versioningit-onbuild]." + } + ] +} diff --git a/test/data/repos/hatch/onbuild-both-config.zip b/test/data/repos/hatch/onbuild-both-config.zip new file mode 100644 index 0000000..31cab67 Binary files /dev/null and b/test/data/repos/hatch/onbuild-both-config.zip differ