-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty (but not null) entries should clear teams and collaborators #301
Draft
Chris-V
wants to merge
3
commits into
github:main-enterprise
Choose a base branch
from
equisoft:support_empty_target_diffs
base: main-enterprise
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,7 +5,7 @@ const NopCommand = require('../nopcommand') | |||||
const teamRepoEndpoint = '/teams/:team_id/repos/:owner/:repo' | ||||||
module.exports = class Teams extends Diffable { | ||||||
async find () { | ||||||
this.log(`Finding teams for ${this.repo.owner}/${this.repo.repo}`) | ||||||
this.log.debug(`Finding teams for ${this.repo.owner}/${this.repo.repo}`) | ||||||
return this.github.repos.listTeams(this.repo).then(res => res.data).catch(e => { return [] }) | ||||||
} | ||||||
|
||||||
|
@@ -28,19 +28,19 @@ module.exports = class Teams extends Diffable { | |||||
|
||||||
add (attrs) { | ||||||
let existing = { team_id: 1 } | ||||||
this.log(`Getting team with the parms ${JSON.stringify(attrs)}`) | ||||||
this.log.debug(`Getting team with the parms ${JSON.stringify(attrs)}`) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return this.github.teams.getByName({ org: this.repo.owner, team_slug: attrs.name }).then(res => { | ||||||
existing = res.data | ||||||
this.log(`adding team ${attrs.name} to repo ${this.repo.repo}`) | ||||||
this.log.debug(`adding team ${attrs.name} to repo ${this.repo.repo}`) | ||||||
if (this.nop) { | ||||||
return Promise.resolve([ | ||||||
new NopCommand(this.constructor.name, this.repo, this.github.teams.addOrUpdateRepoPermissionsInOrg.endpoint(this.toParams(existing, attrs)), 'Add Teams to Repo') | ||||||
]) | ||||||
} | ||||||
return this.github.teams.addOrUpdateRepoPermissionsInOrg(this.toParams(existing, attrs)).then(res => { | ||||||
this.log(`team added ${res}`) | ||||||
this.log.debug(`team added ${res}`) | ||||||
}).catch(e => { | ||||||
this.log(`Error adding team to repo ${JSON.stringify(e)} with parms ${JSON.stringify(this.toParams(existing, attrs))}`) | ||||||
this.log.error(`Error adding team to repo ${JSON.stringify(e)} with parms ${JSON.stringify(this.toParams(existing, attrs))}:\n`, e) | ||||||
}) | ||||||
}).catch(e => { | ||||||
if (e.status === 404) { | ||||||
|
@@ -51,19 +51,19 @@ module.exports = class Teams extends Diffable { | |||||
if (attrs.privacy) { | ||||||
createParam.privacy = attrs.privacy | ||||||
} | ||||||
this.log(`Creating teams ${JSON.stringify(createParam)}`) | ||||||
this.log.debug(`Creating teams ${JSON.stringify(createParam)}`) | ||||||
if (this.nop) { | ||||||
return Promise.resolve([ | ||||||
new NopCommand(this.constructor.name, this.repo, this.github.teams.create.endpoint(createParam), 'Create Team') | ||||||
]) | ||||||
} | ||||||
return this.github.teams.create(createParam).then(res => { | ||||||
this.log(`team ${createParam.name} created`) | ||||||
this.log.debug(`team ${createParam.name} created`) | ||||||
existing = res.data | ||||||
this.log(`adding team ${attrs.name} to repo ${this.repo.repo}`) | ||||||
this.log.debug(`adding team ${attrs.name} to repo ${this.repo.repo}`) | ||||||
return this.github.teams.addOrUpdateRepoPermissionsInOrg(this.toParams(existing, attrs)) | ||||||
}).catch(e => { | ||||||
this.log(`Error adding team ${e}`) | ||||||
this.log.error('Error adding team: ', e) | ||||||
}) | ||||||
} | ||||||
}) | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful. This will remove the collaborators. See https://github.com/github/safe-settings/pull/342/files#diff-aadaae6765a1167f3187e283961920c01d5db933ff8a7908ff10554b5520e689R117.