diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 0f539aef0ffce1ef631c991bb3b02c114a76bd8f..2529b4b97bc31d6f5cb5dae7397b9903a58cecb1 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -75,6 +75,7 @@ async function initRepo(repoName, token, endpoint) { config.repoName = repoName; config.fileList = null; config.prList = null; + config.prs = {}; const platformConfig = {}; let res; try { @@ -525,6 +526,9 @@ async function getPr(prNo) { if (!prNo) { return null; } + if (config.prs[prNo]) { + return config.prs[prNo]; + } const pr = (await get(`repos/${config.repoName}/pulls/${prNo}`)).body; if (!pr) { return null; @@ -584,6 +588,7 @@ async function getPr(prNo) { pr.isStale = true; } } + config.prs[prNo] = pr; return pr; } diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index bd051455fe79cb5c7283880df04c21be344e0234..a0da3268a2a2e728d09315b748e6a1a0a8799dd6 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -996,6 +996,8 @@ describe('platform/github', () => { const pr = await github.getPr(1234); expect(pr.canRebase).toBe(true); expect(pr).toMatchSnapshot(); + const cachedPr = await github.getPr(1234); + expect(cachedPr).toEqual(pr); }); }); describe('getPrFiles()', () => {