diff --git a/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap b/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap index 4a363262df20fc6c33a1d5add060fb975a51dba8..52dc90bafe4efcc6dd265d7a1d1e3b5ae5f3c3e7 100644 --- a/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/azure/__snapshots__/index.spec.ts.snap @@ -280,6 +280,7 @@ exports[`modules/platform/azure/index initRepo should initialise the config for { "defaultBranch": "defBr", "isFork": false, + "repoFingerprint": "02574de485149547c1a071aa7921da3d0afadcd6162f3bd49ba3ced29be589f8b9bac689fd0badb212bd21c3f48bd8566beaf31cdca2b083bd855808a9c129e2", } `; diff --git a/lib/modules/platform/azure/index.ts b/lib/modules/platform/azure/index.ts index 27e94b33f9f64b5e4791784d3ad46f37c81f8baf..342dfcd599067a2a0c4d641ad3a0cbbd952ba4b2 100644 --- a/lib/modules/platform/azure/index.ts +++ b/lib/modules/platform/azure/index.ts @@ -40,6 +40,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import * as azureApi from './azure-got-wrapper'; import * as azureHelper from './azure-helper'; @@ -230,6 +231,7 @@ export async function initRepo({ const repoConfig: RepoResult = { defaultBranch, isFork: false, + repoFingerprint: repoFingerprint(repo.id!, defaults.endpoint), }; return repoConfig; } diff --git a/lib/modules/platform/bitbucket-server/__snapshots__/index.spec.ts.snap b/lib/modules/platform/bitbucket-server/__snapshots__/index.spec.ts.snap index f563464c97913555da209e4cebf403212c5b841e..e135f302c2075ce3a3e0b83b9dc512cea19ed561 100644 --- a/lib/modules/platform/bitbucket-server/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/bitbucket-server/__snapshots__/index.spec.ts.snap @@ -170,6 +170,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with no path initRepo( { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "a37c027c633002a25e0c86a9d82fba2350ee8028133b94fe4df032f052f6f331a0d6d1c189d25c4cf9f436816fbe35d7086556ef2bdd2b2b54c82fde035c2bb6", } `; @@ -177,6 +178,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with no path initRepo( { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "a37c027c633002a25e0c86a9d82fba2350ee8028133b94fe4df032f052f6f331a0d6d1c189d25c4cf9f436816fbe35d7086556ef2bdd2b2b54c82fde035c2bb6", } `; @@ -184,6 +186,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with no path initRepo( { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "a37c027c633002a25e0c86a9d82fba2350ee8028133b94fe4df032f052f6f331a0d6d1c189d25c4cf9f436816fbe35d7086556ef2bdd2b2b54c82fde035c2bb6", } `; @@ -191,6 +194,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with no path initRepo( { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "a37c027c633002a25e0c86a9d82fba2350ee8028133b94fe4df032f052f6f331a0d6d1c189d25c4cf9f436816fbe35d7086556ef2bdd2b2b54c82fde035c2bb6", } `; @@ -382,6 +386,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with path initRepo() g { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "5cf9fcad2424fb392c571e8c68ae75132e5db7a1f74d89235bda8dbac1c6c40c45997bace756898176a8b898aa1580b0345dc6272284ecf18a055536402ffcf7", } `; @@ -389,6 +394,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with path initRepo() u { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "5cf9fcad2424fb392c571e8c68ae75132e5db7a1f74d89235bda8dbac1c6c40c45997bace756898176a8b898aa1580b0345dc6272284ecf18a055536402ffcf7", } `; @@ -396,6 +402,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with path initRepo() u { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "5cf9fcad2424fb392c571e8c68ae75132e5db7a1f74d89235bda8dbac1c6c40c45997bace756898176a8b898aa1580b0345dc6272284ecf18a055536402ffcf7", } `; @@ -403,6 +410,7 @@ exports[`modules/platform/bitbucket-server/index endpoint with path initRepo() w { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "5cf9fcad2424fb392c571e8c68ae75132e5db7a1f74d89235bda8dbac1c6c40c45997bace756898176a8b898aa1580b0345dc6272284ecf18a055536402ffcf7", } `; diff --git a/lib/modules/platform/bitbucket-server/index.spec.ts b/lib/modules/platform/bitbucket-server/index.spec.ts index 7044e66a3e73f4ab66202571708f922ecfc02896..54b8cb6f27d8f7142897e3d7f207b52b0dfa9169 100644 --- a/lib/modules/platform/bitbucket-server/index.spec.ts +++ b/lib/modules/platform/bitbucket-server/index.spec.ts @@ -309,7 +309,11 @@ describe('modules/platform/bitbucket-server/index', () => { endpoint: 'https://stash.renovatebot.com/vcs/', repository: 'SOME/repo', }) - ).toEqual({ defaultBranch: 'master', isFork: false }); + ).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('gitUrl ssh returns ssh url', async () => { @@ -335,7 +339,11 @@ describe('modules/platform/bitbucket-server/index', () => { expect(git.initRepo).toHaveBeenCalledWith( expect.objectContaining({ url: sshLink('SOME', 'repo') }) ); - expect(res).toEqual({ defaultBranch: 'master', isFork: false }); + expect(res).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('gitURL endpoint returns generates endpoint URL', async () => { @@ -365,7 +373,11 @@ describe('modules/platform/bitbucket-server/index', () => { url: link, }) ); - expect(res).toEqual({ defaultBranch: 'master', isFork: false }); + expect(res).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('gitUrl default returns http from API with injected auth', async () => { @@ -396,7 +408,11 @@ describe('modules/platform/bitbucket-server/index', () => { ), }) ); - expect(res).toEqual({ defaultBranch: 'master', isFork: false }); + expect(res).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('uses ssh url from API if http not in API response', async () => { diff --git a/lib/modules/platform/bitbucket-server/index.ts b/lib/modules/platform/bitbucket-server/index.ts index c92083ade125499217a899703d88c72055e00faf..1352372c555e91bc032312d54eee0562cbb9b12f 100644 --- a/lib/modules/platform/bitbucket-server/index.ts +++ b/lib/modules/platform/bitbucket-server/index.ts @@ -39,6 +39,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import type { BbsConfig, @@ -210,6 +211,7 @@ export async function initRepo({ const repoConfig: RepoResult = { defaultBranch: branchRes.body.displayId, isFork: !!info.origin, + repoFingerprint: repoFingerprint(info.id, defaults.endpoint), }; return repoConfig; diff --git a/lib/modules/platform/bitbucket-server/types.ts b/lib/modules/platform/bitbucket-server/types.ts index a856ffea5980d69f076f9917daa1a90fc2c6ee22..002619343052c6c0cf2894b283e9a64f58f9d1bf 100644 --- a/lib/modules/platform/bitbucket-server/types.ts +++ b/lib/modules/platform/bitbucket-server/types.ts @@ -48,6 +48,7 @@ export interface BbsRestPr { } export interface BbsRestRepo { + id: number; project: { key: string }; origin: { name: string; slug: string }; links: { diff --git a/lib/modules/platform/bitbucket-server/utils.spec.ts b/lib/modules/platform/bitbucket-server/utils.spec.ts index 460a94a8277246fc830af38c9581860de87acf75..5d6a52f9f2d975d207e79402997534029da5ea2d 100644 --- a/lib/modules/platform/bitbucket-server/utils.spec.ts +++ b/lib/modules/platform/bitbucket-server/utils.spec.ts @@ -60,6 +60,7 @@ function infoMock( }); } return { + id: 123, project: { key: projectKey }, origin: { name: repositorySlug, slug: repositorySlug }, links, @@ -68,6 +69,7 @@ function infoMock( // This mimics the behavior of bb-server which does not include the clone property at all // if ssh and https are both turned off return { + id: 1, project: { key: projectKey }, origin: { name: repositorySlug, slug: repositorySlug }, links: { clone: undefined }, diff --git a/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap b/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap index 4b2c3693e342019f3d3a19247df007880ffde73e..1a100b3d1972da49d1c17d5e5f802925956530f9 100644 --- a/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -154,6 +154,7 @@ exports[`modules/platform/bitbucket/index initRepo() works 1`] = ` { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "56653db0e9341ef4957c92bb78ee668b0a3f03c75b77db94d520230557385fca344cc1f593191e3594183b5b050909d29996c040045e8852f21774617b240642", } `; diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 2f089c1d50ade7dda00fd7565178bf3d4a2cf191..d68db6debe1b612894c7413526b33e684eb580c2 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -27,6 +27,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import { readOnlyIssueBody } from '../utils/read-only-issue-body'; import * as comments from './comments'; @@ -209,6 +210,7 @@ export async function initRepo({ const repoConfig: RepoResult = { defaultBranch: info.mainbranch, isFork: info.isFork, + repoFingerprint: repoFingerprint(info.uuid, defaults.endpoint), }; return repoConfig; } diff --git a/lib/modules/platform/bitbucket/utils.ts b/lib/modules/platform/bitbucket/utils.ts index c72b76a54cf14f0c5a16155e18530b4b7b21a4e3..aa24d538a93da4594ab2bcb6c9ac1f8c5f346a91 100644 --- a/lib/modules/platform/bitbucket/utils.ts +++ b/lib/modules/platform/bitbucket/utils.ts @@ -38,6 +38,7 @@ export interface RepoInfo { mainbranch: string; mergeMethod: string; has_issues: boolean; + uuid: string; } export type BitbucketBranchState = 'SUCCESSFUL' | 'FAILED' | 'INPROGRESS'; @@ -51,6 +52,7 @@ export interface RepoInfoBody { owner: { username: string }; mainbranch: { name: string }; has_issues: boolean; + uuid: string; } export function repoInfoTransformer(repoInfoBody: RepoInfoBody): RepoInfo { @@ -60,6 +62,7 @@ export function repoInfoTransformer(repoInfoBody: RepoInfoBody): RepoInfo { mainbranch: repoInfoBody.mainbranch.name, mergeMethod: 'merge', has_issues: repoInfoBody.has_issues, + uuid: repoInfoBody.uuid, }; } diff --git a/lib/modules/platform/gitea/__snapshots__/index.spec.ts.snap b/lib/modules/platform/gitea/__snapshots__/index.spec.ts.snap index 10f4071b52e98bc79b4fdeb85a1940ca427b4fd9..be62b49693ed59d29e767a7fe9e2a97b55f96954 100644 --- a/lib/modules/platform/gitea/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/gitea/__snapshots__/index.spec.ts.snap @@ -231,6 +231,7 @@ exports[`modules/platform/gitea/index initRepo should fall back to merge method { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "c48ad9428365701f1a7f4798a410db2401b13267c205e345beb5b469a4a1480b163e1ce663ce483cfe579b2748a807cbeeba2035dc55eca5fe46d60d182510ec", } `; @@ -238,6 +239,7 @@ exports[`modules/platform/gitea/index initRepo should fall back to merge method { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "c48ad9428365701f1a7f4798a410db2401b13267c205e345beb5b469a4a1480b163e1ce663ce483cfe579b2748a807cbeeba2035dc55eca5fe46d60d182510ec", } `; @@ -245,5 +247,6 @@ exports[`modules/platform/gitea/index initRepo should fall back to merge method { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "c48ad9428365701f1a7f4798a410db2401b13267c205e345beb5b469a4a1480b163e1ce663ce483cfe579b2748a807cbeeba2035dc55eca5fe46d60d182510ec", } `; diff --git a/lib/modules/platform/gitea/gitea-helper.spec.ts b/lib/modules/platform/gitea/gitea-helper.spec.ts index 187c89b147f7dbfdf21e2056d4d76096eb24566e..492a5ebd8af9e7cdeb5bc8f3ba02a766d51f8495 100644 --- a/lib/modules/platform/gitea/gitea-helper.spec.ts +++ b/lib/modules/platform/gitea/gitea-helper.spec.ts @@ -67,6 +67,7 @@ describe('modules/platform/gitea/gitea-helper', () => { }; const mockRepo: Repo = { + id: 123, allow_rebase: true, allow_rebase_explicit: true, allow_merge_commits: true, diff --git a/lib/modules/platform/gitea/index.ts b/lib/modules/platform/gitea/index.ts index 4266aeb819f7ccb2a4f478a52acfe6cb89ae994a..50b6b1b436079083857c3ca3815c48159973d48c 100644 --- a/lib/modules/platform/gitea/index.ts +++ b/lib/modules/platform/gitea/index.ts @@ -34,6 +34,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import * as helper from './gitea-helper'; import type { @@ -334,6 +335,7 @@ const platform: Platform = { return { defaultBranch: config.defaultBranch, isFork: !!repo.fork, + repoFingerprint: repoFingerprint(repo.id, defaults.endpoint), }; }, diff --git a/lib/modules/platform/gitea/types.ts b/lib/modules/platform/gitea/types.ts index 0b34560e0f17efff17632fd952446e41e4043364..b1d04ab5589b98ee9c436dfc02f1cbf3483a5b2e 100644 --- a/lib/modules/platform/gitea/types.ts +++ b/lib/modules/platform/gitea/types.ts @@ -57,6 +57,7 @@ export interface User { } export interface Repo { + id: number; allow_merge_commits: boolean; allow_rebase: boolean; allow_rebase_explicit: boolean; diff --git a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap index 5ee5cd6cccae2886796f5f4eb818cc3b2c022229..7f398e480044922e0b5ba24620f1000e3c1e8f4f 100644 --- a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap @@ -157,6 +157,7 @@ exports[`modules/platform/github/index initRepo detects fork default branch mism { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -164,6 +165,7 @@ exports[`modules/platform/github/index initRepo should fork when forkMode 1`] = { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -171,6 +173,7 @@ exports[`modules/platform/github/index initRepo should merge 1`] = ` { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -178,6 +181,7 @@ exports[`modules/platform/github/index initRepo should not guess at merge 1`] = { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -185,6 +189,7 @@ exports[`modules/platform/github/index initRepo should rebase 1`] = ` { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -192,6 +197,7 @@ exports[`modules/platform/github/index initRepo should squash 1`] = ` { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; @@ -199,6 +205,7 @@ exports[`modules/platform/github/index initRepo should update fork when forkMode { "defaultBranch": "master", "isFork": false, + "repoFingerprint": "cd69e13f03c1f8d5399903d4d5e8973cb05218f8b392011be98dd52f0faf2b28541830a9a847716aab9b56be6f4c8e0e4b7cb6d726e7cc992f0b02168bc53f11", } `; diff --git a/lib/modules/platform/github/graphql.ts b/lib/modules/platform/github/graphql.ts index df5d807cbcd3d6f0f3171ca95e07c769bbfe3a7a..6ab8e1d25387c04400cb639c60a1f32e27b06b79 100644 --- a/lib/modules/platform/github/graphql.ts +++ b/lib/modules/platform/github/graphql.ts @@ -1,6 +1,7 @@ export const repoInfoQuery = ` query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { + id isFork isArchived nameWithOwner diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 6ddfbcf2528ce582f59acee32c2860b57817d6ae..977af32b3ccb5e120b7300535e364a6e3665cfee 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -56,6 +56,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import { coerceRestPr } from './common'; import { @@ -512,6 +513,7 @@ export async function initRepo({ const repoConfig: RepoResult = { defaultBranch: config.defaultBranch, isFork: repo.isFork === true, + repoFingerprint: repoFingerprint(repo.id, platformConfig.endpoint), }; return repoConfig; } diff --git a/lib/modules/platform/github/types.ts b/lib/modules/platform/github/types.ts index dcb6c6ee006e6e6d8cf656c7929f42ff36e94dc8..e790de784f9306916b854b1375c0b8688a2dd143 100644 --- a/lib/modules/platform/github/types.ts +++ b/lib/modules/platform/github/types.ts @@ -111,6 +111,7 @@ export interface LocalRepoConfig { export type BranchProtection = any; export interface GhRepo { + id: string; isFork: boolean; isArchived: boolean; nameWithOwner: string; diff --git a/lib/modules/platform/gitlab/index.spec.ts b/lib/modules/platform/gitlab/index.spec.ts index 1f7ae70ff6a4737ef9dc3dc924b2335713681a14..77c851d5976c8c687a336200b1e3d5d0baad8fda 100644 --- a/lib/modules/platform/gitlab/index.spec.ts +++ b/lib/modules/platform/gitlab/index.spec.ts @@ -201,12 +201,11 @@ describe('modules/platform/gitlab/index', () => { await gitlab.initRepo({ repository: 'some/repo/project', }) - ).toMatchInlineSnapshot(` - { - "defaultBranch": "master", - "isFork": false, - } - `); + ).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('should throw an error if receiving an error', async () => { @@ -305,12 +304,11 @@ describe('modules/platform/gitlab/index', () => { await gitlab.initRepo({ repository: 'some/repo/project', }) - ).toMatchInlineSnapshot(` - { - "defaultBranch": "master", - "isFork": false, - } - `); + ).toEqual({ + defaultBranch: 'master', + isFork: false, + repoFingerprint: expect.any(String), + }); }); it('should use ssh_url_to_repo if gitUrl is set to ssh', async () => { diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 8dde207ce206348cad96492485b4e89b18455f2a..c3bfadeed1a0bfcf2c5e58a13ed92a08b8640555 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -49,6 +49,7 @@ import type { RepoResult, UpdatePrConfig, } from '../types'; +import { repoFingerprint } from '../util'; import { smartTruncate } from '../utils/pr-body'; import { getUserID, gitlabApi, isUserBusy } from './http'; import { getMR, updateMR } from './merge-request'; @@ -245,6 +246,7 @@ export async function initRepo({ cloneSubmodules, ignorePrAuthor, gitUrl, + endpoint, }: RepoParams): Promise<RepoResult> { config = {} as any; config.repository = urlEscape(repository); @@ -326,6 +328,7 @@ export async function initRepo({ const repoConfig: RepoResult = { defaultBranch: config.defaultBranch, isFork: !!res.body.forked_from_project, + repoFingerprint: repoFingerprint(res.body.id, defaults.endpoint), }; return repoConfig; } diff --git a/lib/modules/platform/gitlab/types.ts b/lib/modules/platform/gitlab/types.ts index aaffe7386ec5715bcee1c16ba937bf477d35dbc5..b7aa89d5f1e91a4866b77f369811b0022e64c1d7 100644 --- a/lib/modules/platform/gitlab/types.ts +++ b/lib/modules/platform/gitlab/types.ts @@ -43,6 +43,7 @@ export interface UpdateMergeRequest { export type MergeMethod = 'merge' | 'rebase_merge' | 'ff'; export interface RepoResponse { + id: number; archived: boolean; mirror: boolean; default_branch: string; diff --git a/lib/modules/platform/types.ts b/lib/modules/platform/types.ts index 9fffc1927da50856ec0b775d385e3c34ee58ab17..ff2b266f2c814fa3665db3479ea189bbd85c7243 100644 --- a/lib/modules/platform/types.ts +++ b/lib/modules/platform/types.ts @@ -28,6 +28,7 @@ export interface PlatformResult { export interface RepoResult { defaultBranch: string; isFork: boolean; + repoFingerprint: string; } export type GitUrlOption = 'default' | 'ssh' | 'endpoint'; diff --git a/lib/modules/platform/util.ts b/lib/modules/platform/util.ts index d6af2c6345e6889829adcd2bdba6a7903bd9f3f0..6acadd1947bc6a2d1d47d566e23cbd92841de63c 100644 --- a/lib/modules/platform/util.ts +++ b/lib/modules/platform/util.ts @@ -1,3 +1,4 @@ +import hasha from 'hasha'; import { GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, @@ -35,3 +36,12 @@ export function detectPlatform(url: string): 'gitlab' | 'github' | null { return null; } + +export function repoFingerprint( + repoId: number | string, + endpoint: string | undefined +): string { + const input = endpoint ? `${endpoint}::${repoId}` : `${repoId}`; + const fingerprint = hasha(input); + return fingerprint; +} diff --git a/lib/workers/repository/init/apis.spec.ts b/lib/workers/repository/init/apis.spec.ts index bb541ffdfd098f6a4b97382dd528eb7de0eb6904..2daa89b7d150fdefe11f82b260ff269870de7220 100644 --- a/lib/workers/repository/init/apis.spec.ts +++ b/lib/workers/repository/init/apis.spec.ts @@ -26,6 +26,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); const workerPlatformConfig = await initApis(config); expect(workerPlatformConfig).toBeTruthy(); @@ -35,6 +36,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); platform.getJsonFile.mockResolvedValueOnce({ enabled: false }); await expect( @@ -49,6 +51,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: true, + repoFingerprint: '123', }); platform.getJsonFile.mockResolvedValueOnce({ includeForks: false }); await expect( @@ -63,6 +66,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); platform.getJsonFile.mockRejectedValue(new Error()); await expect( @@ -79,6 +83,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); platform.getJsonFile.mockResolvedValueOnce({ includeForks: false }); const workerPlatformConfig = await initApis({ @@ -100,6 +105,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); platform.getJsonFile.mockResolvedValueOnce({ includeForks: false }); const workerPlatformConfig = await initApis({ @@ -116,6 +122,7 @@ describe('workers/repository/init/apis', () => { platform.initRepo.mockResolvedValueOnce({ defaultBranch: 'master', isFork: false, + repoFingerprint: '123', }); platform.getJsonFile.mockResolvedValueOnce({ includeForks: false }); const workerPlatformConfig = await initApis({