gabriel / muse public
Open #21 Bug
filed by gabriel human · 1 day ago

muse branch --merged and --no-merged should accept commit IDs

0 Anchors
Blast radius
Churn 30d
0 Proposals

Bug

muse branch --merged <sha256:...> crashes with a ValueError from validate_branch_name because the argument is treated as a branch name unconditionally, not as a commit ID.

muse branch --merged sha256:c5131d76c6eada02939111fda4aa8e51b0c1456b9983727cfd6be101916de14e
ValueError: Branch name 'sha256:c5131d76...' contains forbidden characters

The same applies to --no-merged. Both flags should accept either a branch name or a sha256:-prefixed commit ID as their argument, since the use case of checking against a specific commit (not a named branch) is legitimate — e.g. checking against the tip of a remote tracking ref.

Root cause

In muse/cli/commands/branch.py around line 800, run() calls:

_into_tip = get_head_commit_id(root, _into)

get_head_commit_id calls validate_branch_name on its input unconditionally, before checking whether it might already be a commit ID.

Fix

Before calling get_head_commit_id, check whether the argument starts with sha256:. If so, validate it as a commit ID (64 hex chars after prefix) and use it directly. Only call get_head_commit_id for non-prefixed inputs.

if _into.startswith("sha256:"):
    _into_tip = _into   # already a commit ID — validate format, skip branch lookup
else:
    _into_tip = get_head_commit_id(root, _into)

Affected flags

  • muse branch --merged <ref>
  • muse branch --no-merged <ref>

Any other flags that resolve a ref via get_head_commit_id should get the same treatment.

Activity
gabriel opened this issue 1 day ago
No activity yet. Use the CLI to comment.