diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index 61aca917500fd9da4631bbbd32b569201e24191d..ab669e05a6246dedc6ca536bdda9f224127e66a9 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -696,8 +696,7 @@ const platform: Platform = { (label) => label.id ); if ( - labels !== undefined && - labels.length !== 0 && + labels && (labels.length !== existingLabelIds.length || labels.filter((labelId) => !existingLabelIds.includes(labelId)) .length !== 0) diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 61f32c3cf7c21d9331a4c28b378026ea796dae77..869c13744e36a66a973d0db36e50fdcb3171c720 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -1202,12 +1202,16 @@ export async function ensureIssue({ } if (shouldReOpen) { logger.debug('Patching issue'); + const data: Record<string, unknown> = { body, state: 'open', title }; + if (labels) { + data.labels = labels; + } await githubApi.patchJson( `repos/${config.parentRepo || config.repository}/issues/${ issue.number }`, { - body: { body, state: 'open', title, labels }, + body: data, } ); logger.debug('Issue updated'); diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 4a585f3a28250d5bd368fd6adc080d7e726e1fd7..18125a3e264a295360b1dfa70b62303dcbb59fbe 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -733,13 +733,12 @@ export async function getIssueList(): Promise<GitlabIssue[]> { author_id: `${authorId}`, state: 'opened', }); - const res = await gitlabApi.getJson<{ iid: number; title: string }[]>( - `projects/${config.repository}/issues?${query}`, - { - useCache: false, - paginate: true, - } - ); + const res = await gitlabApi.getJson< + { iid: number; title: string; labels: string[] }[] + >(`projects/${config.repository}/issues?${query}`, { + useCache: false, + paginate: true, + }); // istanbul ignore if if (!is.array(res.body)) { logger.warn({ responseBody: res.body }, 'Could not retrieve issue list'); @@ -748,6 +747,7 @@ export async function getIssueList(): Promise<GitlabIssue[]> { config.issueList = res.body.map((i) => ({ iid: i.iid, title: i.title, + labels: i.labels, })); } return config.issueList; @@ -814,7 +814,7 @@ export async function ensureIssue({ await gitlabApi.putJson( `projects/${config.repository}/issues/${issue.iid}`, { - body: { title, description, labels }, + body: { title, description, labels: labels ?? issue.labels }, } ); return 'updated'; diff --git a/lib/platform/gitlab/types.ts b/lib/platform/gitlab/types.ts index f35eba0b51b4c55aab63c6d88327fe25f33a44a6..11c2fff864ca5c4add978e26ae0dda5231fc182e 100644 --- a/lib/platform/gitlab/types.ts +++ b/lib/platform/gitlab/types.ts @@ -1,5 +1,8 @@ export interface GitlabIssue { iid: number; + + labels?: string[]; + title: string; }