get payload
This commit is contained in:
committed by
mrugesh mohapatra
parent
8a94cdda60
commit
c2790fbb2d
@ -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/
|
||||||
}
|
}*/
|
||||||
|
41
probot/presolver/lib/presolver.js
Normal file
41
probot/presolver/lib/presolver.js
Normal 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;
|
Reference in New Issue
Block a user