Files
shell-scripts/pull-all.sh
T
andrew 0a21caf6c2 rebuilt thermal, now works with all zones available.
discord will now work without hook specified.
2023-09-27 14:45:57 -04:00

44 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# perform a "git pull" on each location specified (recursively), or current location if none specified.
# git will quietly ignore any git repo stored in a folder you lack permission on.
# pull will not go through if there are uncommitted local changes, or if the branch has no upstream.
#
# will only search symbolic links when passed "-l" option, must be before any locations
# pull-all.sh [-l] # current location implied
# pull-all.sh [-l] ~/my-projects /var/group-projects
# check for "-l" in command prompt
followLinks="-H"
while getopts "l" option; do
case $option in
l)
followLinks="-L"
;;
esac
done
shift "$((OPTIND-1))"
if [[ "-H" == "$followLinks" ]]; then
echo "use -l to follow symbolic links"
fi
# function to process each location
function process_git_pull () {
startedIn=`pwd`
location=$(dirname "$@")
echo -n "----- git pull $location "
printf "%*.*s" 0 $((40 - ${#location} )) "----------------------------------------"
echo "-----"
cd "$location"
git pull --ff-only
cd "$startedIn"
}
# find all folders named ".git" under given locations,
# and call process_git_pull on each location that was found.
# we then work on the folder that contained the ".git" folder.
find "$followLinks" "$@" -type d -name ".git" | while read -r file; do process_git_pull "$file"; done