Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Angular Commit Message Conventions git hook, so you got your commit prepared to with the messages they expect ;)
#!/bin/bash
firstLine=`head -2 $1 | tail -1`
if [[ $firstLine == \#* ]]; then # Testing that the file starts with a comment, not yet a real commit ;)
echo '<type>(<component>): <subject>' > .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '<body>' >> .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '# types: feat, fix, docs, style, refactor, test, chore(mantean)' >> .prepare-commit-msg-temp
{ cat .prepare-commit-msg-temp; cat $1; } > .prepare-commit-msg-temp2
cat .prepare-commit-msg-temp2 > $1
rm .prepare-commit-msg-temp .prepare-commit-msg-temp2
fi
@FranklinYu

This comment has been minimized.

Copy link

@FranklinYu FranklinYu commented May 9, 2016

mantean -> maintain?

@mochadwi

This comment has been minimized.

Copy link

@mochadwi mochadwi commented Jun 2, 2019

How to use this? Do we only have to copy the script to our .git/hooks? I've tried, but no success @aemonge

@aemonge

This comment has been minimized.

Copy link
Owner Author

@aemonge aemonge commented Jun 3, 2019

Yes! It's supposed to do so, can you share with me your environment.

@jmaumene

This comment has been minimized.

Copy link

@jmaumene jmaumene commented Jul 31, 2020

Try to add this on the first line :

#!/bin/bash

and make runnable :

chmod +x prepare-commit-msg

@aemonge

This comment has been minimized.

Copy link
Owner Author

@aemonge aemonge commented Aug 3, 2020

Thanks ! (I've made the change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.