Skip to content

Commit a3c2271

Browse files
Fix release script skipping version bump for lockfile-only changes
has_changes() filtered changed files to only .py and .ts suffixes, so packages with only lockfile updates (e.g. uv.lock from dependabot) were never version-bumped. Remove the suffix filter so any file change in a package directory triggers the CalVer bump. Closes modelcontextprotocol#3870 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent d5bfe34 commit a3c2271

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

‎scripts/release.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def has_changes(path: Path, git_hash: GitHash) -> bool:
112112
text=True,
113113
)
114114

115-
changed_files = [Path(f) for f in output.stdout.splitlines()]
116-
relevant_files = [f for f in changed_files if f.suffix in [".py", ".ts"]]
117-
return len(relevant_files) >= 1
115+
changed_files = output.stdout.splitlines()
116+
117+
return len(changed_files) >= 1
118118
except subprocess.CalledProcessError:
119119
return False
120120

‎scripts/test_release.py‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""Tests for release.py has_changes function."""
2+
3+
import subprocess
4+
import tempfile
5+
from pathlib import Path
6+
7+
from release import has_changes, GitHash
8+
9+
10+
def _run(cmd: str, cwd: Path) -> None:
11+
subprocess.run(cmd.split(), cwd=cwd, check=True, capture_output=True)
12+
13+
14+
def _init_repo(tmp: Path) -> GitHash:
15+
"""Create a git repo with an initial commit and return its hash."""
16+
_run("git init", tmp)
17+
_run("git config user.email [email protected]", tmp)
18+
_run("git config user.name Test", tmp)
19+
(tmp / "README.md").write_text("init")
20+
_run("git add -A", tmp)
21+
_run("git commit -m init", tmp)
22+
result = subprocess.run(
23+
["git", "rev-parse", "HEAD"],
24+
cwd=tmp, check=True, capture_output=True, text=True,
25+
)
26+
return GitHash(result.stdout.strip())
27+
28+
29+
def test_no_changes():
30+
with tempfile.TemporaryDirectory() as tmp:
31+
tmp = Path(tmp)
32+
git_hash = _init_repo(tmp)
33+
assert has_changes(tmp, git_hash) is False
34+
35+
36+
def test_py_file_change():
37+
with tempfile.TemporaryDirectory() as tmp:
38+
tmp = Path(tmp)
39+
git_hash = _init_repo(tmp)
40+
(tmp / "server.py").write_text("print('hi')")
41+
_run("git add -A", tmp)
42+
_run("git commit -m add-py", tmp)
43+
assert has_changes(tmp, git_hash) is True
44+
45+
46+
def test_lockfile_change():
47+
"""Lockfile-only changes must be detected -- this was the bug."""
48+
with tempfile.TemporaryDirectory() as tmp:
49+
tmp = Path(tmp)
50+
git_hash = _init_repo(tmp)
51+
(tmp / "uv.lock").write_text("lockfile content")
52+
_run("git add -A", tmp)
53+
_run("git commit -m add-lock", tmp)
54+
assert has_changes(tmp, git_hash) is True
55+
56+
57+
def test_toml_change():
58+
with tempfile.TemporaryDirectory() as tmp:
59+
tmp = Path(tmp)
60+
git_hash = _init_repo(tmp)
61+
(tmp / "pyproject.toml").write_text("[project]\nname='x'")
62+
_run("git add -A", tmp)
63+
_run("git commit -m add-toml", tmp)
64+
assert has_changes(tmp, git_hash) is True
65+
66+
67+
if __name__ == "__main__":
68+
test_no_changes()
69+
test_py_file_change()
70+
test_lockfile_change()
71+
test_toml_change()
72+
print("All tests passed.")

0 commit comments

Comments
 (0)