How to use the pullRequests function from @octokit/rest

Find comprehensive JavaScript @octokit/rest.pullRequests code examples handpicked from public code repositorys.

7
8
9
10
11
12
13
14
15
16
    token: process.env.GITHUB_TOKEN
});

const {owner, name: repo, filepath: number} = parse(change);

const prData = (await octokit.pullRequests.get({owner, repo, number})).data;
const prReviews = (await octokit.pullRequests.getReviews({owner, repo, number})).data;
const prPatch = (await octokit.pullRequests.get({owner, repo, number, headers: {accept: 'application/vnd.github.v3.patch'}})).data;
const prSlug = branch.replace(/^release-/, '');
const prBranch = `backport-${prSlug}-${number}-${prData.head.ref}`;
fork icon7
star icon16
watch icon77

+ 9 other calls in file

11
12
13
14
15
16
17
})

module.exports = {
  pullRequest: octokit.pullRequests.create,
  release: octokit.repos.createRelease,
  merge: octokit.pullRequests.merge,
}
fork icon1
star icon12
watch icon137

+ 7 other calls in file

6
7
8
9
10
11
12
13
14
15
const {execSync} = require('child_process');

const pr = process.env['CIRCLE_PULL_REQUEST'];
if (pr) {
    const number = +pr.match(/\/(\d+)\/?$/)[1];
    return github.pullRequests.get({
        owner: 'mapbox',
        repo: 'mapbox-gl-native',
        number
    }).then(({data}) => {
fork icon0
star icon6
watch icon3

14
15
16
17
18
19
20
21
22
23
const branchName = getBranchName();

// for some reason the editing endpoint doesn't work with the graphql id (it should)
// let's find the non-hashed id

const prNumber = await octokit.pullRequests.getAll({ owner, repo, state: 'open' }).then(result => {
    try {
        return result.data.filter(pr => pr.head.ref === branchName)[0].number;
    } catch (error) {
        throw new Error('could not find pr on github');
fork icon0
star icon3
watch icon4

18
19
20
21
22
23
24
25
26
27
});
const promises = projects.map(async project => {
  const { owner, repo } = project;
  const state = 'open';

  const result = await octokit.pullRequests.getAll({ owner, repo, state });

  const prs = result.data.filter(
    pr => !pr.title.toLowerCase().includes('wip')
  );
fork icon0
star icon0
watch icon10

14
15
16
17
18
19
20
21
22
23
async function go() {
  let allPrs = []
  let page = 1
  let response
  do {
    response = await octokit.pullRequests.list({
      owner: 'clearlydefined',
      repo: 'curated-data',
      state: 'all',
      per_page: 100,
fork icon0
star icon0
watch icon2

8
9
10
11
12
13
14
15
16
17
})

  .then(result => {
    const firstReviewId = result.data[0].id

    return octokit.pullRequests.getReview({
      owner: 'octokit',
      repo: 'rest.js',
      number: 640,
      id: firstReviewId
fork icon0
star icon0
watch icon1

67
68
69
70
71
72
73
74
75
76

if (pr.data.milestone) {
        info.milestone = pr.data.milestone.title;
}

return promiseRetryRateLimit(() => octokit.pullRequests.getCommits({owner, repo, number}))
        .catch(onError)
        .then(commits => {
                info.contributors = _.unique(_.flatten(commits.data.map(i => {
                        if (!i.author || !i.committer) {
fork icon0
star icon0
watch icon28

+ 3 other calls in file