Skip to content

Commit

Permalink
feat(reporting): improve codespan and github reporting messages
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 15, 2024
1 parent 0ca9a7f commit 5cb7c13
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/reporting/src/internal/emitter/codespan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ impl From<Issue> for Diagnostic<SourceIdentifier> {
}

if let Some(help) = issue.help {
diagnostic.notes.push(format!("help: {}", help));
diagnostic.notes.push(format!("Help: {}", help));
}

if let Some(link) = issue.link {
diagnostic.notes.push(format!("see: {}", link));
diagnostic.notes.push(format!("See: {}", link));
}

diagnostic
Expand Down
26 changes: 25 additions & 1 deletion crates/reporting/src/internal/emitter/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,31 @@ pub fn github_format(
}
};

writeln!(writer, "::{} {}::{}", level, properties, issue.message.as_str())?;
let mut message = issue.message.clone();

// we must use `%0A` instead of `\n`.
//
// see: https://github.com/actions/toolkit/issues/193
if !issue.notes.is_empty() {
message.push_str("%0A");

for note in issue.notes.iter() {
message.push_str("%0A");
message.push_str(note.as_str());
}
}

if let Some(help) = issue.help.as_ref() {
message.push_str("%0A%0AHelp: ");
message.push_str(help.as_str());
}

if let Some(link) = issue.link.as_ref() {
message.push_str("%0A%0AMore information: ");
message.push_str(link.as_str());
}

writeln!(writer, "::{} {}::{}", level, properties, message)?;
}

Ok(highest_level)
Expand Down

0 comments on commit 5cb7c13

Please sign in to comment.