Created
August 25, 2016 15:14
-
-
Save cgutierrez/9c6149193b3091c7864f362b93216ac8 to your computer and use it in GitHub Desktop.
Create a commit log of all the repositories in a directory
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
#!/usr/bin/env sh | |
PROJECTS_DIR=$HOME/Desktop/Werk/mode | |
LOG_FILE=$PROJECTS_DIR/commits.txt | |
AUTHOR='Chris Gutierrez' | |
# store the current dir | |
CUR_DIR=$(pwd) | |
#hey user | |
echo "Building your commit log from yesterday..." | |
cd $PROJECTS_DIR | |
rm -f $LOG_FILE | |
touch $LOG_FILE | |
# Find all git repositories and update them to their latest revision on current branch | |
for i in $(find . -name ".git" | cut -c 3-); do | |
#ignore submodules, vendor, composer, and bins | |
if [[ "$i" != *libraries* && "$i" != *deployment* && "$i" != *vendor* && "$i" != *bin* ]] | |
then | |
PROJECT_DIR=$(dirname $i) | |
echo "checking $PROJECT_DIR..."; | |
#We have to go to the .git parent directory to call the pull command | |
cd $PROJECT_DIR; | |
CMD="git --no-pager log --reverse --author='$AUTHOR' --date=short --since='yesterday' --pretty=format:'%h%x09%ad%x09%s'" | |
LOG_OUTPUT=$(eval $CMD) | |
if [ ! -z "$LOG_OUTPUT" ]; then | |
echo $(basename `pwd`) >> $LOG_FILE | |
echo "$LOG_OUTPUT" >> $LOG_FILE | |
echo "\n" >> $LOG_FILE | |
fi | |
#lets get back to the PROJECTS_DIR and get more gits | |
cd $PROJECTS_DIR | |
fi | |
done | |
open $LOG_FILE | |
cd $CUR_DIR | |
echo "Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment