Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gith

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gith - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

test/payloads/pull-request.json

2

grunt.js

@@ -39,2 +39,2 @@ module.exports = function(grunt) {

};
};

@@ -85,3 +85,3 @@ /*

// assign the final result of this 'thing' to checksPassed
checksPassed = passed;
checksPassed = passed && checksPassed;
}

@@ -155,2 +155,4 @@ });

Gith.prototype.simplifyPayload = function( payload ) {
payload = payload || {};
var branch = '';

@@ -180,5 +182,5 @@ var tag = '';

branch: branch,
repo: payload.repository.owner.name + '/' + payload.repository.name,
repo: payload.repository ? (payload.repository.owner.name + '/' + payload.repository.name) : null,
sha: payload.after,
time: payload.repository.pushed_at,
time: payload.repository ? payload.repository.pushed_at : null,
urls: {

@@ -188,8 +190,8 @@ head: payload.head_commit ? payload.head_commit.url : '',

tag: '',
repo: payload.repository.url,
repo: payload.repository ? payload.repository.url : null,
compare: payload.compare
},
reset: !payload.created && payload.forced,
pusher: payload.pusher.name,
owner: payload.repository.owner.name
pusher: payload.pusher ? payload.pusher.name : null,
owner: (payload.repository && payload.repository.owner) ? payload.repository.owner.name : null
};

@@ -205,3 +207,3 @@

// populate files for every commit
payload.commits.forEach( function( commit ) {
(payload.commits || []).forEach( function( commit ) {
// github label and simpler label ( make 'removed' deleted to be consistant )

@@ -208,0 +210,0 @@ _.each( { added: 'added', modified: 'modified', removed: 'deleted' }, function( s, g ) {

{
"name": "gith",
"description": "gith[ooks] - a simple node server that responds to github post-receive events with meaningful data",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/danheberden/gith",

@@ -29,3 +29,3 @@ "author": {

"scripts": {
"test": "grunt test"
"test": "./node_modules/.bin/grunt test"
},

@@ -32,0 +32,0 @@ "dependencies": {

# gith
Version: 1.0.3
gith[ooks] - a simple node server that responds to github post-receive events with meaningful data

@@ -13,4 +15,4 @@

In your node application, require gith and create a gith server. You can specify a port now, or
you can use the `.listen( portNumber )` method later.
In your node application, require gith and create a gith server. You can specify a port now, or
you can use the `.listen( portNumber )` method later.

@@ -36,3 +38,3 @@ ```javascript

Be sure github.com is sending payload data to your server. From your repository root
Be sure github.com is sending payload data to your server. From your repository root
go to `Admin > Service Hooks > WebHook URLs` and add your server url, e.g., `http://mycoolserver.com:9001`.

@@ -42,3 +44,3 @@

The object passed into `gith()` can utilize four parameters (`repo`, `branch`, `file` and `tag`).
The object passed into `gith()` can utilize four parameters (`repo`, `branch`, `file` and `tag`).
All of these can either be an exact match string, a regular expression or a function.

@@ -77,3 +79,3 @@

The github payload is very detailed, but can be a bit excessive.
The github payload is very detailed, but can be a bit excessive.

@@ -109,2 +111,4 @@ This is the payload that gith gives you:

Note that this payload will only be fully available in case of standard `push` hooks (see below for more information).
## `gith()`

@@ -122,7 +126,7 @@

This closes the gith server
This closes the gith server
#### `gith.listen( port )`
If you didn't pass in a port to `.create()` when you required gith, this
If you didn't pass in a port to `.create()` when you required gith, this
will start the server on the specified port

@@ -135,4 +139,12 @@

## Using `gith` for other types of hooks
When you use Github UI to declare a web hook, it's only attached to the `push` event.
Whenever you want to attach you hook to other events, you will have to use [the API](http://developer.github.com/v3/repos/hooks/). In this case, `gith` may not be able to fully interpret the original payload, and you **should consider the *simplified payload* as unreliable**. In those cases, just use `payload.original`.
## License
Copyright (c) 2012 Dan Heberden
Licensed under the MIT license.

@@ -101,3 +101,3 @@ var githFactory = require('../lib/gith.js');

var gith = githFactory.create( 9001 );
var payloadObject = require('./payloads/add-file-and-dir.json');

@@ -132,3 +132,3 @@ var failSafe = false;

var gith = githFactory.create( 9001 );
var payloadObject = require('./payloads/add-file-and-dir.json');

@@ -162,3 +162,3 @@ var failSafe = false;

exports['gith filtering'] = {
exports['gith filtering'] = {
setUp: function( done ) {

@@ -171,3 +171,3 @@ done();

var gith = githFactory.create();
var test1 = gith({

@@ -207,2 +207,9 @@ repo: 'danheberden/payloads'

var test6 = gith({
repo: 'wrong/repo',
branch: 'merge-test'
}).on( 'all', function( payload ) {
test.ok( false, 'branch should have matched, but not repo, so.....' );
});
// this needs to be improved

@@ -219,3 +226,3 @@ setTimeout( function(){

var gith = githFactory.create();
var test1 = gith({

@@ -250,3 +257,3 @@ repo: /payloads/

exports['gith events'] = {

@@ -275,3 +282,3 @@ setUp: function( done ) {

g.on( 'file:delete', function( payload ) {
test.deepEqual( [ 'another2.txt' ], payload.files.deleted,
test.deepEqual( [ 'another2.txt' ], payload.files.deleted,
'delete branch event should have deleted branch' );

@@ -340,1 +347,21 @@ test.done();

};
exports['other hook types'] = {
setUp: function( done ) {
done();
},
'pull-request.json': function( test ) {
test.expect(1);
var json = require( './payloads/pull-request.json' );
var gith = githFactory.create();
var g = gith();
g.on( 'all', function( payload ) {
// No particular expectation except it must not crash and present original payload
test.equal(payload.original, json);
test.done();
});
gith.payload( json );
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc