Skip to content

Commit

Permalink
Warn if configuring onbuild via versioningit table when using hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Dec 13, 2023
1 parent 1fab146 commit 17e4c19
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/versioningit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions test/data/repos/hatch/onbuild-both-config.json
Original file line number Diff line number Diff line change
@@ -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]."
}
]
}
Binary file added test/data/repos/hatch/onbuild-both-config.zip
Binary file not shown.

0 comments on commit 17e4c19

Please sign in to comment.