Skip to content

Address hotfix detection #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 6 additions & 35 deletions scripts/release/is-hotfix-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,16 @@
if TYPE_CHECKING:
from argparse import Namespace

def get_merge_base_of_ref() -> str:
cp = run(["git", "merge-base", "HEAD", "origin/main"], capture_output=True, text=True)
if cp.returncode != 0:
raise RuntimeError(f"Failed to get merge base with reason '{cp.stderr.strip()}'")
return cp.stdout.strip()

def get_release_branches_containing(commit: str) -> List[Version]:
cp = run(["git", "branch", "--list", "rc/*", "--contains", commit], capture_output=True, text=True)
if cp.returncode != 0:
raise RuntimeError("Failed to get branches containing commit")
release_versions: List[Version] = []
for version in [b.strip() for b in cp.stdout.splitlines()]:
try:
if version.startswith("rc/"):
version = version[3:]
release_versions.append(Version(version))
except ValueError:
print(f"Warning: Skipping invalid version string: {version}", file=stderr)

return release_versions

def main(args: 'Namespace') -> Literal[0,1]:
try:
merge_base = get_merge_base_of_ref()
release_versions = get_release_branches_containing(merge_base)
if len(release_versions) == 0:
print(f"Info: No release branches found containing merge base {merge_base}", file=stderr)
version = Version(args.version)
if version.patch > 0:
print("true")
else:
print("false")
return 0

for version in release_versions:
if version.next_patch() == Version(args.version):
print("true")
return 0

print("false")
return 0
except RuntimeError as e:
print(f"Error: {e}", file=stderr)
except ValueError:
print(f"Invalid version string: {args.version}", file=stderr)
return 1

if __name__ == '__main__':
Expand Down
Loading