2024-01-25 09:53:09 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Update all git directories below current directory or specified directory
|
|
|
|
|
|
|
|
# Skips directories that contain a file called .ignore
|
|
|
|
|
|
|
|
HIGHLIGHT="\e[01;34m"
|
|
|
|
NORMAL='\e[00m'
|
|
|
|
|
|
|
|
function update {
|
|
|
|
local d="$1"
|
|
|
|
if [ -d "$d" ]; then
|
|
|
|
if [ -e "$d/.ignore" ]; then
|
|
|
|
echo -e "\n${HIGHLIGHT}Ignoring $d${NORMAL}"
|
|
|
|
else
|
2024-06-05 19:13:44 +02:00
|
|
|
cd "$d" || exit > /dev/null
|
2024-01-25 09:53:09 +01:00
|
|
|
if [ -d ".git" ]; then
|
|
|
|
echo -e "\n${HIGHLIGHT}Updating pwd$NORMAL"
|
|
|
|
git add .
|
|
|
|
git stash
|
|
|
|
git pull
|
|
|
|
else
|
2024-06-05 19:13:44 +02:00
|
|
|
# shellcheck disable=SC2035
|
2024-01-25 09:53:09 +01:00
|
|
|
scan *
|
|
|
|
fi
|
|
|
|
cd .. > /dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#echo "Exiting update: pwd=pwd"
|
|
|
|
}
|
|
|
|
|
|
|
|
function scan {
|
|
|
|
#echo "pwd"
|
2024-06-05 19:13:44 +02:00
|
|
|
for x in "$@"; do
|
2024-01-25 09:53:09 +01:00
|
|
|
update "$x"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2024-06-05 19:13:44 +02:00
|
|
|
if [ "$1" != "" ]; then cd "$1" || exit > /dev/null; fi
|
2024-01-25 09:53:09 +01:00
|
|
|
|
|
|
|
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}"
|
2024-06-05 19:13:44 +02:00
|
|
|
# shellcheck disable=SC2035
|
2024-01-25 09:53:09 +01:00
|
|
|
scan *
|