beautify fetch
This commit is contained in:
parent
7cdf3b2997
commit
00b115a598
1 changed files with 19 additions and 9 deletions
28
gis
28
gis
|
|
@ -3,6 +3,7 @@
|
||||||
# Text formatting variables
|
# Text formatting variables
|
||||||
text_reset=$'\e[0m'
|
text_reset=$'\e[0m'
|
||||||
text_bold=$'\e[1m'
|
text_bold=$'\e[1m'
|
||||||
|
text_blue=$'\e[34m'
|
||||||
text_green=$'\e[32m'
|
text_green=$'\e[32m'
|
||||||
text_red=$'\e[31m'
|
text_red=$'\e[31m'
|
||||||
text_yellow=$'\e[33m'
|
text_yellow=$'\e[33m'
|
||||||
|
|
@ -56,21 +57,30 @@ if [ "${paths[*]}" == "" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find Git repositories
|
# Find Git repositories
|
||||||
|
git_dirs=()
|
||||||
for path in "${paths[@]}"; do
|
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
|
done
|
||||||
|
|
||||||
# Fetch Git repositories via background processes
|
# Fetch Git repositories
|
||||||
if [ "$fetch" == true ]; then
|
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}"
|
cd "$dir" || echo "Failed to cd into ${text_bold}${text_red}${dir}${text_reset}"
|
||||||
|
|
||||||
# Get repository name
|
# Get repository name
|
||||||
repository_name=$(basename "$dir")
|
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+=("$!")
|
fetch_pids+=("$!")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -81,9 +91,9 @@ if [ "$fetch" == true ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get Git status of all directories
|
# 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}"
|
cd "$dir" || echo "Failed to cd into ${text_bold}${text_red}${dir}${text_reset}"
|
||||||
|
|
||||||
# Get repository name
|
# Get repository name
|
||||||
repository_name=$(basename "$dir")
|
repository_name=$(basename "$dir")
|
||||||
|
|
||||||
|
|
@ -127,7 +137,7 @@ for dir in $git_dirs; do
|
||||||
|
|
||||||
# Update all status keys
|
# Update all status keys
|
||||||
all_status_keys="${all_status_keys}${status_keys}"
|
all_status_keys="${all_status_keys}${status_keys}"
|
||||||
|
|
||||||
# Construct key output
|
# Construct key output
|
||||||
if [[ "$status_keys" ]]; then
|
if [[ "$status_keys" ]]; then
|
||||||
status_keys="${text_bold}${text_red}[${status_keys}]${text_reset}"
|
status_keys="${text_bold}${text_red}[${status_keys}]${text_reset}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue