Пример #1
0
var bitBucket = function*(body, confFile) {
  var conf = yield misc.readConf(confFile);
  var repo = body.repository.absolute_url.substring(1, body.repository.absolute_url.length-1);
  var combos = [];

  if (conf.providers.bitbucket.hasOwnProperty(repo)) {
    for (var i = 0; i < body.commits.length; i++) {
      var branch = body.commits[i].branch;

      if (conf.providers.bitbucket[repo].hasOwnProperty(branch)) {
        var combo = {
            repo: repo
          , branch: branch
          , conf: conf.providers.bitbucket[repo][branch]
        };

        if (!misc.isIn(combos, combo)) {
          combos.push(combo);
        }
      }
    }
  }

  return combos;
};
Пример #2
0
var gitHub = function*(body, confFile) {
  var conf = yield misc.readConf(confFile);
  var combos = [];

  if (body.hasOwnProperty('repository')) {
    var repo = body.repository.full_name;
    var branch = body.ref.split('/')[2];
    
    if (conf.providers.github.hasOwnProperty(repo) &&
        conf.providers.github[repo].hasOwnProperty(branch)) {
      combos.push({
          repo: repo
        , branch: branch
        , conf: conf.providers.github[repo][branch]
      });
    }
  }

  return combos;
};
Пример #3
0
 it('should read the file and return an object with its contents', function*() {
   var repos = yield misc.readConf('repos.json.template');
   expect(repos).to.be.an('object');
   expect(repos).to.deep.equal({
       "version": "0.0.1"
     , "providers": {
           "bitbucket": {
             "repo/path": {
                 "branch": {
                     "host": "branch.example.com"
                   , "test_commands": [
                       "npm test"
                     ]
                 }
               , "other_branch": {
                     "host": "other.branch.example.com"
                   , "test_commands": [
                       "npm test"
                     ]
                 }
             }
           }
         , "github": {
             "github/repo": {
                 "another_branch": {
                     "host": "another.branch.example.com"
                   , "test_commands": [
                       "lein test"
                     ]
                 }
               , "yet_another_branch": {
                     "host": "yet.another.branch.example.com"
                   , "test_commands": [
                       "lein test"
                     ]
                 }
             }
           } 
       }
   });
 });