diff --git a/lib/plugins/teams.js b/lib/plugins/teams.js index 4d7f7927..700d0e05 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) { @@ -73,7 +76,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)}`) - return this.github.teams.getByName({ org: this.repo.owner, team_slug: attrs.name }).then(res => { + 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