Skip to content

Commit 3ec494f

Browse files
committed
Simplify hotfix detection
The logic to detect a hotfix by finding a merge base between main and release branch is incorrect because the merge base wasn't found in previous releases. Now we just assume any version with a patch number larger than 0 is a hotfix.
1 parent cdaffa0 commit 3ec494f

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

scripts/release/is-hotfix-release.py

+6-35
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,16 @@
66
if TYPE_CHECKING:
77
from argparse import Namespace
88

9-
def get_merge_base_of_ref() -> str:
10-
cp = run(["git", "merge-base", "HEAD", "origin/main"], capture_output=True, text=True)
11-
if cp.returncode != 0:
12-
raise RuntimeError(f"Failed to get merge base with reason '{cp.stderr.strip()}'")
13-
return cp.stdout.strip()
14-
15-
def get_release_branches_containing(commit: str) -> List[Version]:
16-
cp = run(["git", "branch", "--list", "rc/*", "--contains", commit], capture_output=True, text=True)
17-
if cp.returncode != 0:
18-
raise RuntimeError("Failed to get branches containing commit")
19-
release_versions: List[Version] = []
20-
for version in [b.strip() for b in cp.stdout.splitlines()]:
21-
try:
22-
if version.startswith("rc/"):
23-
version = version[3:]
24-
release_versions.append(Version(version))
25-
except ValueError:
26-
print(f"Warning: Skipping invalid version string: {version}", file=stderr)
27-
28-
return release_versions
29-
309
def main(args: 'Namespace') -> Literal[0,1]:
3110
try:
32-
merge_base = get_merge_base_of_ref()
33-
release_versions = get_release_branches_containing(merge_base)
34-
if len(release_versions) == 0:
35-
print(f"Info: No release branches found containing merge base {merge_base}", file=stderr)
11+
version = Version(args.version)
12+
if version.patch > 0:
13+
print("true")
14+
else:
3615
print("false")
37-
return 0
38-
39-
for version in release_versions:
40-
if version.next_patch() == Version(args.version):
41-
print("true")
42-
return 0
43-
44-
print("false")
4516
return 0
46-
except RuntimeError as e:
47-
print(f"Error: {e}", file=stderr)
17+
except ValueError:
18+
print(f"Invalid version string: {args.version}", file=stderr)
4819
return 1
4920

5021
if __name__ == '__main__':

0 commit comments

Comments
 (0)