Skip to content

Instantly share code, notes, and snippets.

@nicolasnoble
Created June 20, 2020 15:41
Show Gist options
  • Save nicolasnoble/dee2df70cfd5843e315e2521d0cf837d to your computer and use it in GitHub Desktop.
Save nicolasnoble/dee2df70cfd5843e315e2521d0cf837d to your computer and use it in GitHub Desktop.
const github = require('octonode')
const repoName = /* repository name */
const client = github.client(/* user token */)
const repo = client.repo(repoName)
async function migrateAll() {
let page = 1
while (true) {
const prsResult = await repo.prsAsync({page: page, state: 'open'})
const prs = prsResult[0]
page = page + 1
if (prs.length === 0) return
for (let i = 0; i < prs.length; i++) {
if (prs[i].base.ref !== 'master') return
console.log('Migrating ' + prs[i].number)
const ghpr = client.pr(repoName, prs[i].number)
await ghpr.updateAsync({'base': 'main'})
}
}
}
migrateAll().then(console.log).catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment