commitstatus: Trim description to 140 characters if it is too long
This commit is contained in:
parent
9f70ab9c13
commit
5730914971
|
@ -46,12 +46,19 @@ impl<'a> CommitStatus<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(&self, state: hubcaps::statuses::State) {
|
pub fn set(&self, state: hubcaps::statuses::State) {
|
||||||
|
let desc = if self.description.len() >= 140 {
|
||||||
|
eprintln!("Warning: description is over 140 char; truncating: {:?}", &self.description);
|
||||||
|
self.description.chars().take(140).collect()
|
||||||
|
} else {
|
||||||
|
self.description.clone()
|
||||||
|
};
|
||||||
|
|
||||||
self.api
|
self.api
|
||||||
.create(
|
.create(
|
||||||
self.sha.as_ref(),
|
self.sha.as_ref(),
|
||||||
&hubcaps::statuses::StatusOptions::builder(state)
|
&hubcaps::statuses::StatusOptions::builder(state)
|
||||||
.context(self.context.clone())
|
.context(self.context.clone())
|
||||||
.description(self.description.clone())
|
.description(desc)
|
||||||
.target_url(self.url.clone())
|
.target_url(self.url.clone())
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue