File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929.env
3030.env. *
3131! .env.example
32+
33+
34+ change-summary.md
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2- gitprune () {
3- echo " Pruning local git branches"
2+
3+ GREEN=' \033[32m'
4+ GREY=' \033[2m'
5+ RESET=' \033[0m'
6+
7+ gecho () { printf " ${GREEN} %s${RESET} \n" " $* " ; }
8+
9+ show_progress () {
10+ while IFS= read -r line; do
11+ printf " \r${GREY} %-120s${RESET} " " ${line: 0: 120} "
12+ done
13+ printf " \r%-120s\r" " "
14+ }
15+
16+ gitprune () {
17+ gecho " Pruning local git branches"
418
519 if [[ " $1 " == " --force" ]]; then
6- echo " Force deleting unmerged branches"
20+ gecho " Force deleting unmerged branches"
721 git branch -r | awk ' {print $1}' | grep -Ev -f /dev/fd/0 <( git branch -vv | grep origin) | awk ' {print $1}' | xargs -r git branch -D
822 else
923 git branch -r | awk ' {print $1}' | grep -Ev -f /dev/fd/0 <( git branch -vv | grep origin) | awk ' {print $1}' | xargs -r git branch -d
1024 fi
1125
12- git gc --prune=now
13- git fetch -p
14- echo " Pruning complete. Running garbage collection"
15- git gc
16- echo " Pruned and Cleaned."
26+ { git gc --prune=now && git fetch -p; } 2>&1 | show_progress
27+ gecho " Running garbage collection"
28+ git gc 2>&1 | show_progress
29+ gecho " [DONE] Pruned and cleaned."
1730}
1831
19- gitrefresh () {
20- echo " Refreshing local clone."
21- if [[ " $1 " != " " ]]
22- then
23- git checkout " $1 "
24- else
25- git checkout main
26- fi
27- git fetch origin
28- git pull
29- gitprune --force
30- gitprune --force
32+ gitrefresh () {
33+ local branch=" ${1:- main} "
34+ gecho " Refreshing local clone → $branch "
35+ git checkout " $branch " 2>&1 | show_progress
36+ git fetch origin 2>&1 | show_progress
37+ git pull 2>&1 | show_progress
38+ gitprune --force > /dev/null 2>&1
39+ gitprune --force
3140}
You can’t perform that action at this time.
0 commit comments