Skip to content

Instantly share code, notes, and snippets.

@kfatehi
Last active May 27, 2024 16:04
Show Gist options
  • Save kfatehi/ff12772c852da1fe8a2c88a5e3f1bfb3 to your computer and use it in GitHub Desktop.
Save kfatehi/ff12772c852da1fe8a2c88a5e3f1bfb3 to your computer and use it in GitHub Desktop.
list pull requests across entire organization
var Promise = require('bluebird')
var GitHubApi = require("github");
const org = "matrix-hacks";
var github = new GitHubApi({ Promise });
github.repos.getForOrg({ org, type: 'sources' })
.then(res=>res.data.map(i=>i.name))
.then(repos=>{
return Promise.map(repos, (repo) => {
return github.pullRequests.getAll({
state: 'open',
owner: org,
repo
});
})
})
.then((allReposPrs) => {
allReposPrs.forEach(thisRepoPrs=>{
thisRepoPrs.data.forEach(pr => {
const {
_links,
title,
body,
created_at,
updated_at,
user: { login },
number,
} = pr;
const baseName = pr.base.repo.name;
console.log([
`Pull request`,
`\tRepo: ${pr.base.repo.name}`,
`\tAuthor: ${login}`,
`\tTitle: ${title}`,
`\tURL: ${_links.html.href}`,
].join('\n'));
});
})
});
@jd-brennan
Copy link

Thanks!

@nguythi0802
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment