New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

git2consul

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git2consul - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

@@ -13,2 +13,4 @@ var _ = require('underscore');

var utils = require('../utils.js');
var hook_providers = {

@@ -21,13 +23,19 @@ 'bitbucket' : require('./hooks/webhook.js').bitbucket,

/**
* Create a new repo. This will perform a number of validations, throwing an exception if any fail.
* It will also set up the internal state of the object, including a Branch object for every branch
* in the repo, but initialization of the branches and repos is deferred to the init method.
*/
function Repo(repo_config) {
var this_obj = this;
// TODO: Throw if local_store isn't set.
// TODO: Throw if local_store doesn't exist on the fs.
if (!repo_config) throw new Error('No configuration provided for repo');
if (!repo_config) throw new Error('No configuration provided for repo');
if (!repo_config.url || !repo_config.name || !repo_config.branches) {
throw new Error("A repo must have a url, a name, and a branch array.");
if (!repo_config.local_store || !repo_config.url || !repo_config.name || !repo_config.branches) {
throw new Error("A repo must have a local_store, a url, a name, and a branch array.");
}
// Check to make sure local_store is valid and writeable.
utils.validate_writeable_directory(repo_config.local_store);
if (repo_config.branches.length === 0) {

@@ -34,0 +42,0 @@ throw new Error('No branches specified.');

{
"name": "git2consul",
"description": "System for moving data from git to consul",
"version": "0.7.2",
"version": "0.7.3",
"contributors": [

@@ -6,0 +6,0 @@ {

@@ -7,2 +7,5 @@ var _ = require('underscore');

var fs = require('fs');
var rimraf = require('rimraf');
var git = require('../lib/git/');

@@ -24,3 +27,4 @@ var git_commands = require('../lib/git/commands.js');

[{}, {'name':'incomplete'}, {'name':'incomplete', 'branches': ['master']}].forEach(function(config) {
[{}, {'local_store':'/tmp/test_workspace'}, {'local_store':'/tmp/test_workspace', 'name':'incomplete'},
{'local_store':'/tmp/test_workspace', 'name':'incomplete', 'branches': ['master']}].forEach(function(config) {
try {

@@ -30,3 +34,3 @@ var repo = new Repo(config);

} catch(e) {
e.message.should.equal('A repo must have a url, a name, and a branch array.');
e.message.should.equal('A repo must have a local_store, a url, a name, and a branch array.');
}

@@ -70,5 +74,40 @@ });

it ('should reject a repo with a non-existent local_store', function() {
try {
var repo = new Repo({'name': 'non_existent_local_store_repo', 'url': 'http://www.github.com/',
'local_store':'/var/i_dont_live_here', 'branches': ['master']});
should.fail("Repo with non-existent local_store should throw an exception");
} catch(e) {
e.message.should.equal('directory /var/i_dont_live_here does not exist');
}
});
it ('should reject a repo with a non-writeable local_store', function() {
try {
fs.writeFileSync('/tmp/not_a_directory', 'oops');
var repo = new Repo({'name': 'non_directory_local_store_repo', 'url': 'http://www.github.com/',
'local_store':'/tmp/not_a_directory', 'branches': ['master']});
should.fail("Repo with non-writeable local_store should throw an exception");
} catch(e) {
e.message.should.equal('/tmp/not_a_directory is not a directory');
}
try {
rimraf.sync('/tmp/test_directory');
fs.mkdirSync('/tmp/test_directory');
fs.chmodSync('/tmp/test_directory', parseInt(555, 8));
var repo = new Repo({'name': 'unwriteable_directory', 'url': 'http://www.github.com/',
'local_store':'/tmp/test_directory', 'branches': ['master']});
should.fail("Repo with non-writeable directory should throw an exception");
} catch(e) {
e.message.should.equal('/tmp/test_directory is not writeable');
} finally {
rimraf.sync('/tmp/test_directory');
}
});
it ('should reject a repo with duplicate branches', function() {
try {
var repo = new Repo({'name': 'busted_dupe_branch_repo', 'url': 'http://www.github.com/', 'branches': ['master', 'master', 'commander']});
var repo = new Repo({'name': 'busted_dupe_branch_repo', 'url': 'http://www.github.com/',
'local_store':'/tmp/test_workspace', 'branches': ['master', 'master', 'commander']});
should.fail("Repo with duplicate branches should throw an exception");

@@ -82,3 +121,4 @@ } catch(e) {

try {
var repo = new Repo({'name': 'busted_empty_branch_repo', 'url': 'http://www.github.com/', 'branches': []});
var repo = new Repo({'name': 'busted_empty_branch_repo', 'local_store':'/tmp/test_workspace',
'url': 'http://www.github.com/', 'branches': []});
should.fail("Repo with no branches should be denied.");

@@ -85,0 +125,0 @@ } catch(e) {

Sorry, the diff of this file is not supported yet