@@ -33,9 +33,9 @@ module.exports = class Teams extends Diffable {
3333
3434 this . log . debug ( 'Removing all security manager teams since they should not be handled here' )
3535 this . log . debug ( `Calling API to get security managers ${ JSON . stringify ( this . github . request . endpoint ( 'GET /orgs/{org}/security-managers' ,
36- {
37- org : this . repo . owner
38- } ) ) } `)
36+ {
37+ org : this . repo . owner
38+ } ) ) } `)
3939 const resp = await this . github . paginate ( 'GET /orgs/{org}/security-managers' ,
4040 { org : this . repo . owner } )
4141
@@ -46,15 +46,18 @@ module.exports = class Teams extends Diffable {
4646 this . log . debug ( `${ this . repo . owner } Org does not have Security manager teams set up ${ e } ` )
4747 } else {
4848 this . log . error (
49- `Unexpected error when fetching for security manager teams org ${ this . repo . owner } = ${ e } `
49+ `Unexpected error when fetching for security manager teams org ${ this . repo . owner } = ${ e } `
5050 )
5151 }
5252 return teams
5353 }
5454 }
55+ slugify ( name ) {
56+ return name . toLowerCase ( ) . replace ( / \s + / g, '-' )
57+ }
5558
5659 comparator ( existing , attrs ) {
57- return existing . slug === attrs . name . toLowerCase ( )
60+ return existing . slug === this . slugify ( attrs . name )
5861 }
5962
6063 changed ( existing , attrs ) {
@@ -72,8 +75,8 @@ module.exports = class Teams extends Diffable {
7275
7376 add ( attrs ) {
7477 let existing = { team_id : 1 }
75- this . log . debug ( `Getting team with the parms ${ JSON . stringify ( attrs ) } ` )
76- return this . github . teams . getByName ( { org : this . repo . owner , team_slug : attrs . name } ) . then ( res => {
78+ this . log . debug ( `Getting team with the parms ${ JSON . stringify ( attrs ) } , ${ this . slugify ( attrs . name ) } ` )
79+ return this . github . teams . getByName ( { org : this . repo . owner , team_slug : this . slugify ( attrs . name ) } ) . then ( res => {
7780 existing = res . data
7881 this . log . debug ( `adding team ${ attrs . name } to repo ${ this . repo . repo } ` )
7982 if ( this . nop ) {
@@ -132,7 +135,7 @@ module.exports = class Teams extends Diffable {
132135 return {
133136 team_id : existing . id ,
134137 org : this . repo . owner ,
135- team_slug : attrs . name ,
138+ team_slug : this . slugify ( existing . name ) ,
136139 owner : this . repo . owner ,
137140 repo : this . repo . repo ,
138141 permission : attrs . permission
0 commit comments