constmessage=err?("Was not built:\r\n\r\n```\r\n"+err.substring(0,64000).replace(/```/g,"` ` `")+"\r\n```\r\n\r\nDO NOT MERGE!"):("Build OK\r\n\r\n"+successMessage);
constmessage=err?("Was not built:\r\n\r\n```\r\n"+err.substring(0,64000).replace(/```/g,"` ` `")+"\r\n```\r\n\r\nDO NOT MERGE!"):("Build OK\r\n\r\n"+successMessage);
conststatusUrlMessage="Build status URL: "+settings.siteRoot+"status/"+options.headRepoOptions.owner+"/"+options.headRepoOptions.reponame+"/"+options.headRepoOptions.rev+"\r\n\r\n";
conststatusUrlMessage="Build status URL: "+settings.siteRoot+"status/"+options.headRepoOptions.owner+"/"+options.headRepoOptions.reponame+"/"+options.headRepoOptions.rev+"\r\n\r\n";
console.log("Got push event for "+options.owner+"/"+options.reponame+":"+options.branch);
console.log("Got push event for "+options.owner+"/"+options.reponame+":"+options.branch);
builder.build(options,(err,result)=>{
builder.build(options,(err,result)=>{
console.log("Done processing request from GitHub");
console.log("Done processing request from GitHub");
console.log("Error: "+err);
console.log("Error: "+err);
//console.log("Result:");
//console.log("Result:");
//console.log(result);
//console.log(result);
res.send("Done processing request from GitHub\r\n"+"Error: "+err+"\r\n"+"Result: "+result);
res.send("Done processing request from GitHub\r\n"+"Error: "+err+"\r\n"+"Result: "+result);
});
});
};
};
constprocessPullRequest=(req,res,payload)=>{
constprocessPullRequest=(req,res,payload)=>{
constaction=payload.action;
constaction=payload.action;
constnumber=payload.number;
constnumber=payload.number;
constpullRequest=payload.pull_request;
constpullRequest=payload.pull_request;
consthead=pullRequest.head;
consthead=pullRequest.head;
constheadRepo=head.repo;
constheadRepo=head.repo;
constheadRepoOptions={
constheadRepoOptions={
url:headRepo.url,
url:headRepo.url,
owner:headRepo.owner.name||headRepo.owner.login,
owner:headRepo.owner.name||headRepo.owner.login,
reponame:headRepo.name,
reponame:headRepo.name,
rev:head.sha,
rev:head.sha,
branchname:head.ref,
branchname:head.ref,
branch:"refs/heads/"+head.ref
branch:"refs/heads/"+head.ref
};
};
constbase=pullRequest.base;
constbase=pullRequest.base;
constbaseRepo=base.repo;
constbaseRepo=base.repo;
constbaseRepoOptions={
constbaseRepoOptions={
owner:baseRepo.owner.name||baseRepo.owner.login,
owner:baseRepo.owner.name||baseRepo.owner.login,
reponame:baseRepo.name,
reponame:baseRepo.name,
branchname:base.ref
branchname:base.ref
};
};
constoptions={
constoptions={
app:req.app,
app:req.app,
action:action,
action:action,
number:number,
number:number,
headRepoOptions:headRepoOptions,
headRepoOptions:headRepoOptions,
baseRepoOptions:baseRepoOptions
baseRepoOptions:baseRepoOptions
};
};
constmasterOptions={
constmasterOptions={
app:req.app,
app:req.app,
action:action,
action:action,
number:number,
number:number,
headRepoOptions:baseRepoOptions,
headRepoOptions:baseRepoOptions,
baseRepoOptions:baseRepoOptions
baseRepoOptions:baseRepoOptions
};
};
console.log("Got pull request "+action+" event, from "+headRepoOptions.owner+"/"+headRepoOptions.reponame+":"+headRepoOptions.branchname+" ("+headRepoOptions.rev+") to "+baseRepoOptions.owner+"/"+baseRepoOptions.reponame+":"+baseRepoOptions.branchname);
console.log("Got pull request "+action+" event, from "+headRepoOptions.owner+"/"+headRepoOptions.reponame+":"+headRepoOptions.branchname+" ("+headRepoOptions.rev+") to "+baseRepoOptions.owner+"/"+baseRepoOptions.reponame+":"+baseRepoOptions.branchname);