Created
October 6, 2015 15:10
-
-
Save romainPrignon/a48697bb1f85706d0910 to your computer and use it in GitHub Desktop.
Iterate over directories and display yesterday's commits
This file contains hidden or 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/sh | |
| # color | |
| RESTORE='\033[0m' | |
| GREEN='\033[00;32m' | |
| currentDir=$(pwd) | |
| workspace=$1 | |
| author=$2 | |
| atLeastOneCommit=false | |
| # exit if there's no workspace to check | |
| if [ -z "$workspace" ]; then | |
| echo "Exit ! You need to specify a working directory" | |
| exit 1 | |
| fi | |
| # exit if there's no author | |
| if [ -z "$author" ]; then | |
| echo "Exit ! You need to specify an author" | |
| exit 1 | |
| fi | |
| # go into workspace | |
| cd ${workspace} | |
| # iterate over directory in workspace | |
| for dir in */ | |
| do | |
| dir=${dir%*/} | |
| #go into current dir of iteration | |
| cd ${dir} | |
| # if is git repo | |
| if [ -d .git ]; then | |
| #save yeasterday commits | |
| commits=$(git log --since '1 day ago' --oneline --author ${author}) | |
| # if there is some commits | |
| if [ -n "$commits" ]; then | |
| # display them | |
| echo "Yesterday's commits for project : ${GREEN}${dir##*/}${RESTORE} \n" | |
| echo "${commits}" | |
| echo "\n\n" | |
| # there was at least one commit | |
| atLeastOneCommit=true | |
| fi; | |
| fi; | |
| # go back | |
| cd .. | |
| done | |
| if [ $atLeastOneCommit = false ] ; then | |
| echo "No commits yesterday ? :p" | |
| fi | |
| # go back where we where | |
| cd ${currentDir} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment