Skip to content

Instantly share code, notes, and snippets.

@Auronmatrix
Last active June 28, 2019 14:01
Show Gist options
  • Save Auronmatrix/bbd75681da799bbf60b705a23af4a4bc to your computer and use it in GitHub Desktop.
Save Auronmatrix/bbd75681da799bbf60b705a23af4a4bc to your computer and use it in GitHub Desktop.
Get Directory Tags
#!/bin/bash
# Update all git directories below current directory or specified directory
# Skips directories that contain a file called .ignore
function update {
local d="$1"
if [ -d "$d" ]; then
if [ -e "$d/.ignore" ]; then
echo "Ignoring $d"
else
cd $d > /dev/null
if [ -d ".git" ]; then
echo "----------------"
echo "Git Repo: `pwd`"
echo "----------------"
# sed -i '' 's/foo/bar/g' .git/config
# git config --local --list
TAG=$(git describe --abbrev=0 --tags 2>/dev/null)
echo "$TAG"
echo ""
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