fix: use git fetch --tags and uv sync --reinstall to fix version after upgrade

uv's PEP 517 build isolation copies source to a temp dir without .git,
so setuptools-scm can't determine the version and falls back to the
existing _version.py. Forcing --reinstall-package hate_crack makes uv
rebuild from source in the actual repo dir (editable mode) where git
is accessible, so the correct version is generated.
This commit is contained in:
Justin Bollinger
2026-03-19 18:02:54 -04:00
parent bc166e0a4e
commit 0aa61a4c7c
2 changed files with 7 additions and 4 deletions

View File

@@ -827,12 +827,15 @@ def _run_upgrade():
if git_root_result.returncode != 0:
print(
"\n Could not find a git repository to upgrade from."
"\n Run manually: git pull && make clean && make && make install\n"
"\n Run manually: git pull && git fetch --tags && uv sync --reinstall-package hate_crack\n"
)
raise SystemExit(1)
repo_root = git_root_result.stdout.strip()
result = subprocess.run(
"git pull && make install",
# git fetch --tags ensures new release tags are visible to setuptools-scm.
# uv sync --reinstall-package forces hate_crack to be rebuilt from
# current source so setuptools-scm generates the correct version.
"git pull && git fetch --tags && uv sync --reinstall-package hate_crack",
shell=True,
cwd=repo_root,
)

View File

@@ -160,7 +160,7 @@ class TestCheckForUpdates:
assert mock_run.call_count == 2
make_cmd = mock_run.call_args_list[1][0][0]
assert "git pull" in make_cmd
assert "make install" in make_cmd
assert "uv sync --reinstall-package hate_crack" in make_cmd
assert mock_run.call_args_list[1][1]["cwd"] == "/fake/repo"
output = capsys.readouterr().out
assert "Upgrade complete" in output
@@ -231,7 +231,7 @@ class TestRunUpgrade:
assert mock_run.call_count == 2
make_cmd = mock_run.call_args_list[1][0][0]
assert "git pull" in make_cmd
assert "make install" in make_cmd
assert "uv sync --reinstall-package hate_crack" in make_cmd
assert mock_run.call_args_list[1][1]["cwd"] == "/fake/repo"
output = capsys.readouterr().out
assert "Upgrade complete" in output