Files
fish-config/functions/branch.fish
T
rootiest f6ead99f48 feat(help): header-driven --help for development functions, plus the wiring guard
bd-pull, branch, check_fish_deps, claude-docs, claude-pr, fast, poke, qr
and parur take the standard call site. fish-deps instead routes -h/--help
to its existing __fish_deps_help, which previously answered only via the
unknown-subcommand path, printing "Unknown subcommand: --help" and
exiting 1.

This completes the 40 conversions and lands
test_every_user_facing_function_has_help -- acceptance criterion 6, the
check that fails when a new user-facing function ships without help. It
was developed red against the pre-conversion tree and reported exactly
the 40 names of the design's CONVERT table:

    bd-pull bkg branch check_fish_deps claude-docs claude-pr cleanup
    fast fc fish-deps fzf-update gip gip4 gip6 hist lD ld limine-edit
    lock lsr lss lstree lt ltr lx parur poke ports qr sbver screensleep
    split spwin steam-dl sudo-toggle swapstat tab tmux-clean upgrade
    wake-lock

each as "<name>: no -h/--help handling and not in $__help_exempt", with
the guard exiting 1. The count fell 40 -> 32 -> 24 -> 17 -> 10 -> 0
across the conversion commits. It is committed green so every commit on
this branch passes the suite.

$__help_exempt is the single machine-readable exemption record; a second
assertion fails if an exempt name stops being a published function, so a
rename or deletion upstream cannot silently exempt nothing.
2026-09-07 20:09:30 -04:00

39 lines
984 B
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# CATEGORY
# 04-git-and-version-control
#
# SYNOPSIS
# branch <branch_name>
#
# DESCRIPTION
# Switches to a local git branch, creating it if it does not already
# exist. Extra arguments are forwarded to git checkout.
#
# ARGUMENTS
# branch_name Branch to switch to or create
#
# EXIT STATUS
# 0 Branch checked out or created
# 1 Not inside a git work tree
#
# EXAMPLE
# branch feature/new-ui
function branch --description 'Switch to or create a git branch'
__fish_help_header (status current-function) $argv; and return 0
if not git rev-parse --is-inside-work-tree >/dev/null 2>&1
echo "Not a git repo."
return 1
end
# Check if the branch already exists locally
if git show-ref --verify --quiet refs/heads/$argv[1]
git checkout $argv
else
# If it doesn't exist, create it
git checkout -b $argv
end
end