Created
December 10, 2020 15:48
-
-
Save siredmar/12043e9bad7903eccbf86bfdd92fb888 to your computer and use it in GitHub Desktop.
Get all revisions of git repos recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
cd $d > /dev/null | |
if [ -d ".git" ]; then | |
p=$(pwd) | |
echo $p | |
git -C $p log -n 1 | grep "commit\s.[a-z0-9]*$" | awk '{print $2}' | |
else | |
scan * | |
fi | |
cd .. > /dev/null | |
fi | |
fi | |
#echo "Exiting update: pwd=`pwd`" | |
} | |
function scan { | |
#echo "`pwd`" | |
for x in $*; do | |
update "$x" | |
done | |
} | |
if [ "$1" != "" ]; then cd $1 > /dev/null; fi | |
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}" | |
scan * | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment