avp::ptr weblog

Everything that is in our mind.

Archive for the ‘post-receive’ tag

Colored Diffs add-on for Thunderbird

with 2 comments

Reading todays post-hook emails with the latest diffs of some project the thought rushed to my head that it would be nice to have the diffs displayed in color. Since I am using Thunderbird as my email client I found a great add-on named “Colored Diff”.

Although, the add-on seems to be outdated to work with the latest Thunderbird version (which is 10.0 right now) there is an easy way to install the add-on while the automatic installer refuses to do so. Here is what you can do to make the installation work.

  1. Download the colored diffs *.xpi file
  2. Open the archive with an archive manager of your choice
  3. Edit the contained install.rdf with a text editor of your choice
  4. Change the maxVersion parameter to be equal or greater then the current version of Thunderbird
    Before: <em:maxVersion>3.1.*</em:maxVersion>
    After: <em:maxVersion>13.1.*</em:maxVersion>
  5. Save the changes and store them back into the archive
  6. Install the add-on

Do not forget to check out the preferences after you installed the add-on. You can choose 4 different types to display the diffs and customize the colors as well.

If you feel interested to enhance the add-on you can do so. The “Colored diffs” project is hosted on Google Code open for people to participate.

Written by tobi

February 8th, 2012 at 4:33 pm

How to update your web site using git?

without comments

There is a smart way to keep your web site up-to-date when you use a git repository to manage your HTML sources. You can use a post-receive hook to immediately send changes to your httpdocs folder whenever you push changes to the repository. Here are the actions to do.

  1. Grant write access to the httpdocs folder for the user/group git.
  2. Add a detached worktree to the git configuration.
  3. Add the checkout command to the post-receive hook.

1. Grant write access to the httpdocs folder for the user/group git

You need to enable the user that runs the post-receive hook to write to the webserver folder. The user typically is git or the group git. Edit the sudoer file using the visudo command to grant access to the aforementioned folder.

%git ALL=(ALL) NOPASSWD: /usr/bin/git

Read this documentation to understand the sudoer file and another helpful posting from Gilles on sudoer parameters. My best regards go out to Abhijit Menon-Sen who helped me to understand the sudoer commands.

2. Add a detached worktree to the git configuration.

Following the tutorial of Abhijit Menon-Sen on “using git to manager a web site” you need to change your configuration as follows.

$ git config core.worktree /var/www/www.domain.com/httpdocs/
$ git config core.bare false
$ git config receive.denycurrentbranch ignore

3. Add the checkout command to the post-receive hook.

Finally add the command to the post-receive script that will update your web site httpdocs folder.

$ sudo git checkout -f

The git checkout command is run in the context of the root user. This context switch is allowed via the sudoer file edited earlier. The switch is necessary to gain write access to the location of the detached worktree which is httpdocs.

Written by tobi

October 2nd, 2010 at 2:22 pm