Crate gcu

Crate gcu 

Source
Expand description

Switch, create, and derive Git branches (including from GitHub PR URLs).

ยงArguments

  • - Switch to previous branch.
  • -b <args...> Create new branch from sanitized <args...> then switch.
  • <single> Switch if exists, else confirm create & switch.
  • <multiple args> Sanitize & join into branch name (create if missing).
  • <github pull request url> Derive branch name from PR & switch (fetch if needed).
  • (none) Launch interactive selector.

ยงUsage

gcu # interactive branch picker
gcu - # previous branch
gcu -b Feature Add Foo # create: feature-add-foo
gcu feature add foo # sanitized join -> feature-add-foo (create if missing)
gcu https://github.com/org/repo/pull/123 # derive PR branch name & switch

ยงErrors

  • GitHub authentication via [ytil_gh::log_into_github] or PR branch name derivation via [ytil_gh::get_branch_name_from_url] fails.
  • Branch name construction via build_branch_name yields empty string.
  • Branch listing via [ytil_git::branch::get_all] / switching via [ytil_git::branch::switch] / creation via [ytil_git::branch::create_from_default_branch] fails.
  • Interactive selection via [ytil_tui::minimal_select] or user confirmation input fails.
  • Current branch lookup via [ytil_git::branch::get_current] fails.

Functionsยง

ask_branching_from_not_default ๐Ÿ”’
Prints a styled notice that a new branch is being created from a non-default branch.
autocomplete_git_branches_and_switch ๐Ÿ”’
Interactive selection and switching of Git branches.
build_branch_name ๐Ÿ”’
Builds a sanitized, lowercased Git branch name from raw arguments.
create_branch_and_switch ๐Ÿ”’
Creates a new local branch (if desired) and switches to it.
handle_single_input_argument ๐Ÿ”’
Handles a single input argument, either a GitHub PR URL or a branch name, and switches to the corresponding branch.
main ๐Ÿ”’
Switch, create, and derive Git branches (including from GitHub PR URLs).
report_branch_exists ๐Ÿ”’
Prints a styled indication that the branch already exists; then indicates switch.
report_branch_new ๐Ÿ”’
Prints a styled indication that a new branch was created.
report_branch_not_created ๐Ÿ”’
Prints a styled indication that branch creation was aborted (no newline).
report_branch_switch ๐Ÿ”’
Prints a styled indication of a successful branch switch.
should_create_new_branch ๐Ÿ”’
Returns true if a new branch may be created following the desired behavior.