get payload

This commit is contained in:
tbushman
2018-10-31 20:23:44 -06:00
committed by mrugesh mohapatra
parent 8a94cdda60
commit c2790fbb2d
2 changed files with 72 additions and 2 deletions

View File

@ -1,4 +1,33 @@
module.exports = app => { const Presolver = require('./lib/presolver');
function probotPlugin(robot) {
const events = [
"pull_request.opened",
"pull_request.edited",
"pull_request.synchronize",
"pull_request.reopened"
];
robot.on(events, presolve);
}
async function presolve(context) {
const presolverContext = getRepository(context);
const pullRequest = getPullRequest(context);
}
function getRepository(context) {
const config = Object.assign(context.repo());
return new Presolver(context.github, config);
}
function getPullRequest(context) {
return context.payload.pull_request || context.payload.review.pull_request;
}
module.exports = probotPlugin;
/*module.exports = async app => {
// Your code here // Your code here
app.log('Yay, the app was loaded!') app.log('Yay, the app was loaded!')
@ -12,4 +41,4 @@ module.exports = app => {
// To get your app running against GitHub, see: // To get your app running against GitHub, see:
// https://probot.github.io/docs/development/ // https://probot.github.io/docs/development/
} }*/

View File

@ -0,0 +1,41 @@
class Presolver {
constructor(github, { owner, repo, logger = console, ...config }) {
this.github = github;
this.logger = logger;
this.config = Object.assign({
owner,
repo
});
this.pullRequest = {};
}
static get STATE() {
return Object.freeze({
CLASH: 'clashing'
})
async _getClashingRanges(pullRequest) {
Object.assign(this.pullRequest, pullRequest);
const { owner, repo } = this.config;
const number = this.pullRequest.number;
const prs = (await this.github.pullRequests.get({ owner, repo }))
.data || [];
this.logger(prs)
prs.forEach(function(pr){
const files = pr.files()
})
}
async presolve(pullRequest) {
Object.assign(this.pullRequest, pullRequest);
const { owner, repo } = this.config;
const number = this.pullRequest.number;
const state = await this._getClashingRanges(pullRequest);
}
}
module.exports = Presolver;