problem setting permissions
This commit is contained in:
committed by
mrugesh mohapatra
parent
14471dc4fd
commit
0e5a338ac2
@ -36,12 +36,12 @@ default_events:
|
|||||||
# - project_column
|
# - project_column
|
||||||
# - public
|
# - public
|
||||||
- pull_request
|
- pull_request
|
||||||
# - pull_request_review
|
- pull_request_review
|
||||||
# - pull_request_review_comment
|
- pull_request_review_comment
|
||||||
# - push
|
# - push
|
||||||
# - release
|
# - release
|
||||||
# - repository
|
- repository
|
||||||
# - repository_import
|
- repository_import
|
||||||
# - status
|
# - status
|
||||||
# - team
|
# - team
|
||||||
# - team_add
|
# - team_add
|
||||||
@ -54,15 +54,15 @@ default_events:
|
|||||||
default_permissions:
|
default_permissions:
|
||||||
# Repository creation, deletion, settings, teams, and collaborators.
|
# Repository creation, deletion, settings, teams, and collaborators.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-administration
|
# https://developer.github.com/v3/apps/permissions/#permission-on-administration
|
||||||
# administration: read
|
administration: read
|
||||||
|
|
||||||
# Checks on code.
|
# Checks on code.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-checks
|
# https://developer.github.com/v3/apps/permissions/#permission-on-checks
|
||||||
# checks: read
|
checks: read
|
||||||
|
|
||||||
# Repository contents, commits, branches, downloads, releases, and merges.
|
# Repository contents, commits, branches, downloads, releases, and merges.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-contents
|
# https://developer.github.com/v3/apps/permissions/#permission-on-contents
|
||||||
# contents: read
|
contents: read
|
||||||
|
|
||||||
# Deployments and deployment statuses.
|
# Deployments and deployment statuses.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-deployments
|
# https://developer.github.com/v3/apps/permissions/#permission-on-deployments
|
||||||
@ -70,11 +70,11 @@ default_permissions:
|
|||||||
|
|
||||||
# Issues and related comments, assignees, labels, and milestones.
|
# Issues and related comments, assignees, labels, and milestones.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-issues
|
# https://developer.github.com/v3/apps/permissions/#permission-on-issues
|
||||||
issues: write
|
# issues: write
|
||||||
|
|
||||||
# Search repositories, list collaborators, and access repository metadata.
|
# Search repositories, list collaborators, and access repository metadata.
|
||||||
# https://developer.github.com/v3/apps/permissions/#metadata-permissions
|
# https://developer.github.com/v3/apps/permissions/#metadata-permissions
|
||||||
# metadata: read
|
metadata: read
|
||||||
|
|
||||||
# Retrieve Pages statuses, configuration, and builds, as well as create new builds.
|
# Retrieve Pages statuses, configuration, and builds, as well as create new builds.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-pages
|
# https://developer.github.com/v3/apps/permissions/#permission-on-pages
|
||||||
@ -86,7 +86,7 @@ default_permissions:
|
|||||||
|
|
||||||
# Manage the post-receive hooks for a repository.
|
# Manage the post-receive hooks for a repository.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
|
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
|
||||||
# repository_hooks: read
|
repository_hooks: read
|
||||||
|
|
||||||
# Manage repository projects, columns, and cards.
|
# Manage repository projects, columns, and cards.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-projects
|
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-projects
|
||||||
@ -98,7 +98,7 @@ default_permissions:
|
|||||||
|
|
||||||
# Commit statuses.
|
# Commit statuses.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-statuses
|
# https://developer.github.com/v3/apps/permissions/#permission-on-statuses
|
||||||
# statuses: read
|
statuses: read
|
||||||
|
|
||||||
# Organization members and teams.
|
# Organization members and teams.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-members
|
# https://developer.github.com/v3/apps/permissions/#permission-on-members
|
||||||
@ -118,7 +118,7 @@ default_permissions:
|
|||||||
|
|
||||||
# Manage the post-receive hooks for an organization.
|
# Manage the post-receive hooks for an organization.
|
||||||
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-hooks
|
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-hooks
|
||||||
# organization_hooks: read
|
organization_hooks: read
|
||||||
|
|
||||||
# Get notified of, and update, content references.
|
# Get notified of, and update, content references.
|
||||||
# https://developer.github.com/v3/apps/permissions/
|
# https://developer.github.com/v3/apps/permissions/
|
||||||
|
@ -1,6 +1,28 @@
|
|||||||
/*const Presolver = require('./lib/presolver');
|
const debug = require("debug")("probot:presolver");
|
||||||
|
/*const Presolver = {
|
||||||
|
(github, { owner, repo, logger = console, ...config }) {
|
||||||
|
//constructor(github, { owner, repo, logger = console, ...config }) {
|
||||||
|
this.github = github;
|
||||||
|
this.logger = logger;
|
||||||
|
this.config = Object.assign({}, {
|
||||||
|
owner,
|
||||||
|
repo
|
||||||
|
});
|
||||||
|
this.pullRequest = {};
|
||||||
|
//}
|
||||||
|
|
||||||
function probotPlugin(robot) {
|
/*static get STATE() {
|
||||||
|
return Object.freeze({
|
||||||
|
CLASH: 'clashing'
|
||||||
|
});
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
async function probotPlugin(robot) {
|
||||||
const events = [
|
const events = [
|
||||||
"pull_request.opened",
|
"pull_request.opened",
|
||||||
"pull_request.edited",
|
"pull_request.edited",
|
||||||
@ -10,14 +32,29 @@ function probotPlugin(robot) {
|
|||||||
|
|
||||||
robot.on(events, presolve);
|
robot.on(events, presolve);
|
||||||
}
|
}
|
||||||
|
async function _getClashingRanges(context, pullRequest) {
|
||||||
|
const repo = pullRequest.base.repo;
|
||||||
|
//console.log(pullRequest)
|
||||||
|
const owner = repo.owner;
|
||||||
|
const number = pullRequest.number;
|
||||||
|
|
||||||
async function presolve(context) {
|
const prs = (await context.github.pullRequests.get({ owner, repo }))
|
||||||
const presolverContext = getRepository(context);
|
.data || [];
|
||||||
const pullRequest = getPullRequest(context);
|
prs.forEach(function(pr){
|
||||||
|
const files = pr.files()
|
||||||
|
console.log(files)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
async function presolver(context, pullRequest) {
|
||||||
|
//Object.assign(this.pullRequest, pullRequest);
|
||||||
|
//const { owner, repo } = this.config;
|
||||||
|
//const number = this.pullRequest.number;
|
||||||
|
|
||||||
function getRepository(context) {
|
const state = await _getClashingRanges(context, pullRequest);
|
||||||
const config = Object.assign(context.repo());
|
|
||||||
|
}
|
||||||
|
function forRepository(context) {
|
||||||
|
const config = Object.assign({}, context.repo({ logger: debug }));
|
||||||
return new Presolver(context.github, config);
|
return new Presolver(context.github, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,20 +62,34 @@ function getPullRequest(context) {
|
|||||||
return context.payload.pull_request || context.payload.review.pull_request;
|
return context.payload.pull_request || context.payload.review.pull_request;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = probotPlugin;
|
|
||||||
*/
|
async function presolve(context) {
|
||||||
function getPullRequest(context) {
|
//const presolved = //forRepository(context);
|
||||||
return context.payload.pull_request || context.payload.review.pull_request;
|
const pullRequest = getPullRequest(context);
|
||||||
|
//presolver.presolve(pullRequest);
|
||||||
|
console.log(context);
|
||||||
|
return presolver(context, pullRequest);
|
||||||
}
|
}
|
||||||
module.exports = async app => {
|
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!')
|
||||||
|
|
||||||
app.on('pull_request.labeled', async context => {
|
app.on('pull_request.opened', async githubcontext => {
|
||||||
|
//console.log(githubcontext)
|
||||||
|
const prContext = getPullRequest(githubcontext);
|
||||||
|
//console.log(prContext);
|
||||||
|
//const config = //Object.assign({}, githubcontext.repo({})
|
||||||
|
//);
|
||||||
|
//const context = prContext.github;
|
||||||
|
//console.log(context)
|
||||||
|
//constructor(github, { owner, repo, logger = console, ...config }) {
|
||||||
|
|
||||||
//const prNumber = context.payload.pull_request.number;
|
//const prNumber = context.payload.pull_request.number;
|
||||||
const { title, head, number, id } = getPullRequest(context);
|
|
||||||
const owner = context.repo().owner;
|
const { title, head, number, id } = prContext;*/
|
||||||
const repo = context.repo().repo;
|
//const owner = context.owner;
|
||||||
|
//const repo = context.repo;
|
||||||
/*const reviews =
|
/*const reviews =
|
||||||
(await context.github.pullRequests.getReviews({ owner, repo, number }))
|
(await context.github.pullRequests.getReviews({ owner, repo, number }))
|
||||||
.data || [];
|
.data || [];
|
||||||
@ -72,7 +123,7 @@ module.exports = async app => {
|
|||||||
return Object.values(uniqueReviews);
|
return Object.values(uniqueReviews);
|
||||||
}*/
|
}*/
|
||||||
//const params =
|
//const params =
|
||||||
const commit_id = head.sha;
|
/* const commit_id = head.sha;
|
||||||
const body = 'probot comment test';
|
const body = 'probot comment test';
|
||||||
const filepath = './app.js'
|
const filepath = './app.js'
|
||||||
const pos = 4;
|
const pos = 4;
|
||||||
@ -88,7 +139,7 @@ module.exports = async app => {
|
|||||||
const position =
|
const position =
|
||||||
//comments[].path =
|
//comments[].path =
|
||||||
pos;
|
pos;
|
||||||
const reviewers = ['tbushman']
|
const reviewers = ['tbushman']*/
|
||||||
/*return await context.github.pullRequests.createReview({
|
/*return await context.github.pullRequests.createReview({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -98,16 +149,16 @@ module.exports = async app => {
|
|||||||
event,
|
event,
|
||||||
comments
|
comments
|
||||||
|
|
||||||
})
|
})*/
|
||||||
/*const issueComment = context.issue({ body: 'probot label test' })
|
/* const issueComment = githubcontext.issue({ body: 'probot label test' })
|
||||||
return context.github.issues.createComment(issueComment)*/
|
return githubcontext.github.issues.createComment(issueComment)
|
||||||
return await context.github.pullRequests.createReviewRequest({owner, repo, number, reviewers})
|
//return await githubcontext.github.pullRequests.createReviewRequest({owner, repo, number, reviewers})
|
||||||
})
|
})*/
|
||||||
|
|
||||||
// For more information on building apps:
|
// For more information on building apps:
|
||||||
// https://probot.github.io/docs/
|
// https://probot.github.io/docs/
|
||||||
|
|
||||||
// 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/
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
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;
|
|
@ -4,26 +4,33 @@ const myProbotApp = require('..')
|
|||||||
const { Probot } = require('probot')
|
const { Probot } = require('probot')
|
||||||
// Requiring our fixtures
|
// Requiring our fixtures
|
||||||
const payload = require('./fixtures/pullRequests.labeled')
|
const payload = require('./fixtures/pullRequests.labeled')
|
||||||
const issueCreatedBody = { body: 'Thanks for opening this issue!' }
|
const issueCreatedBody = { body: 'Thanks for contributing!' }
|
||||||
|
// const url = (process.env.NODE_ENV === 'production' ? 'https://api.github.com' : 'https://smee.io/Vq0IH8tsXTuCp6kM')
|
||||||
nock.disableNetConnect()
|
nock.disableNetConnect()
|
||||||
|
|
||||||
describe('My Probot app', () => {
|
describe('My Probot app', () => {
|
||||||
let probot
|
let probot, github
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
probot = new Probot({})
|
probot = new Probot({})
|
||||||
// Load our app into probot
|
// Load our app into probot
|
||||||
const app = probot.load(myProbotApp)
|
let app = probot.load(myProbotApp)
|
||||||
|
// This is an easy way to mock out the GitHub API
|
||||||
|
// https://probot.github.io/docs/testing/
|
||||||
|
github = {
|
||||||
|
issues: {
|
||||||
|
createComment: jest.fn().mockReturnValue(Promise.resolve({}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.auth = () => Promise.resolve(github)
|
||||||
// just return a test token
|
// just return a test token
|
||||||
app.app = () => 'test'
|
//app.app = () => 'test'
|
||||||
})
|
})
|
||||||
|
|
||||||
test('creates a comment when an issue is opened', async () => {
|
test('creates a comment when an issue is opened', async () => {
|
||||||
nock('https://api.github.com')
|
/*nock(url)
|
||||||
.post('/app/installations/421598/access_tokens')
|
.post('/app/installations/421598/access_tokens')
|
||||||
.reply(200, { token: 'test' })
|
.reply(200, { token: 'test' })*/
|
||||||
|
|
||||||
// Test that a comment is posted
|
// Test that a comment is posted
|
||||||
/*nock('https://api.github.com')
|
/*nock('https://api.github.com')
|
||||||
@ -34,7 +41,8 @@ describe('My Probot app', () => {
|
|||||||
.reply(200)*/
|
.reply(200)*/
|
||||||
|
|
||||||
// Receive a webhook event
|
// Receive a webhook event
|
||||||
await probot.receive({name: 'pull_request', payload: payload})
|
await probot.receive({name: 'pull_request.opened', payload: payload})
|
||||||
|
expect(github.issues.createComment).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user