Skip to content

Commit

Permalink
Read from .git/versioningit-pretend-version
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Oct 21, 2024
1 parent f41c952 commit 10c4116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/versioningit/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setuptools_finalizer(dist: Distribution) -> None:
# root of the source tree".
PROJECT_ROOT = Path().resolve()
log.info("Project dir: %s", PROJECT_ROOT)
pretend_version = get_pretend_version()
pretend_version = get_pretend_version(project_root=PROJECT_ROOT)
if pretend_version is not None:
dist.metadata.version = pretend_version
return
Expand Down
9 changes: 7 additions & 2 deletions src/versioningit/onbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,10 @@ def replace_version_onbuild(
fp.writelines(lines)


def get_pretend_version() -> str:
return os.getenv("VERSIONINGIT_PRETEND_VERSION")
def get_pretend_version(project_root: Path) -> str | None:
# Reads from a file .git/versioningit-pretend-version
filename = project_root / ".git" / "versioningit-pretend-version"
if not filename.exists():
return None
with open(filename) as f:
return f.read().strip()

0 comments on commit 10c4116

Please sign in to comment.