Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid unconditional
origin/prefixing for default branch values.On Line 76 and Line 81, if
resolve_default_branchalready returnsorigin/main(from existing config), this becomesorigin/origin/mainand ref resolution can fail. Normalize the value before prefixing.Proposed fix
_create_resolve_from_ref() { local from_ref="$1" from_current="$2" repo_root="$3" + local default_branch if [ -z "$from_ref" ]; then if [ "$from_current" -eq 1 ]; then from_ref=$(get_current_branch) if [ -z "$from_ref" ] || [ "$from_ref" = "HEAD" ]; then log_warn "Currently in detached HEAD state - falling back to default branch" - from_ref="origin/$(resolve_default_branch "$repo_root")" + default_branch=$(resolve_default_branch "$repo_root") + case "$default_branch" in + origin/*) from_ref="$default_branch" ;; + refs/remotes/origin/*) from_ref="${default_branch#refs/remotes/}" ;; + *) from_ref="origin/$default_branch" ;; + esac else log_info "Creating from current branch: $from_ref" fi else - from_ref="origin/$(resolve_default_branch "$repo_root")" + default_branch=$(resolve_default_branch "$repo_root") + case "$default_branch" in + origin/*) from_ref="$default_branch" ;; + refs/remotes/origin/*) from_ref="${default_branch#refs/remotes/}" ;; + *) from_ref="origin/$default_branch" ;; + esac fi fi printf "%s" "$from_ref" }As per coding guidelines, "Maintain backwards compatibility with existing configs in shell scripts."
📝 Committable suggestion
🤖 Prompt for AI Agents