Last active
December 22, 2015 12:29
-
-
Save markhalliwell/6473218 to your computer and use it in GitHub Desktop.
Drupal project post commit (copies thanks and commit link to pasteboard). Follow instructions at https://coderwall.com/p/jp7d5q
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 | |
| # Ensure repo is hosted on drupal.org. | |
| repoRemote=`git remote -v | grep push | perl -lne 'print $& if /git\.drupal\.org[:\/]project\/[^.]*/'`; | |
| if [ ! -z "${repoRemote}" ]; then | |
| # Extract the project and commit info. | |
| project=`echo "${repoRemote}" | sed -e 's/git\.drupal\.org[:\/]//'`; | |
| commitHash=`git log -n 1 --pretty=format:"%h"`; | |
| commitName=`git log -n 1 --pretty=format:"%cn"`; | |
| commitMessage=`git log -n 1 --pretty=format:"%B"`; | |
| authorName=`git log -n 1 --pretty=format:"%an"`; | |
| if [ "${commitName}" != "${authorName}" ]; then | |
| authorName="Thanks @${authorName}!\n\n"; | |
| else | |
| authorName=''; | |
| fi | |
| upstreamBranch="$(git rev-parse --symbolic-full-name --abbrev-ref @{u} | cut -d '/' -f2)"; | |
| if [[ ! -z "${upstreamBranch}" ]]; then | |
| upstreamBranch=" to <a href=\"http://drupalcode.org/${project}.git/shortlog/refs/heads/${upstreamBranch}\">${upstreamBranch}</a>"; | |
| fi | |
| printf "${authorName}Committed <a href=\"http://drupalcode.org/${project}.git/commitdiff/$commitHash\">${commitHash}</a>${upstreamBranch}:\n<blockquote>\n${commitMessage}\n</blockquote>" | pbcopy; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment