Skip to content

Instantly share code, notes, and snippets.

@iAmNathanJ
Created August 24, 2017 12:33
Show Gist options
  • Save iAmNathanJ/0ae03dcb08ba222d36346b138e83bfdf to your computer and use it in GitHub Desktop.
Save iAmNathanJ/0ae03dcb08ba222d36346b138e83bfdf to your computer and use it in GitHub Desktop.
Recursively scan git repos and install git-secrets
#!/bin/bash
# Usage examples:
# ./update-all-repos.sh
# ./update-all-repos.sh ~/Sites ~/Projects
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
function update {
local d="$1"
if [ -d "$d" ]; then
cd "$d" > /dev/null
if [ -d ".git" ]; then
printf "%b\n" "\n${HIGHLIGHT}Updating `pwd`$NORMAL"
git secrets --install
else
scan *
fi
cd .. > /dev/null
fi
}
function scan {
for x in $*; do
update "$x"
done
}
function updater {
if [ "$1" != "" ]; then cd "$1" > /dev/null; fi
printf "%b\n" "${HIGHLIGHT}Scanning ${PWD}${NORMAL}"
scan *
}
if [ "$1" == "" ]; then
updater
else
for dir in "$@"; do
updater "$dir"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment