chore: issues utils

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-07-01 15:07:04 +00:00
parent 4cc01668fd
commit 7e479f3c7a
2 changed files with 28 additions and 22 deletions

View File

@@ -262,3 +262,27 @@ impl Event {
.map_err(|err| N34Error::InvalidEvent(format!("Invalid event ID in `e` tag: {err}")))
}
}
/// Utility functions for working with issue events
#[easy_ext::ext(GitIssueUtils)]
impl Event {
/// Gets the subject line of the issue or "N/A" if none exists
#[inline]
pub fn extract_issue_subject(&self) -> &str {
self.tags
.find(TagKind::Subject)
.and_then(|t| t.content())
.unwrap_or("N/A")
}
/// Gets all issue labels formatted as comma-separated hashtags (e.g. "#bug,
/// #feature")
#[inline]
pub fn extract_issue_labels(&self) -> String {
self.tags
.filter(TagKind::t())
.filter_map(|t| t.content().map(|l| format!("#{l}")))
.collect::<Vec<_>>()
.join(", ")
}
}