beautify fetch
This commit is contained in:
parent
7cdf3b2997
commit
00b115a598
1 changed files with 19 additions and 9 deletions
24
gis
24
gis
|
|
@ -3,6 +3,7 @@
|
|||
# Text formatting variables
|
||||
text_reset=$'\e[0m'
|
||||
text_bold=$'\e[1m'
|
||||
text_blue=$'\e[34m'
|
||||
text_green=$'\e[32m'
|
||||
text_red=$'\e[31m'
|
||||
text_yellow=$'\e[33m'
|
||||
|
|
@ -56,21 +57,30 @@ if [ "${paths[*]}" == "" ]; then
|
|||
fi
|
||||
|
||||
# Find Git repositories
|
||||
git_dirs=()
|
||||
for path in "${paths[@]}"; do
|
||||
git_dirs+="$(find "$path" -type d -name ".git" -exec dirname {} \; | sort) "
|
||||
readarray -t found_git_dirs < <(find "$path" -type d -name ".git" -exec dirname {} \; | sort)
|
||||
git_dirs+=("${found_git_dirs[@]}")
|
||||
done
|
||||
|
||||
# Fetch Git repositories via background processes
|
||||
# Fetch Git repositories
|
||||
if [ "$fetch" == true ]; then
|
||||
echo "Fetching"
|
||||
for dir in $git_dirs; do
|
||||
|
||||
if [ "${#git_dirs[@]}" -eq 1 ]; then
|
||||
suffix="y"
|
||||
else
|
||||
suffix="ies"
|
||||
fi
|
||||
echo "${text_bold}${text_blue}Fetching${text_reset} ${#git_dirs[@]} repositor${suffix}"
|
||||
|
||||
for dir in "${git_dirs[@]}"; do
|
||||
cd "$dir" || echo "Failed to cd into ${text_bold}${text_red}${dir}${text_reset}"
|
||||
|
||||
# Get repository name
|
||||
repository_name=$(basename "$dir")
|
||||
echo " - $repository_name"
|
||||
|
||||
git fetch --prune --all 1> /dev/null 2> >(trap "" INT TERM; sed "s/^/${text_bold}${repository_name}${text_reset} /" >&2) &
|
||||
# Fetch all Git repositories in background
|
||||
git fetch --prune --all 1> /dev/null 2> >(trap "" INT TERM; sed "s/^/${text_bold}${text_blue}${repository_name}${text_reset} /" >&2) &
|
||||
fetch_pids+=("$!")
|
||||
done
|
||||
|
||||
|
|
@ -81,7 +91,7 @@ if [ "$fetch" == true ]; then
|
|||
fi
|
||||
|
||||
# Get Git status of all directories
|
||||
for dir in $git_dirs; do
|
||||
for dir in "${git_dirs[@]}"; do
|
||||
cd "$dir" || echo "Failed to cd into ${text_bold}${text_red}${dir}${text_reset}"
|
||||
|
||||
# Get repository name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue