mirror of
https://github.com/paulirish/git-recent.git
synced 2026-09-10 07:26:16 -04:00
add GIT_RECENT_QUERY env for testing
This commit is contained in:
parent
fbb93ae381
commit
6b628b190c
14
git-recent
14
git-recent
|
|
@ -62,10 +62,13 @@ fi
|
|||
# - https://github.com/junegunn/fzf/wiki/Examples-(fish)#git
|
||||
# - https://github.com/junegunn/fzf-git.sh (intense.)
|
||||
|
||||
# If there's a GIT_RECENT_QUERY environment variable, use it for non-interactive filtering. (Primarily added for testing.)
|
||||
filterarg=${GIT_RECENT_QUERY:+"--filter=$GIT_RECENT_QUERY"}
|
||||
|
||||
_browse_branches() {
|
||||
git for-each-ref --color=always --sort=-authordate "$heads" --format="$branches_format" \
|
||||
| fzf --ansi -- \
|
||||
--layout=reverse --multi --height=90% --min-height=20 \
|
||||
| fzf \
|
||||
$filterarg --ansi -- --layout=reverse --multi --height=90% --min-height=20 \
|
||||
--border-label-pos=2 --border-label '🌲 Branches' --border \
|
||||
--no-hscroll --no-multi \
|
||||
--preview-window='right,70%,border-left,border-rounded' --preview="$uniqcommits_cmd" --preview-label="Commits unique to branch" \
|
||||
|
|
@ -75,9 +78,12 @@ _browse_branches() {
|
|||
--bind "ctrl-y:execute-silent($copy_cmd)" \
|
||||
--bind "ctrl-o:preview:$diffbranch_cmd"
|
||||
}
|
||||
|
||||
chosen_branch="$(_browse_branches)"
|
||||
if [[ -n "$chosen_branch" ]]; then
|
||||
line_count=$(printf "%s" "$chosen_branch" | wc -l)
|
||||
|
||||
if [[ -n "$chosen_branch" ]] && (( line_count == 0 )); then
|
||||
echo git checkout "$chosen_branch"
|
||||
git checkout "$chosen_branch"
|
||||
else
|
||||
echo "$chosen_branch"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue