Skip to content

Commit f7f47de

Browse files
committed
Reduce space taken by workflow URLs in try build started comment
1 parent 67ee920 commit f7f47de

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/bors/comment.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,14 @@ pub fn try_build_started_comment(
198198
Comment::new(msg)
199199
}
200200

201-
pub fn append_workflow_links_to_comment(comment_content: &mut String, workflow_links: Vec<String>) {
202-
comment_content.push_str("\n**Workflows**:\n\n");
203-
204-
for link in workflow_links {
205-
comment_content.push_str(&format!("- {link}\n"));
201+
pub fn append_workflow_links_to_comment(comment_content: &mut String, workflow_urls: Vec<String>) {
202+
if workflow_urls.len() == 1 {
203+
comment_content.push_str(&format!("\n**Workflow**: {}", workflow_urls[0]));
204+
} else {
205+
comment_content.push_str("\n**Workflows**:\n\n");
206+
for url in workflow_urls {
207+
comment_content.push_str(&format!("- {url}\n"));
208+
}
206209
}
207210
}
208211

src/bors/handlers/trybuild.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,9 +1104,7 @@ try_failed = ["+foo", "+bar", "-baz"]
11041104
11051105
To cancel the try build, run the command `@bors try cancel`.
11061106
1107-
**Workflows**:
1108-
1109-
- https://github.com/rust-lang/borstest/actions/runs/1
1107+
**Workflow**: https://github.com/rust-lang/borstest/actions/runs/1
11101108
");
11111109

11121110
Ok(())

src/bors/handlers/workflow.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,18 @@ async fn add_workflow_links_to_try_build_start_comment(
9595

9696
let workflows = db.get_workflow_urls_for_build(build).await?;
9797

98-
let mut comment_content = repo
99-
.client
100-
.get_comment_content(&try_build_comment.node_id)
101-
.await?;
98+
if !workflows.is_empty() {
99+
let mut comment_content = repo
100+
.client
101+
.get_comment_content(&try_build_comment.node_id)
102+
.await?;
102103

103-
append_workflow_links_to_comment(&mut comment_content, workflows);
104+
append_workflow_links_to_comment(&mut comment_content, workflows);
104105

105-
repo.client
106-
.update_comment_content(&try_build_comment.node_id, &comment_content)
107-
.await?;
106+
repo.client
107+
.update_comment_content(&try_build_comment.node_id, &comment_content)
108+
.await?;
109+
}
108110

109111
Ok(())
110112
}

0 commit comments

Comments
 (0)