An EventEmitter built on top of GitHub post-receive hooks.
npm install git-notifier
var server = require( "git-notifier" ).createServer();
server.listen( 8000 );
server.on( "scottgonzalez/node-git-notifier/heads/**", function( data ) {
console.log( "New commit: " + data.commit );
});
All events follow a simple format: {username}/{repo}/{refspec}
The server is an EventEmitter2 instance and therefore supports namespacing, which makes the notifier quite powerful and flexible.
All events receive a single data parameter with the following properties:
commit
: The SHA of the last commit.owner
: The owner of the repo.repo
: The name of the repo.raw
: The raw post-receive data.
Note: Commits to a branch contain a branch
property in the data.
Listen for commits on the master branch:
server.on( "scottgonzalez/node-git-notifier/heads/master", function( data ) {
console.log( "New commit on master: " + data.commit );
});
Listen for commits on a namespaced branch:
server.on( "scottgonzalez/node-git-notifier/heads/some/deep/branch", function( data ) {
console.log( "New commit on some/deep/branch: " + data.commit );
});
Listen for commits on any branch in a specific namespace:
server.on( "scottgonzalez/node-git-notifier/heads/ns/**", function( data ) {
console.log( "New commit on " + data.branch + ": " + data.commit );
});
Listen for commits on any branch:
server.on( "scottgonzalez/node-git-notifier/heads/**", function( data ) {
console.log( "New commit on " + data.branch + ": " + data.commit );
});
Note: Commits to a tag contain a tag
property in the data.
server.on( "scottgonzalez/node-git-notifier/tags/*", function( data ) {
console.log( "Created new tag: " + data.tag );
});
server.on( "scottgonzalez/node-git-notifier/**", function( data ) {
console.log( "More activity on node-git-notifier..." );
});
server.on( "scottgonzalez/**", function( data ) {
console.log( "More activity on " + data.repo + "..." );
});
server.on( "**", function( data ) {
console.log( "More activity on " + data.owner + "/" + data.repo + "..." );
});
Copyright 2012 Scott González
node-git-notifier is released under the MIT license.