diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index b81c7b809a9282e6d512234e47557d142784a922..03337462d67624e918c79512da481d3f63270a33 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -457,10 +457,12 @@ describe('modules/platform/bitbucket/index', () => { describe('findIssue()', () => { it('does not throw', async () => { + httpMock.scope(baseUrl).get('/2.0/user').reply(200, { uuid: '12345' }); + await bitbucket.initPlatform({ username: 'renovate', password: 'pass' }); const scope = await initRepoMock({}, { has_issues: true }); scope .get( - '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.uuid%3D%2212345%22' ) .reply(200, { values: [ @@ -488,7 +490,7 @@ describe('modules/platform/bitbucket/index', () => { ); scope .get( - '/2.0/repositories/some/empty/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/empty/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [], @@ -502,7 +504,7 @@ describe('modules/platform/bitbucket/index', () => { const scope = await initRepoMock({}, { has_issues: true }); scope .get( - '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [ @@ -534,11 +536,11 @@ describe('modules/platform/bitbucket/index', () => { ); scope .get( - '/2.0/repositories/some/empty/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/empty/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [] }) .get( - '/2.0/repositories/some/empty/issues?q=title%3D%22old-title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/empty/issues?q=title%3D%22old-title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [] }) .post('/2.0/repositories/some/empty/issues') @@ -556,7 +558,7 @@ describe('modules/platform/bitbucket/index', () => { const scope = await initRepoMock({}, { has_issues: true }); scope .get( - '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [ @@ -593,7 +595,7 @@ describe('modules/platform/bitbucket/index', () => { const scope = await initRepoMock({}, { has_issues: true }); scope .get( - '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)%20AND%20reporter.username%3D%22abc%22' + '/2.0/repositories/some/repo/issues?q=title%3D%22title%22%20AND%20(state%20%3D%20%22new%22%20OR%20state%20%3D%20%22open%22)' ) .reply(200, { values: [ @@ -624,11 +626,13 @@ describe('modules/platform/bitbucket/index', () => { }); it('get issues', async () => { + httpMock.scope(baseUrl).get('/2.0/user').reply(200, { uuid: '12345' }); + await bitbucket.initPlatform({ username: 'renovate', password: 'pass' }); const scope = await initRepoMock({}, { has_issues: true }); scope .get('/2.0/repositories/some/repo/issues') .query({ - q: '(state = "new" OR state = "open") AND reporter.username="abc"', + q: '(state = "new" OR state = "open") AND reporter.uuid="12345"', }) .reply(200, { values: [ @@ -655,7 +659,7 @@ describe('modules/platform/bitbucket/index', () => { scope .get('/2.0/repositories/some/repo/issues') .query({ - q: '(state = "new" OR state = "open") AND reporter.username="abc"', + q: '(state = "new" OR state = "open")', }) .reply(500, {}); const issues = await bitbucket.getIssueList(); diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index efe7852211674c4c9426abb16791665b74abb504..dda49add7a274826512f91d96402393f6dd854bb 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -169,7 +169,6 @@ export async function initRepo({ }); config = { repository, - username: opts.username, ignorePrAuthor, } as Config; let info: RepoInfo; @@ -462,13 +461,14 @@ type BbIssue = { id: number; title: string; content?: { raw: string } }; async function findOpenIssues(title: string): Promise<BbIssue[]> { try { - const filter = encodeURIComponent( - [ - `title=${JSON.stringify(title)}`, - '(state = "new" OR state = "open")', - `reporter.username="${config.username}"`, - ].join(' AND ') - ); + const filters = [ + `title=${JSON.stringify(title)}`, + '(state = "new" OR state = "open")', + ]; + if (renovateUserUuid) { + filters.push(`reporter.uuid="${renovateUserUuid}"`); + } + const filter = encodeURIComponent(filters.join(' AND ')); return ( ( await bitbucketHttp.getJson<{ values: BbIssue[] }>( @@ -603,12 +603,11 @@ export async function getIssueList(): Promise<Issue[]> { return []; } try { - const filter = encodeURIComponent( - [ - '(state = "new" OR state = "open")', - `reporter.username="${config.username}"`, - ].join(' AND ') - ); + const filters = ['(state = "new" OR state = "open")']; + if (renovateUserUuid) { + filters.push(`reporter.uuid="${renovateUserUuid}"`); + } + const filter = encodeURIComponent(filters.join(' AND ')); return ( ( await bitbucketHttp.getJson<{ values: Issue[] }>( diff --git a/lib/modules/platform/bitbucket/types.ts b/lib/modules/platform/bitbucket/types.ts index 7611dba4edd0aad61bf7a4562d9d6f6316ed1036..0ffb4b9623cb77a261d38f927bb0bf2535370539 100644 --- a/lib/modules/platform/bitbucket/types.ts +++ b/lib/modules/platform/bitbucket/types.ts @@ -15,8 +15,6 @@ export interface Config { owner: string; prList: Pr[]; repository: string; - username: string; - userUuid: string; ignorePrAuthor: boolean; }