From 42bec3dc62017e85c74a9da4f14f6d27757fa0a4 Mon Sep 17 00:00:00 2001 From: "rick.stokkingreef" Date: Mon, 15 Dec 2025 14:00:13 +0100 Subject: [PATCH 1/2] fix: When team name contains spaces make sure it matches the team_slug Signed-off-by: rick.stokkingreef --- lib/plugins/teams.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/plugins/teams.js b/lib/plugins/teams.js index 4d7f79273..406291704 100644 --- a/lib/plugins/teams.js +++ b/lib/plugins/teams.js @@ -33,9 +33,9 @@ module.exports = class Teams extends Diffable { this.log.debug('Removing all security manager teams since they should not be handled here') this.log.debug(`Calling API to get security managers ${JSON.stringify(this.github.request.endpoint('GET /orgs/{org}/security-managers', - { - org: this.repo.owner - }))} `) + { + org: this.repo.owner + }))} `) const resp = await this.github.paginate('GET /orgs/{org}/security-managers', { org: this.repo.owner }) @@ -46,15 +46,18 @@ module.exports = class Teams extends Diffable { this.log.debug(`${this.repo.owner} Org does not have Security manager teams set up ${e}`) } else { this.log.error( - `Unexpected error when fetching for security manager teams org ${this.repo.owner} = ${e}` + `Unexpected error when fetching for security manager teams org ${this.repo.owner} = ${e}` ) } return teams } } + slugify (name) { + return name.toLowerCase().replace(/\s+/g, '-') + } comparator (existing, attrs) { - return existing.slug === attrs.name.toLowerCase() + return existing.slug === this.slugify(attrs.name) } changed (existing, attrs) { @@ -72,8 +75,8 @@ module.exports = class Teams extends Diffable { add (attrs) { let existing = { team_id: 1 } - this.log.debug(`Getting team with the parms ${JSON.stringify(attrs)}`) - return this.github.teams.getByName({ org: this.repo.owner, team_slug: attrs.name }).then(res => { + this.log.debug(`Getting team with the parms ${JSON.stringify(attrs)}, ${this.slugify(attrs.name)}`) + return this.github.teams.getByName({ org: this.repo.owner, team_slug: this.slugify(attrs.name) }).then(res => { existing = res.data this.log.debug(`adding team ${attrs.name} to repo ${this.repo.repo}`) if (this.nop) { @@ -132,7 +135,7 @@ module.exports = class Teams extends Diffable { return { team_id: existing.id, org: this.repo.owner, - team_slug: attrs.name, + team_slug: this.slugify(existing.name), owner: this.repo.owner, repo: this.repo.repo, permission: attrs.permission From 69bdcaa4fa2eb0cd9b5b3bf9a4cdc745ab8cbad7 Mon Sep 17 00:00:00 2001 From: "rick.stokkingreef" Date: Mon, 15 Dec 2025 14:01:10 +0100 Subject: [PATCH 2/2] remove debug Signed-off-by: rick.stokkingreef --- lib/plugins/teams.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/teams.js b/lib/plugins/teams.js index 406291704..700d0e055 100644 --- a/lib/plugins/teams.js +++ b/lib/plugins/teams.js @@ -75,7 +75,7 @@ module.exports = class Teams extends Diffable { add (attrs) { let existing = { team_id: 1 } - this.log.debug(`Getting team with the parms ${JSON.stringify(attrs)}, ${this.slugify(attrs.name)}`) + this.log.debug(`Getting team with the parms ${JSON.stringify(attrs)}`) return this.github.teams.getByName({ org: this.repo.owner, team_slug: this.slugify(attrs.name) }).then(res => { existing = res.data this.log.debug(`adding team ${attrs.name} to repo ${this.repo.repo}`)