mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
upgrade: report git branch via --show-current so a stale release tag can't break upgrades
git rev-parse --abbrev-ref HEAD reports "heads/release" when a stale tag named release exists alongside the release branch (tags outrank heads in git ref resolution). check_for_update then looked up the nonexistent origin/heads/release and permanently reported no updates available, and the Controller UI pre-filled "heads/release" as the upgrade branch. Use git branch --show-current everywhere instead; it never disambiguates. A detached HEAD (empty output) now defaults to the release branch for upgrades; a genuine git failure still returns None. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
9e8050bd48
commit
ab5f416b3f
5 changed files with 94 additions and 15 deletions
|
|
@ -78,17 +78,20 @@ def get_current_branch() -> Optional[str]:
|
|||
Get the current git branch of /opt/wrolpi.
|
||||
|
||||
Returns:
|
||||
Branch name, or None if unable to determine
|
||||
Branch name ('release' on a detached HEAD), or None if unable to determine
|
||||
"""
|
||||
try:
|
||||
# Not `rev-parse --abbrev-ref HEAD`: it reports "heads/release" when a stale
|
||||
# `release` tag exists alongside the branch, breaking origin/{branch} lookups.
|
||||
result = subprocess.run(
|
||||
["git", "-C", "/opt/wrolpi", "rev-parse", "--abbrev-ref", "HEAD"],
|
||||
["git", "-C", "/opt/wrolpi", "branch", "--show-current"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5,
|
||||
)
|
||||
if result.returncode == 0:
|
||||
return result.stdout.strip()
|
||||
# A detached HEAD prints nothing; upgrades come from `release` by default.
|
||||
return result.stdout.strip() or "release"
|
||||
except (subprocess.TimeoutExpired, subprocess.SubprocessError, FileNotFoundError):
|
||||
pass
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue