lib/web/handlers/api.js
function deploy(req, res) {
    var stackName = req.params.stack,
        regionName = req.params.region,
        name = req.remoteUser.name;

    function _deploy(to_revision) {
      async.waterfall([
        dreadnot.deploy.bind(dreadnot, stackName, regionName, to_revision, name),

        function(number, callback) {
          dreadnot.getDeploymentSummary(stackName, regionName, number, callback);
        }
      ], res.respond);
    }

    //Make the to_revision field optional
    if (typeof req.body !== 'undefined') {
      if (req.body.to_revision) {
        // Deploy to a specified revision
        _deploy(req.body.to_revision);
      } else if (req.body.username && req.body.password) {
        // Deploy to the latest git commit on the repo or the specified branch
        // username and password are git username and password with sufficient credentials
        _getLatestRevision(req, function (err, sha) {
          if (err) {
            res.respond(err);
          } else {
            _deploy(sha);
          }
        });
      } else {
        // Redeploy last deployed revision
        dreadnot.getDeployedRevision(req.params.stack, req.params.region, function(err, data) {
          if (err) {
            res.respond(err);
          } else {
            _deploy(data["deployed_revision"]);
          }
        });
      }
    }
  }
function deploy(req, res) {
    var stackName = req.params.stack,
        regionName = req.params.region,
        name = req.remoteUser.name;

    function _deploy(to_revision) {
      async.waterfall([
        dreadnot.deploy.bind(dreadnot, stackName, regionName, to_revision, name),

        function(number, callback) {
          dreadnot.getDeploymentSummary(stackName, regionName, number, callback);
        }
      ], res.respond);
    }

    //Make the to_revision field optional
    if (typeof req.body !== 'undefined') {
      if (req.body.to_revision) {
        // Deploy to a specified revision
        _deploy(req.body.to_revision);
      } else if (req.body.username && req.body.password) {
        // Deploy to the latest git commit on the repo or the specified branch
        // username and password are git username and password with sufficient credentials
        _getLatestRevision(req, function (err, sha) {
          if (err) {
            res.respond(err);
          } else {
            _deploy(sha);
          }
        });
      } else {
        // Redeploy last deployed revision
        dreadnot.getDeployedRevision(req.params.stack, req.params.region, function(err, data) {
          if (err) {
            res.respond(err);
          } else {
            _deploy(data["deployed_revision"]);
          }
        });
      }
    }
  }
Handle attempted deployments. Redirect to the deployment on success. On stack locked errors, redirect to the region view, otherwise a full error view.