Adding diff to Gitorious push notification emails

One thing we were really missing in

Gitorious is lack of diff in email notifications. We were using this feature in SVN for “quick code review”. Before we moved to Gitorious, we were using Gitolite where it was possible to configure it with git .hooks. However in Gitorious you do not have easy access to your repository directory ( it’s hashed ). So I have started googling about the feature. I have found in Gitorious a misterious feature called webhooks. But what it does is sending HTTP requests with JSON objects about commits, but without diff body. After loosing few more hours on google, forums and different groups I decided to try to implement this feature on my own. Few more hours to understand this mysterious ( for me ) Ruby on Rails code of Gitorious and I have localized few files that I should change to make it working. After all I have to say it was quite simple. The core are two lines that create commit diff in lib/event_rendering/text.rb:   repo = Repository.find_by_name_in_project!(event.target.name, event.project) diff_content = repo.git.git.show({}, [start_sha, end_sha].join(“..”))   (If you would like to modify content of the commit diff you just have to modify this git.git call ). Rest of the code is just for putting diff_content value into email :). You can review the whole patch here. After applying the patch please remember to restart git-poller and subscribe in Gitorious to email notification.

You May Also Like

New HTTP Logger Grails plugin

I've wrote a new Grails plugin - httplogger. It logs:

  • request information (url, headers, cookies, method, body),
  • grails dispatch information (controller, action, parameters),
  • response information (elapsed time and body).

It is mostly useful for logging your REST traffic. Full HTTP web pages can be huge to log and generally waste your space. I suggest to map all of your REST controllers with the same path in UrlMappings, e.g. /rest/ and configure this plugin with this path.

Here is some simple output just to give you a taste of it.

17:16:00,331 INFO  filters.LogRawRequestInfoFilter  - 17:16:00,340 INFO  filters.LogRawRequestInfoFilter  - 17:16:00,342 INFO  filters.LogGrailsUrlsInfoFilter  - 17:16:00,731 INFO  filters.LogOutputResponseFilter  - >> #1 returned 200, took 405 ms.
17:16:00,745 INFO filters.LogOutputResponseFilter - >> #1 responded with '{count:0}'
17:18:55,799 INFO  filters.LogRawRequestInfoFilter  - 17:18:55,799 INFO  filters.LogRawRequestInfoFilter  - 17:18:55,800 INFO  filters.LogRawRequestInfoFilter  - 17:18:55,801 INFO  filters.LogOutputResponseFilter  - >> #2 returned 404, took 3 ms.
17:18:55,802 INFO filters.LogOutputResponseFilter - >> #2 responded with ''

Official plugin information can be found on Grails plugins website here: http://grails.org/plugins/httplogger or you can browse code on github: TouK/grails-httplogger.