fix(supervisor): use version-sorted tag list for current_deployed_tag
git describe --exact-match returns the first tag alphabetically when multiple tags point to the same commit. This caused an infinite redeploy loop when Gitea CI created a sequential tag (v11) on the same commit as our date-based tag (v202602281745) — v11 < v202602281745 alphabetically but the deploy check uses version sort where v202602281745 > v11. Fix: use git tag --points-at HEAD --sort=-version:refname to pick the highest-version tag at HEAD, matching the sort order of latest_remote_tag(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -279,12 +279,18 @@ def web_code_changed() -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def current_deployed_tag() -> str | None:
|
def current_deployed_tag() -> str | None:
|
||||||
"""Return the tag currently checked out, or None if not on a tag."""
|
"""Return the highest-version tag pointing at HEAD, or None.
|
||||||
|
|
||||||
|
Uses the same sort order as latest_remote_tag() so that when multiple
|
||||||
|
tags point to the same commit (e.g. a date-based tag and a CI integer
|
||||||
|
tag), we always compare apples-to-apples.
|
||||||
|
"""
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["git", "describe", "--tags", "--exact-match", "HEAD"],
|
["git", "tag", "--list", "--sort=-version:refname", "--points-at", "HEAD", "v*"],
|
||||||
capture_output=True, text=True, timeout=10,
|
capture_output=True, text=True, timeout=10,
|
||||||
)
|
)
|
||||||
return result.stdout.strip() or None
|
tags = result.stdout.strip().splitlines()
|
||||||
|
return tags[0] if tags else None
|
||||||
|
|
||||||
|
|
||||||
def latest_remote_tag() -> str | None:
|
def latest_remote_tag() -> str | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user