chore: Rename GitIssueUtils trait to GitIssuePrMetadata
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -26,7 +26,7 @@ use crate::{
|
|||||||
error::{N34Error, N34Result},
|
error::{N34Error, N34Result},
|
||||||
nostr_utils::{
|
nostr_utils::{
|
||||||
NostrClient,
|
NostrClient,
|
||||||
traits::{GitIssueUtils, NaddrsUtils, ReposUtils},
|
traits::{GitIssuePrMetadata, NaddrsUtils, ReposUtils},
|
||||||
utils,
|
utils,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -80,9 +80,9 @@ impl CommandRunner for ViewArgs {
|
|||||||
.await?
|
.await?
|
||||||
.ok_or(N34Error::CanNotFoundIssue)?;
|
.ok_or(N34Error::CanNotFoundIssue)?;
|
||||||
|
|
||||||
let issue_subject = utils::smart_wrap(issue.extract_issue_subject(), 70);
|
let issue_subject = utils::smart_wrap(issue.extract_event_subject(), 70);
|
||||||
let issue_author = client.get_username(issue.pubkey).await;
|
let issue_author = client.get_username(issue.pubkey).await;
|
||||||
let mut issue_labels = utils::smart_wrap(&issue.extract_issue_labels(), 70);
|
let mut issue_labels = utils::smart_wrap(&issue.extract_event_labels(), 70);
|
||||||
|
|
||||||
if issue_labels.is_empty() {
|
if issue_labels.is_empty() {
|
||||||
issue_labels = "\n".to_owned();
|
issue_labels = "\n".to_owned();
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ use crate::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
cli::{CliOptions, patch::GitPatch},
|
cli::{CliOptions, patch::GitPatch},
|
||||||
error::{N34Error, N34Result},
|
error::{N34Error, N34Result},
|
||||||
nostr_utils::traits::{GitIssueUtils, GitPatchUtils, ReposUtils},
|
nostr_utils::traits::{GitIssuePrMetadata, GitPatchUtils, ReposUtils},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Updates the issue's status to `new_status` after validating it with
|
/// Updates the issue's status to `new_status` after validating it with
|
||||||
@@ -384,8 +384,8 @@ fn format_patch_and_issue(event: &Event, status: Either<PatchStatus, IssueStatus
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let labels = event.extract_issue_labels();
|
let labels = event.extract_event_labels();
|
||||||
let subject = event.extract_issue_subject();
|
let subject = event.extract_event_subject();
|
||||||
|
|
||||||
if labels.is_empty() {
|
if labels.is_empty() {
|
||||||
subject.to_owned()
|
subject.to_owned()
|
||||||
|
|||||||
@@ -286,22 +286,22 @@ impl Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Utility functions for working with issue events
|
/// Utility functions for working with issue and PR metadata
|
||||||
#[easy_ext::ext(GitIssueUtils)]
|
#[easy_ext::ext(GitIssuePrMetadata)]
|
||||||
impl Event {
|
impl Event {
|
||||||
/// Gets the subject line of the issue or "N/A" if none exists
|
/// Gets the subject line of the issue/pr or "N/A" if none exists
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn extract_issue_subject(&self) -> &str {
|
pub fn extract_event_subject(&self) -> &str {
|
||||||
self.tags
|
self.tags
|
||||||
.find(TagKind::Subject)
|
.find(TagKind::Subject)
|
||||||
.and_then(|t| t.content())
|
.and_then(|t| t.content())
|
||||||
.unwrap_or("N/A")
|
.unwrap_or("N/A")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets all issue labels formatted as comma-separated hashtags (e.g. "#bug,
|
/// Gets all issue/pr labels formatted as comma-separated hashtags (e.g.
|
||||||
/// #feature")
|
/// "#bug, #feature")
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn extract_issue_labels(&self) -> String {
|
pub fn extract_event_labels(&self) -> String {
|
||||||
self.tags
|
self.tags
|
||||||
.filter(TagKind::t())
|
.filter(TagKind::t())
|
||||||
.filter_map(|t| t.content().map(|l| format!("#{l}")))
|
.filter_map(|t| t.content().map(|l| format!("#{l}")))
|
||||||
|
|||||||
Reference in New Issue
Block a user