Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask for backports #175

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ module.exports = app => {

app.on('pull_request.closed', async context => {
const params = context.issue()

const thisPR = await context.github.pullRequests.get(params)
if (!thisPR.data.merged) {
app.log('PR is not merged, but closed')
return
}

const comments = await context.github.issues.listComments(params)

// Obtain all targets
Expand All @@ -51,20 +58,15 @@ module.exports = app => {

if (targets.length === 0) {
app.log('Nothing to backport')
return
}

const thisPR = await context.github.pullRequests.get(params)
if (!thisPR.data.merged) {
app.log('PR is not merged, but closed')
pr.askForBackports(thisPR.data.number)
return
}

//TODO filter same backport requests

app.log(targets)
const success = await backport(context, context.issue.number, targets)

if (success) {
pr.removeBackportRequestLabel(context)
}
Expand Down
10 changes: 9 additions & 1 deletion lib/pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ module.exports = {
)
},

askForBackports: async function(context, target, prId) {
return context.github.issues.createComment(
context.issue({
body: 'Should this be backported?'
})
)
},

getReviewers: async function(context) {
const reviewers1 = await context.github.pullRequests.listReviewRequests(context.issue())
const reviewers2 = await context.github.pullRequests.listReviews(context.issue())
Expand All @@ -76,4 +84,4 @@ module.exports = {

return context.github.pullRequests.createReviewRequest(params);
}
}
}