Last active
January 7, 2017 01:17
-
-
Save eduard-sukharev/4dd421c02d4bd74ff066 to your computer and use it in GitHub Desktop.
Git hook to Prepare PR message when developing with TFS (put into .git/hooks, add executable rights and create pr_messages 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
#!/bin/sh | |
# Git hook to: | |
# Run phpunit tests | |
# Prepare GitHub formatted PR message with links to TMS | |
# Copy PR message into KDE clipboard management tool (Klipper) | |
# put it into .git/hooks, add executable rights and create pr_messages directory | |
tms_name="JIRA" | |
tms_prefix="http://jira.com/browse/" | |
unittest="vendor/bin/phpunit -c tests/" | |
merge_branch="master" | |
eval $unittest | |
if [ $? -ne 0 ] | |
then | |
echo "Unit test execution failed. Pushing to repository aborted." | |
exit 1 | |
fi | |
PBI=`git symbolic-ref --short HEAD` | |
echo "**$tms_name Item: $PBI:**\n" > pr_messages/$PBI.md | |
git log $merge_branch..HEAD --format=" - [x] %B" >> pr_messages/$PBI.md | |
sed -r -i "s|([A-Z]{3,}-[0-9]{4,})|[[\\1]($tms_prefix\\1)]|g" pr_messages/$PBI.md | |
cat pr_messages/$PBI.md | |
output=$(cat pr_messages/$PBI.md) | |
qdbus org.kde.klipper /klipper setClipboardContents "$output" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment