Skip to content

Instantly share code, notes, and snippets.

@ferrolho
Last active July 26, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrolho/d276d58a3ec683ff12a38d22246d6d9b to your computer and use it in GitHub Desktop.
Save ferrolho/d276d58a3ec683ff12a38d22246d6d9b to your computer and use it in GitHub Desktop.
Outputs the hash code and repository name under `catkin_ws/src`
#!/bin/bash
# Store the current location
CUR_DIR=$(pwd)
# Get a sorted list of the git repositories in the current location
repositories=$(find . -name ".git" | cut -c 3- | rev | cut -c 6- | rev | sort)
# For each repository
for i in $repositories ; do
cd "$i"; hash=$(git rev-parse --verify HEAD | cut -c -7)
# Echo the hash and the repository name
echo -e "\033[1m$hash\033[0m\t\033[33m$i\033[0m"
cd $CUR_DIR
done
#!/bin/bash
# For each line
while read p; do
hash=$(echo $p | cut -c -7)
repos=$(echo $p | cut -c 9-)
# Navigate to repository
cd $repos
# Fetch and checkout specific hash
git fetch
git checkout $hash
# Go back to `catkin_ws/src`
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment