Skip to content

Commit

Permalink
log waring for unavaiable labels
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Mar 18, 2024
1 parent 8b92b64 commit 70126e0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
42 changes: 42 additions & 0 deletions lib/modules/platform/gitea/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,48 @@ describe('modules/platform/gitea/index', () => {
}),
).toResolve();
});

it('should log a warning if labels could not be looked up', async () => {
const updatedMockPR = partial<PR>({
...mockPRs[0],
number: 1,
title: 'New Title',
body: 'New Body',
state: 'open',
labels: [
{
id: 1,
name: 'some-label',
},
],
});
const scope = httpMock
.scope('https://gitea.com/api/v1')
.get('/repos/some/repo/pulls')
.query({ state: 'all', sort: 'recentupdate' })
.reply(200, mockPRs)
.get('/repos/some/repo/labels')
.reply(200, mockRepoLabels)
.get('/orgs/some/labels')
.reply(200, mockOrgLabels)
.patch('/repos/some/repo/pulls/1')
.reply(200, updatedMockPR);

await initFakePlatform(scope);
await initFakeRepo(scope);
await expect(
gitea.updatePr({
number: 1,
prTitle: 'New Title',
prBody: 'New Body',
state: 'open',
labels: ['some-label', 'unavailable-label'],
}),
).toResolve();
expect(logger.warn).toHaveBeenCalledWith(
'Some labels could not be looked up. Renovate may halt label updates assuming changes by others.',
);
});
});

describe('mergePr', () => {
Expand Down
5 changes: 5 additions & 0 deletions lib/modules/platform/gitea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ const platform: Platform = {
prUpdateParams.labels = (await map(labels, lookupLabelByName)).filter(
is.number,
);
if (labels.length !== prUpdateParams.labels.length) {
logger.warn(
'Some labels could not be looked up. Renovate may halt label updates assuming changes by others.',
);
}
}

const gpr = await helper.updatePR(
Expand Down

0 comments on commit 70126e0

Please sign in to comment.