paulirish.git-recent/git-recent-cl
google-labs-jules[bot] 66e9793904 Refactor git-recent to be robust and pluggable
- Replaced fragile .git/ path parsing with git plumbing commands to support worktrees and packed-refs.
- Decoupled Chromium logic into a separate `git-recent-cl` script.
- Implemented a plugin system via `GIT_RECENT_SOURCE` environment variable.
- Improved shell hygiene and fzf command injection protection.
2025-12-30 09:28:57 +00:00

33 lines
1,013 B
Bash
Executable file

#!/bin/bash
#
# git-recent-cl
# Plugin for git-recent to add Chromium CL status.
#
YELLOW='\033[0;33m'
DIM='\033[2m'
NC='\033[0m' # No Color
# Determine which refs to look at. Default to heads.
# If an argument is provided (e.g. from `git recent remotename`), use that.
heads="refs/heads"
if [[ -n "$1" ]]; then
heads="refs/remotes/$1"
fi
# Get CL status
# This mimics the logic in the original git-recent
CL_STATUS=$(git cl status --fast --no-branch-color 2>/dev/null | grep 'https://' | sed 's| (.*||')
git for-each-ref --sort=-authordate "$heads" --format="%(refname:short)" \
| while read -r branch_name; do
review_url=$(echo "$CL_STATUS" | grep -E "\b${branch_name} :" | grep -o -E 'https://.*' | sed 's|https://||')
if [[ -n "$review_url" ]]; then
# Using fancy integrated hyperlinks
printf "$YELLOW%s $DIM\033]8;;%s\a%s\033]8;;\a$NC\n" "$branch_name" "https://$review_url" "$review_url"
else
printf "$YELLOW%s$NC\n" "$branch_name"
fi
done