Symfony2 Team Trick For Your Github PR commits

Since many weeks or months ago I wanted to have this script that would take my ticket # from github but specified in my local branch `feature/1234` and would mark my commits with the corresponding message appended with `[#1234]` so they would link automatically on github and would read nicely `[#1234] thanks my friends for your comments, I have addressed them`.

I found this nice blog post with the solution but I have adapted it to install system wide and also in one go.

// this will install into your .git/hooks/prepare-commit-msg the script working as shown below
cd path/to/my/project/directory
curl -s https://raw.github.com/gist/c56ebdff6f80e4b5c978 | sh

Once you are done you can do:

// after doing some changes in my project on branch `feature/1`
~/sites-2/vespolina-project.site (feature/1 *%)
~ git st
# On branch feature/1
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   .gitignore
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	app/config/parameters.yml.dist
no changes added to commit (use "git add" and/or "git commit -a")
~/sites-2/vespolina-project.site (feature/1 *%)
~ git ca "move parameters.yml into parameters.yml.dist"
[feature/1 2c614cd] [#1] move parameters.yml into parameters.yml.dist
 2 files changed, 20 insertions(+)
 create mode 100644 app/config/parameters.yml.dist
~/sites-2/vespolina-project.site (feature/1)
* 2c614cd - (HEAD, feature/1) [#1] move parameters.yml into parameters.yml.dist (0 seconds ago) <Luis Cordova>

Did you notice how pretty it looks now the git commit message? you missed it.

* 2c614cd - (HEAD, feature/1) [#1] move parameters.yml into parameters.yml.dist (0 seconds ago) <Luis Cordova>

If you liked my adaptation of this little script feel free to donate/support me to write more! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *