lib/container.js
function build(mode, system, cdef, out, cb) {
    var cmd = cdef.specific.processBuild || cdef.specific.build;
    var branch = '';

    logger.info('building');
    out.stdout('building');

    if (!cmd) { return cb(null, {}); }
    if (!cdef.specific.repositoryUrl) { return cb(new Error('missing repositoryUrl'), {}); }

    //var parsed = parseGitUrl(cdef.specific.repositoryUrl).branch;
    var parsed = parseGitUrl(cdef.specific.repositoryUrl);
    if (parsed.branch) {
      branch = parsed.branch;
    }

    if (cdef.specific.commit) {
      var synchCommand =  [
        [
          ' ( ' +
          'test `git show-ref --hash refs/heads/' + branch +'` = ' + cdef.specific.commit,
          ' && ',
          'git checkout -q ' + branch,
          ' ) ',
          ' || ',
          'git checkout -q ' + cdef.specific.commit
        ].join(' '),
        'echo checked out ' + cdef.specific.commit,
      ].join(' && ');

      executor.exec(mode, synchCommand, pathFromRepoUrl(system, cdef), out, function(err) {
        if (err) { return cb(err); }
        executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb);
      });
    }
    else {
      executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb);
    }
  }
function build(mode, system, cdef, out, cb) {
    var cmd = cdef.specific.processBuild || cdef.specific.build;
    var branch = '';

    logger.info('building');
    out.stdout('building');

    if (!cmd) { return cb(null, {}); }
    if (!cdef.specific.repositoryUrl) { return cb(new Error('missing repositoryUrl'), {}); }

    //var parsed = parseGitUrl(cdef.specific.repositoryUrl).branch;
    var parsed = parseGitUrl(cdef.specific.repositoryUrl);
    if (parsed.branch) {
      branch = parsed.branch;
    }

    if (cdef.specific.commit) {
      var synchCommand =  [
        [
          ' ( ' +
          'test `git show-ref --hash refs/heads/' + branch +'` = ' + cdef.specific.commit,
          ' && ',
          'git checkout -q ' + branch,
          ' ) ',
          ' || ',
          'git checkout -q ' + cdef.specific.commit
        ].join(' '),
        'echo checked out ' + cdef.specific.commit,
      ].join(' && ');

      executor.exec(mode, synchCommand, pathFromRepoUrl(system, cdef), out, function(err) {
        if (err) { return cb(err); }
        executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb);
      });
    }
    else {
      executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb);
    }
  }
build the container
system - the system definition
cdef - contianer definition block
out - ouput stream
cb - complete callback