Skip to content

Move generic Git worktree and branch helpers out of lib_gh #168

Description

@codeforester

Problem

lib/bash/gh/lib_gh.sh is documented as a GitHub CLI library, but several public helpers are generic local Git operations and never invoke gh:

  • gh_detect_default_branch
  • gh_worktree_path_for_branch
  • gh_list_worktree_branches
  • gh_branch_upstream
  • gh_branch_merged_to_ref
  • gh_list_remote_branches

Default-branch detection also duplicates _git_expected_update_branch in lib_git.sh. This blurs library ownership and makes Git-only callers import a GitHub-specific module.

Scope

  • Move generic branch, remote, and worktree primitives into lib_git.sh with git_* names.
  • Consolidate default-branch detection behind one implementation.
  • Make producer-command failures distinguishable from an empty/not-found result; current process-substitution loops can hide git worktree list failure.
  • Coordinate Base call-site/import updates before removing old names.
  • Keep lib_gh.sh focused on GitHub remote parsing and gh CLI/API behavior.

Acceptance Criteria

  • Git-only helpers live and are documented in the Git library.
  • Base uses the new Git API without importing lib_gh.sh solely for local Git operations.
  • Worktree/remote command failures return a real failure instead of empty success.
  • No duplicate default-branch algorithm remains.

Validation

  • Focused git/gh BATS coverage
  • Relevant Base Bash tests for coordinated adoption
  • ./tests/validate.sh
  • git diff --check

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions