Skip to content

Commit

Permalink
add pin symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Dec 4, 2024
1 parent f9ad8d1 commit 9561b14
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/hhd/plugins/bootc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
BRANCHES = os.environ.get(
"HHD_BOOTC_BRANCHES", "stable:Stable,testing:Testing,unstable:Unstable"
)
DEFAULT_PREFIX = "> "

REF_PREFIX = "§ "
DEFAULT_PREFIX = "◉ "

BOOTC_STATUS_CMD = [
BOOTC_PATH,
Expand Down Expand Up @@ -189,25 +191,32 @@ def _init(self, conf: Config):

# Find branch and replace tag
branch = get_branch(img, self.branches)
rebased_ver = False
rebased_ver = None
self.branch_name = branch
self.branch_ref = None
has_rebased = False
if branch:
if ":" in img:
tag = img[img.rindex(":") + 1 :]
if tag != branch:
rebased_ver = True
rebased_ver = tag
has_rebased = True
self.branch_ref = ref.split(":")[0] + ":" + branch
img = img[: img.rindex(":") + 1] + branch
if img:
conf["updates.bootc.image"] = img

# If we have a staged update, that will boot first
s = self.get_version("staged")
og = s = self.get_version("staged")
staged = False
if s:
conf["updates.bootc.staged"] = DEFAULT_PREFIX + s
s = DEFAULT_PREFIX + s
staged = True
if s and og == rebased_ver:
s = REF_PREFIX + s
# Only apply one start to avoid confusion
rebased_ver = None
conf["updates.bootc.staged"] = s

# Check if the user selected rollback
# Then that will be the default, provided there is a rollback
Expand All @@ -223,9 +232,11 @@ def _init(self, conf: Config):
conf[f"updates.bootc.rollback"] = s

# Otherwise, the booted version will be the default
s = self.get_version("booted")
og = s = self.get_version("booted")
if s and not rollback and not staged:
s = DEFAULT_PREFIX + s
if s and og == rebased_ver:
s = REF_PREFIX + s
conf[f"updates.bootc.booted"] = s

conf["updates.bootc.status"] = ""
Expand Down Expand Up @@ -256,7 +267,7 @@ def _init(self, conf: Config):
elif self.get_version("staged"):
conf["updates.bootc.stage.mode"] = "ready_updated"
self.state = "ready_updated"
elif rebased_ver:
elif has_rebased:
conf["updates.bootc.stage.mode"] = "ready_rebased"
self.state = "ready_rebased"
elif rollback:
Expand Down

0 comments on commit 9561b14

Please sign in to comment.