diff --git a/lib/platform/azure/__snapshots__/index.spec.ts.snap b/lib/platform/azure/__snapshots__/index.spec.ts.snap index c14a6a04039684514a706383815b24c95bcf18aa..d148e1eb6f74fbd4073f5ab48a8cad81f191cd9b 100644 --- a/lib/platform/azure/__snapshots__/index.spec.ts.snap +++ b/lib/platform/azure/__snapshots__/index.spec.ts.snap @@ -37,7 +37,6 @@ exports[`platform/azure deleteLabel() Should delete a label 1`] = ` Array [ Array [], Array [], - Array [], ] `; @@ -165,7 +164,6 @@ Object { exports[`platform/azure initRepo should initialise the config for a repo 1`] = ` Array [ Array [], - Array [], ] `; diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index 1c234b6252d5bc9b83e4f59647a2de8d985ef76d..3b464d06980701d1de1ce2eafbb883ce19d94a1d 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -136,12 +136,6 @@ describe('platform/azure', () => { ]), } as any) ); - azureApi.gitApi.mockImplementationOnce( - () => - ({ - getBranch: jest.fn(() => ({ commit: { commitId: '1234' } })), - } as any) - ); azureHelper.getProjectAndRepo.mockImplementationOnce(() => ({ project: 'some-repo', repo: 'some-repo', @@ -779,7 +773,7 @@ describe('platform/azure', () => { } as any) ); await azure.addAssignees(123, ['test@bonjour.fr', 'jyc', 'def']); - expect(azureApi.gitApi).toHaveBeenCalledTimes(4); + expect(azureApi.gitApi).toHaveBeenCalledTimes(3); }); }); @@ -806,7 +800,7 @@ describe('platform/azure', () => { } as any) ); await azure.addReviewers(123, ['test@bonjour.fr', 'jyc', 'def']); - expect(azureApi.gitApi).toHaveBeenCalledTimes(4); + expect(azureApi.gitApi).toHaveBeenCalledTimes(3); }); }); diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 524d926c85d13e28f9f01ca8d2509085c406a3ef..2248bc4bdad713ae78036977ab921cf1389124b2 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -40,7 +40,6 @@ import { AzurePr } from './types'; interface Config { repoForceRebase: boolean; mergeMethod: GitPullRequestMergeStrategy; - baseCommitSHA: string | undefined; baseBranch: string; defaultBranch: string; owner: string; @@ -96,15 +95,6 @@ export async function getRepos(): Promise<string[]> { return repos.map((repo) => `${repo.project.name}/${repo.name}`); } -async function getBranchCommit(fullBranchName: string): Promise<string> { - const azureApiGit = await azureApi.gitApi(); - const commit = await azureApiGit.getBranch( - config.repoId, - azureHelper.getBranchNameWithoutRefsheadsPrefix(fullBranchName)! - ); - return commit.commit.commitId; -} - export async function initRepo({ repository, localDir, @@ -130,7 +120,6 @@ export async function initRepo({ config.defaultBranch = repo.defaultBranch.replace('refs/heads/', ''); config.baseBranch = config.defaultBranch; logger.debug(`${repository} default branch = ${config.defaultBranch}`); - config.baseCommitSHA = await getBranchCommit(config.baseBranch); config.mergeMethod = await azureHelper.getMergeMethod(repo.id, names.project); config.repoForceRebase = false; @@ -186,7 +175,6 @@ export function getRepoForceRebase(): Promise<boolean> { export async function setBaseBranch(branchName: string): Promise<string> { logger.debug(`Setting baseBranch to ${branchName}`); config.baseBranch = branchName; - delete config.baseCommitSHA; const baseBranchSha = await git.setBranch(branchName); return baseBranchSha; } diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 46b20925b55ff0af1db06a188b95102388d58781..fc548e9b46e397eedd46f97a66dd0f29e5ff3f4b 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -177,7 +177,6 @@ export function getRepoForceRebase(): Promise<boolean> { export async function setBaseBranch(branchName: string): Promise<string> { logger.debug(`Setting baseBranch to ${branchName}`); config.baseBranch = branchName; - delete config.baseCommitSHA; const baseBranchSha = await git.setBranch(branchName); return baseBranchSha; } @@ -777,7 +776,6 @@ export async function mergePr( }, } ); - delete config.baseCommitSHA; logger.debug('Automerging succeeded'); } catch (err) /* istanbul ignore next */ { return false; diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts index 6bb0c632193d7d17e058b12b2be31bb4ecc67e1b..4578ed5d6e6a2f34430f0067d408191d51060193 100644 --- a/lib/platform/bitbucket/utils.ts +++ b/lib/platform/bitbucket/utils.ts @@ -9,7 +9,6 @@ const bitbucketHttp = new BitbucketHttp(); export interface Config { baseBranch: string; - baseCommitSHA: string; defaultBranch: string; has_issues: boolean; mergeMethod: string; diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap index 9d025fac703ab99253e7a531643308fd2904a711..8694755cc923de746c5edb6279e0fa4e33a9d400 100644 --- a/lib/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/platform/github/__snapshots__/index.spec.ts.snap @@ -12,6 +12,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -26,7 +29,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -63,6 +66,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -77,7 +83,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -122,6 +128,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -136,7 +145,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -181,6 +190,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -195,7 +207,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -301,6 +313,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -315,7 +330,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -352,6 +367,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -366,7 +384,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -400,6 +418,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -414,7 +435,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -505,6 +526,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -519,7 +543,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -610,6 +634,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -624,7 +651,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -704,6 +731,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -718,7 +748,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -795,6 +825,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -809,7 +842,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -886,6 +919,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -900,7 +936,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -988,6 +1024,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -1002,7 +1041,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -1812,6 +1851,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -1826,7 +1868,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -1884,6 +1926,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -1898,7 +1943,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2095,6 +2140,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2109,7 +2157,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2117,17 +2165,6 @@ Array [ "method": "POST", "url": "https://api.github.com/graphql", }, - Object { - "headers": Object { - "accept": "application/vnd.github.v3+json", - "accept-encoding": "gzip, deflate", - "authorization": "token abc123", - "host": "api.github.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://api.github.com/repos/some/repo/git/refs/heads/master", - }, Object { "headers": Object { "accept": "application/vnd.github.v3+json", @@ -2329,6 +2366,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2343,7 +2383,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2388,6 +2428,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2402,7 +2445,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2425,6 +2468,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2439,7 +2485,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2462,6 +2508,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2476,7 +2525,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2521,6 +2570,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2535,7 +2587,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2580,6 +2632,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2594,7 +2649,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2639,6 +2694,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2653,7 +2711,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2698,6 +2756,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2712,7 +2773,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2757,6 +2818,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2771,7 +2835,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2805,6 +2869,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2819,7 +2886,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -2876,6 +2943,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -2890,7 +2960,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3057,6 +3127,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3071,7 +3144,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3192,6 +3265,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3206,7 +3282,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3386,6 +3462,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3400,7 +3479,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3578,6 +3657,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3592,7 +3674,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3754,6 +3836,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3768,7 +3853,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -3952,6 +4037,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -3966,7 +4054,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "github.company.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4491,6 +4579,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4505,7 +4596,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4513,17 +4604,6 @@ Array [ "method": "POST", "url": "https://api.github.com/graphql", }, - Object { - "headers": Object { - "accept": "application/vnd.github.v3+json", - "accept-encoding": "gzip, deflate", - "authorization": "token abc123", - "host": "api.github.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://api.github.com/repos/some/repo/git/refs/heads/master", - }, Object { "headers": Object { "accept": "application/vnd.github.v3+json", @@ -4568,6 +4648,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4582,7 +4665,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4612,6 +4695,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4626,7 +4712,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4656,6 +4742,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4670,7 +4759,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4700,6 +4789,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4714,7 +4806,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4737,6 +4829,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4751,7 +4846,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4785,6 +4880,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4799,7 +4897,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4822,6 +4920,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4836,7 +4937,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4866,6 +4967,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4880,7 +4984,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4888,17 +4992,6 @@ Array [ "method": "POST", "url": "https://api.github.com/graphql", }, - Object { - "headers": Object { - "accept": "application/vnd.github.v3+json", - "accept-encoding": "gzip, deflate", - "authorization": "token abc123", - "host": "api.github.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://api.github.com/repos/some/repo/git/refs/heads/master", - }, Object { "headers": Object { "accept": "application/vnd.github.v3+json", @@ -4957,6 +5050,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -4971,7 +5067,7 @@ Array [ "accept": "application/vnd.github.machine-man-preview+json, application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -4994,6 +5090,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5008,7 +5107,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5031,6 +5130,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5045,7 +5147,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5124,6 +5226,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5138,7 +5243,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5203,6 +5308,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5217,7 +5325,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5254,6 +5362,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5268,7 +5379,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5305,6 +5416,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5319,7 +5433,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5356,6 +5470,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5370,7 +5487,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5407,6 +5524,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5421,7 +5541,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5455,6 +5575,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5469,7 +5592,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", @@ -5539,6 +5662,9 @@ Array [ }, "defaultBranchRef": Object { "name": null, + "target": Object { + "oid": null, + }, }, "isArchived": null, "isFork": null, @@ -5553,7 +5679,7 @@ Array [ "accept": "application/vnd.github.v3+json", "accept-encoding": "gzip, deflate", "authorization": "token abc123", - "content-length": "280", + "content-length": "330", "content-type": "application/json", "host": "api.github.com", "user-agent": "https://github.com/renovatebot/renovate", diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 6007e665316bf30e508890c1d2117de5c754315a..95397b73ef38da970ea348130f1b08e39fdb66a5 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -165,6 +165,9 @@ describe('platform/github', () => { squashMergeAllowed: true, defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -190,17 +193,13 @@ describe('platform/github', () => { squashMergeAllowed: true, defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, }) - // getBranchCommit - .get(`/repos/${repository}/git/refs/heads/master`) - .reply(200, { - object: { - sha: '1234', - }, - }) // getRepos .get('/user/repos?per_page=100') .reply(200, forkedRepo ? [{ full_name: forkedRepo }] : []) @@ -280,6 +279,9 @@ describe('platform/github', () => { squashMergeAllowed: true, defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -305,6 +307,9 @@ describe('platform/github', () => { squashMergeAllowed: false, defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -324,6 +329,9 @@ describe('platform/github', () => { repository: { defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -345,6 +353,9 @@ describe('platform/github', () => { nameWithOwner: 'some/repo', defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -375,6 +386,9 @@ describe('platform/github', () => { nameWithOwner: 'some/other', defaultBranchRef: { name: 'master', + target: { + oid: '1234', + }, }, }, }, @@ -1659,8 +1673,7 @@ describe('platform/github', () => { .post('/graphql') .reply(200, graphqlOpenPullRequests) .post('/graphql') - .reply(200, graphqlClosedPullRequests) - .get('/repos/some/repo/git/refs/heads/master'); + .reply(200, graphqlClosedPullRequests); await github.initRepo({ repository: 'some/repo', } as any); diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 3f32448b4a87f419e06df4a99f5ffcd2429cb2c3..6f42a5bfee9882163bc1772eb2edb26742914933 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -162,32 +162,6 @@ async function getBranchProtection( return res.body; } -// Return the commit SHA for a branch -async function getBranchCommit(branchName: string): Promise<string> { - try { - const res = await githubApi.getJson<{ object: { sha: string } }>( - `repos/${config.repository}/git/refs/heads/${escapeHash(branchName)}` - ); - return res.body.object.sha; - } catch (err) /* istanbul ignore next */ { - logger.debug({ err }, 'Error getting branch commit'); - if (err.statusCode === 404) { - throw new Error(REPOSITORY_CHANGED); - } - if (err.statusCode === 409) { - throw new Error(REPOSITORY_EMPTY); - } - throw err; - } -} - -async function getBaseCommitSHA(): Promise<string> { - if (!config.baseCommitSHA) { - config.baseCommitSHA = await getBranchCommit(config.baseBranch); - } - return config.baseCommitSHA; -} - // Initialize GitHub by getting base branch and SHA export async function initRepo({ endpoint, @@ -229,6 +203,9 @@ export async function initRepo({ squashMergeAllowed defaultBranchRef { name + target { + oid + } } } }` @@ -350,8 +327,7 @@ export async function initRepo({ logger.debug('Bot is in forkMode'); config.forkToken = forkToken; // Save parent SHA then delete - const parentSha = await getBaseCommitSHA(); - config.baseCommitSHA = null; + const parentSha = repo.defaultBranchRef.target.oid; // save parent name then delete config.parentRepo = config.repository; config.repository = null; @@ -502,7 +478,6 @@ export async function getRepoForceRebase(): Promise<boolean> { // istanbul ignore next export async function setBaseBranch(branchName: string): Promise<string> { config.baseBranch = branchName; - config.baseCommitSHA = null; const baseBranchSha = await git.setBranch(branchName); return baseBranchSha; } @@ -1612,8 +1587,6 @@ export async function mergePr( } } logger.debug({ pr: prNo }, 'PR merged'); - // Update base branch SHA - config.baseCommitSHA = null; // Delete branch await deleteBranch(branchName); return true; diff --git a/lib/platform/github/types.ts b/lib/platform/github/types.ts index fd234e7f5de36cfcb6e5eb8cb3132c0c672ce890..49eb596fc30610dd4a31d6186296ee8db098dd27 100644 --- a/lib/platform/github/types.ts +++ b/lib/platform/github/types.ts @@ -30,7 +30,6 @@ export interface LocalRepoConfig { prReviewsRequired: boolean; repoForceRebase?: boolean; parentRepo: string; - baseCommitSHA: string | null; forkMode?: boolean; forkToken?: string; closedPrList: PrList | null; @@ -60,5 +59,8 @@ export interface GhRepo { squashMergeAllowed: boolean; defaultBranchRef: { name: string; + target: { + oid: string; + }; }; }