Files
fish-config/functions/git-clean.fish
T
rootiest a65e05b661 feat(docs): generate Section 5 from function comment headers
The man-page-style comment header above each function in functions/*.fish
becomes the SSOT for that function's documentation. Writing a new function
and documenting it are now the same act.

- manualtools.parse_functions() parses every header carrying a # CATEGORY;
  absence of one is the opt-in, keeping bundled-plugin and prompt internals
  out of the manual with no exclusion list to maintain.
- build-manual.py generates entries for both --concat and --site, with
  **Dependencies:** rendered as links and a **Used by:** reverse index
  computed in one pass. Cross-category links are the navigation win.
- docs/manual/05-functions/*.md reduced to frontmatter-only stubs. Every
  intro measured zero words, so the category files were pure entry
  containers; ordering, titles, and helpKeywords routing are untouched.
- _first_sentence() unwraps the leading hard-wrapped paragraph and skips
  the whole Synopsis block, not just its label line. Site cards no longer
  truncate mid-clause or show a synopsis as their description.

Verification, per the design spec:
- test_concat_roundtrips_original scoped to sections 0-4 and 6-11. It
  guarded a format migration; this is a content migration.
- replaced by structural checks: one entry per categorised function, the
  required sections present, every category resolving to a stub with no
  stub empty, and every declared dependency resolving to a real function
  or a type -q-guarded binary.
- public functions lacking # CATEGORY warn rather than fail, so a new
  user-facing function going undocumented stays visible in CI.

24/24 checks pass. 94 entries generated from 94 parsed headers.

Also drops a stale claim from open-url's NOTES: config-help --html calls
xdg-open directly and has never called open-url.
2026-07-26 04:12:48 -04:00

79 lines
2.7 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# CATEGORY
# 04-git-and-version-control
#
# SYNOPSIS
# git-clean [-h] [-f]
#
# DESCRIPTION
# Fetches and prunes the remote, fast-forwards the current branch, and
# deletes local branches whose tracking remote has been deleted. Switches to
# main/master automatically if the current branch is orphaned.
#
# ARGUMENTS
# -h, --help Show help message
# -f, --force Force-delete unmerged orphaned branches (git branch -D)
#
# RETURNS
# 0 Cleanup complete
# 1 Argument parsing failed
#
# EXAMPLE
# git-clean --force
# git-clean
function git-clean --description 'Sync main, prune remotes, and delete orphaned branches'
set -l options h/help f/force
argparse $options -- $argv
or return
if set -q _flag_help
echo (set_color --bold blue)"Usage: "(set_color normal)"git-clean [OPTIONS]"
echo
echo "Steps taken:"
echo " 1. Fetches and prunes to find deleted remote branches."
echo " 2. Switches to main if you are on an orphaned branch."
echo " 3. Pulls the latest changes from the remote."
echo " 4. Deletes local orphaned branches."
return 0
end
# 1. Fetch and prune (Quietly)
echo (set_color blue)"Fetching and pruning remote tracking..."(set_color normal)
git fetch --prune --quiet
# 2. Identify orphaned branches and current branch
set -l gone_branches (git branch -vv | awk '/: gone\]/ {gsub(/\*/, ""); print $1}')
set -l current_branch (git branch --show-current)
if test -n "$gone_branches"
# 3. Move to safety if needed (Quietly)
if contains "$current_branch" $gone_branches
echo (set_color yellow)"Current branch '$current_branch' was deleted on remote. Moving to main..."(set_color normal)
# Redirecting output to /dev/null to hide the 'Switched to branch' message
git checkout main >/dev/null 2>&1; or git checkout master >/dev/null 2>&1
end
end
# 4. Update the current branch (Quietly)
echo (set_color blue)"Updating current branch..."(set_color normal)
git pull --quiet
# 5. Final cleanup
if test -n "$gone_branches"
set -l delete_flag -d
if set -q _flag_force
set -l delete_flag -D
end
echo (set_color red)"Deleting orphaned local branches ($delete_flag):"(set_color normal)
for branch in $gone_branches
# We keep this output so you can see confirmation of which hashes were deleted
git branch $delete_flag $branch
end
else
echo (set_color green)"Everything is tidy. No orphaned branches found."(set_color normal)
end
end