Skip to content

Commit

Permalink
Team descriptions can be null
Browse files Browse the repository at this point in the history
When a team does not have a description, GitHub's API sets the
`description` field to `null`. This breaks deserialization, which
expects the field to be set to a `String`.

This is most likely only an issue for teams that have not previously
been managed by sync-team, e.g. when an existing organizations is added
to the team repository.
  • Loading branch information
jdno authored and Mark-Simulacrum committed Dec 13, 2023
1 parent 1bc1e73 commit 9991616
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/github/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl GitHub {
// doesn't actually exist on GitHub
id: None,
name: name.to_string(),
description: description.to_string(),
description: Some(description.to_string()),
privacy,
slug: name.to_string(),
})
Expand Down Expand Up @@ -889,7 +889,7 @@ pub(crate) struct Team {
/// a dry run and not actually present on GitHub, so other methods can avoid acting on them.
pub(crate) id: Option<usize>,
pub(crate) name: String,
pub(crate) description: String,
pub(crate) description: Option<String>,
pub(crate) privacy: TeamPrivacy,
/// The slug usually matches the name but can differ.
/// For example, a team named rustup.rs would have a slug rustup-rs.
Expand Down
11 changes: 9 additions & 2 deletions src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ impl SyncGitHub {
name_diff = Some(github_team.name.clone())
}
let mut description_diff = None;
if team.description != DEFAULT_DESCRIPTION {
description_diff = Some((team.description.clone(), DEFAULT_DESCRIPTION.to_owned()));
match &team.description {
Some(description) => {
if description != DEFAULT_DESCRIPTION {
description_diff = Some((description.clone(), DEFAULT_DESCRIPTION.to_owned()));
}
}
None => {
description_diff = Some((String::new(), DEFAULT_DESCRIPTION.to_owned()));
}
}
let mut privacy_diff = None;
if team.privacy != DEFAULT_PRIVACY {
Expand Down

0 comments on commit 9991616

Please sign in to comment.