Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created January 11, 2016 19:29
Show Gist options
  • Save patrickkettner/230d22c0f6397278f061 to your computer and use it in GitHub Desktop.
Save patrickkettner/230d22c0f6397278f061 to your computer and use it in GitHub Desktop.
match commits from a subdirectory to the github usernames that commited them
#!/bin/bash
SINCE_STRING="6.months.ago"
DIRECTORY_TO_CHECK="./test"
if [ ! -d $DIRECTORY_TO_CHECK ]; then
echo "$DIRECTORY_TO_CHECK does not exist - update the script"
exit 1
fi
GITHUB_URL=$(git config --get remote.origin.url | awk -F "[:|.]" '{print $3}')
COMMITS=$(git log --pretty=format:%H --since=$SINCE_STRING -- $DIRECTORY_TO_CHECK)
for commit in $COMMITS; do
result=$(curl "https://api.github.com/repos/$GITHUB_URL/commits/$commit" --silent | grep login | cut -d \" -f 4)
if [ -z "$result" ]; then
echo "no username found for $commit"
else
echo "$result"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment