Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function commit(user, repo, commit, options, callback) {
var branch = commit.branch || 'master'
var message = commit.message
var updates = commit.updates
var shaLatestCommit, shaBaseTree, shaNewTree, shaNewCommit
return Promise.from(null).then(function () {
//check for correct input
assert(user && typeof user === 'string', '`user` must be a string')
assert(repo && typeof repo === 'string', '`repo` must be a string')
assert(branch && typeof branch === 'string', '`branch` must be a string')
assert(message && typeof message === 'string', '`message` must be a string')
updates = Promise.all(updates.map(function (file) {
// {path: string, content: string|Buffer}
assert(typeof file.path === 'string', '`file.path` must be a string')
assert(typeof file.content === 'string' || Buffer.isBuffer(file.content), '`file.content` must be a string or a Buffer')
var path = file.path.replace(/\\/g, '/').replace(/^\//, '')
var mode = file.mode || '100644'
var type = file.type || 'blob'
return github.json('post', '/repos/:owner/:repo/git/blobs', {
owner: user,
exports.update = function(req, res) {
debug("Create/update client: %j", req.body);
var Client = req.app.globals.Client;
Promise.from(null).then(function() {
// Create client if requested
if (req.body.updateOrCreate == 'create') {
return Client.create({
version: '0.2.0',
name: req.body.name,
clientId: slugid.v4(),
accessToken: slugid.v4() + slugid.v4() + slugid.v4(),
scopes: JSON.parse(req.body.scopes),
expires: new Date(req.body.expires),
details: {
notes: req.body.notes
}
});
}
// Update WorkerType if requested
var retryLoop = function() {
// Apply modifier to properties
var modified = Promise.from(modifier.call(properties));
// When modified attempt to update
return modified.then(function() {
var updated = attemptUpdate();
// If update fails we retry it gain
return updated.catch(function(err) {
// Rethrow error, if this didn't happen because of an etag mismatch
if (err.code != 'UpdateConditionNotSatisfied') {
debug(
"Update of entity failed unexpectedly, %s, as JSON: %j",
err, err, err.stack
);
throw err;
}
var retryLoop = function() {
// Apply modifier to properties
var modified = Promise.from(modifier.call(properties));
// When modified attempt to update
return modified.then(function() {
var updated = attemptUpdate();
// If update fails we retry it gain
return updated.catch(function(err) {
// Rethrow error, if this didn't happen because of an etag mismatch
if (err.code != 'UpdateConditionNotSatisfied') {
debug(
"Update of entity failed unexpectedly, %s, as JSON: %j",
err, err, err.stack
);
throw err;
}
try {
return fn(owin).then(function(){
if (expand) { owinContext.shrinkContext(owin); }
owin = null;
},
function(err){
owinDefaultError.call(owin, err);
if (expand) { owinContext.shrinkContext(owin); }
});
}
catch (err)
{
owinDefaultError.call(owin,err);
if (expand) { owinContext.shrinkContext(owin); }
return Promise.from(null);
}
};
};
prev = function (){return Promise.from(null);};
while (i--) {
return function(req, res) {
Promise.from().then(function() {
return handler.call(context, req, res);
}).catch(function(err) {
var incidentId = uuid.v4();
debug(
"Error occurred handling: %s, err: %s, as JSON: %j, incidentId: %s",
req.url, err, err, incidentId, err.stack
);
res.json(500, {
message: "Internal Server Error",
error: {
info: "Ask administrator to lookup incidentId in log-file",
incidentId: incidentId
}
});
});
};
function owinDefaultApp(next){
if (this[constants.owinjs.Error])
{
return Promise.reject(this[constants.owinjs.Error]);
}
else if (this.response.statusCode === null)
{
return Promise.reject(404);
}
else
{
return Promise.from(null);
}
}
options.handler = function(req, res) {
Promise.from(handler(req, res)).then(undefined, function(err) {
var incidentId = uuid.v4();
debug(
"Error occurred handling: %s, err: %s, as JSON: %j, incidentId: %s",
options.route, err, err, incidentId, err.stack
);
res.json(500, {
message: "Internal Server Error",
error: {
info: "Ask administrator to lookup incidentId in log-file",
incidentId: incidentId
}
});
});
};
options.handler = function(req, res) {
Promise.from(handler(req, res)).catch(function(err) {
var incidentId = uuid.v4();
debug(
"Error occurred handling: %s, err: %s, as JSON: %j, incidentId: %s",
options.route, err, err, incidentId, err.stack
);
res.json(500, {
message: "Internal Server Error",
error: {
info: "Ask administrator to lookup incidentId in log-file",
incidentId: incidentId
}
});
});
};