Last active
July 26, 2018 13:51
-
-
Save ferrolho/d276d58a3ec683ff12a38d22246d6d9b to your computer and use it in GitHub Desktop.
Outputs the hash code and repository name under `catkin_ws/src`
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 | |
# 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 |
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 | |
# 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