Skip to content

Commit

Permalink
Properly normalize whitespace in descriptions
Browse files Browse the repository at this point in the history
Closes #13.
  • Loading branch information
jwodder committed Oct 24, 2023
1 parent cb8a720 commit c3a05b1
Show file tree
Hide file tree
Showing 4 changed files with 393 additions and 255 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v0.3.0 (in development)
-----------------------
- Properly normalize whitespace in label names
- Properly normalize whitespace in descriptions

v0.2.0 (2023-10-22)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ struct UpdateLabel {
new_name: Option<LabelName>,
#[serde_as(as = "Option<AsHashlessRgb>")]
color: Option<Color>,
description: Option<String>,
description: Option<Description>,
}

#[derive(Debug, Error)]
Expand Down
48 changes: 24 additions & 24 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub(crate) struct PartialLabelOptions {
pub(crate) create: Option<bool>,
pub(crate) update: Option<bool>,
pub(crate) color: Option<ColorSpec>,
pub(crate) description: Option<String>,
pub(crate) description: Option<Description>,
pub(crate) on_rename_clash: Option<OnRenameClash>,
pub(crate) enforce_case: Option<bool>,
}
Expand Down Expand Up @@ -292,7 +292,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -304,7 +304,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("blue".parse().unwrap()),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("yellow".parse().unwrap()),
description: Some(String::from("Gnu all the stos")),
description: Some("Gnu all the stos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -364,7 +364,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("green".parse().unwrap()),
description: Some(String::from("Clee all the shs")),
description: Some("Clee all the shs".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -403,7 +403,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("yellow".parse().unwrap()),
description: Some(String::from("Gnu all the stos")),
description: Some("Gnu all the stos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -415,7 +415,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("green".parse().unwrap()),
description: Some(String::from("Clee all the shs")),
description: Some("Clee all the shs".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -469,7 +469,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -486,7 +486,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("blue".parse().unwrap()),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -593,7 +593,7 @@ mod tests {
rename_from: vec!["food".parse().unwrap(), "drink".parse().unwrap()],
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -605,7 +605,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("blue".parse().unwrap()),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -664,7 +664,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::default(),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: false,
update: true,
on_rename_clash: OnRenameClash::Warn,
Expand Down Expand Up @@ -715,7 +715,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: false,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -727,7 +727,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("#cccccc".parse().unwrap()),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -766,7 +766,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: false,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -778,7 +778,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("#cccccc".parse().unwrap()),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -829,7 +829,7 @@ mod tests {
"green".parse().unwrap(),
"blue".parse().unwrap(),
]),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: false,
update: true,
on_rename_clash: OnRenameClash::Error,
Expand All @@ -841,7 +841,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("orange".parse().unwrap()),
description: Some(String::from("This is a label.")),
description: Some("This is a label.".parse().unwrap()),
create: true,
update: false,
on_rename_clash: OnRenameClash::Warn,
Expand Down Expand Up @@ -890,7 +890,7 @@ mod tests {
"yellow".parse().unwrap(),
"purple".parse().unwrap(),
]),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -911,7 +911,7 @@ mod tests {
"green".parse().unwrap(),
"blue".parse().unwrap(),
]),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
create: false,
update: false,
on_rename_clash: OnRenameClash::default(),
Expand Down Expand Up @@ -943,7 +943,7 @@ mod tests {
rename_from: Vec::new(),
options: LabelOptions {
color: ColorSpec::Fixed("red".parse().unwrap()),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
create: true,
update: true,
on_rename_clash: OnRenameClash::default(),
Expand All @@ -959,12 +959,12 @@ mod tests {
Label {
name: "Foo".parse().unwrap(),
color: "red".parse().unwrap(),
description: Some(String::from("Foo all the bars")),
description: Some("Foo all the bars".parse().unwrap()),
},
Label {
name: "bar".parse().unwrap(),
color: "blue".parse().unwrap(),
description: Some(String::from("Bar all the foos")),
description: Some("Bar all the foos".parse().unwrap()),
},
Label {
name: "no-desc".parse().unwrap(),
Expand All @@ -974,7 +974,7 @@ mod tests {
Label {
name: "empty-desc".parse().unwrap(),
color: "yellow".parse().unwrap(),
description: Some(String::new()),
description: Some("".parse().unwrap()),
},
];
let cfg = Config::from_labels(String::from("test"), labels);
Expand Down
Loading

0 comments on commit c3a05b1

Please sign in to comment.