chore: Use new stabilized let-chains feature
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -89,11 +89,12 @@ impl CliConfig {
|
||||
pub fn load(file_path: PathBuf) -> N34Result<Self> {
|
||||
tracing::info!(path = %file_path.display(), "Loading configuration from file");
|
||||
// Make sure the file is exist
|
||||
if let Some(parent) = file_path.parent() {
|
||||
if !parent.exists() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
if let Some(parent) = file_path.parent()
|
||||
&& !parent.exists()
|
||||
{
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
let _ = fs::File::create_new(&file_path);
|
||||
|
||||
let mut config: Self =
|
||||
|
||||
@@ -82,10 +82,10 @@ impl Cli {
|
||||
pub fn post_cli(mut cli: Cli) -> N34Result<Cli> {
|
||||
cli.options.pow = cli.options.pow.or(cli.options.config.pow);
|
||||
|
||||
if cli.options.relays.is_empty() {
|
||||
if let Some(relays) = &cli.options.config.fallback_relays {
|
||||
cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect();
|
||||
}
|
||||
if cli.options.relays.is_empty()
|
||||
&& let Some(relays) = &cli.options.config.fallback_relays
|
||||
{
|
||||
cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect();
|
||||
}
|
||||
|
||||
Ok(cli)
|
||||
|
||||
@@ -314,16 +314,16 @@ impl NostrClient {
|
||||
.map(|status| N34Result::Ok((PatchStatus::try_from(status.kind)?, status.tags)))
|
||||
.unwrap_or_else(|| Ok((PatchStatus::Open, Tags::new())))?;
|
||||
|
||||
if let Some(revision_id) = root_revision {
|
||||
if root_status.is_merged_or_applied()
|
||||
&& !event_tags
|
||||
.filter(TagKind::e())
|
||||
.any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex()))
|
||||
{
|
||||
return Ok(PatchStatus::Closed);
|
||||
}
|
||||
if let Some(revision_id) = root_revision
|
||||
&& root_status.is_merged_or_applied()
|
||||
&& !event_tags
|
||||
.filter(TagKind::e())
|
||||
.any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex()))
|
||||
{
|
||||
return Ok(PatchStatus::Closed);
|
||||
}
|
||||
|
||||
|
||||
Ok(root_status)
|
||||
}
|
||||
|
||||
@@ -368,10 +368,10 @@ impl NostrClient {
|
||||
{
|
||||
self.add_relay_hint(relay_hint.cloned()).await;
|
||||
let root_event = self.fetch_event(Filter::new().id(*id)).await?;
|
||||
if let Some(ref root_event) = root_event {
|
||||
if !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch) {
|
||||
return Err(N34Error::CanNotReplyToEvent);
|
||||
}
|
||||
if let Some(ref root_event) = root_event
|
||||
&& !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch)
|
||||
{
|
||||
return Err(N34Error::CanNotReplyToEvent);
|
||||
}
|
||||
return Ok(root_event);
|
||||
} else if let Some(nip22::CommentTarget::Event { id, relay_hint, .. }) =
|
||||
|
||||
@@ -207,10 +207,10 @@ pub fn read_editor(file_pre_content: Option<&str>, file_suffix: &str) -> N34Resu
|
||||
.wait()?;
|
||||
crate::EDITOR_OPEN.store(false, Ordering::Relaxed);
|
||||
|
||||
if !exit_status.success() {
|
||||
if let Some(code) = exit_status.code() {
|
||||
return Err(N34Error::EditorErr(editor, code));
|
||||
}
|
||||
if !exit_status.success()
|
||||
&& let Some(code) = exit_status.code()
|
||||
{
|
||||
return Err(N34Error::EditorErr(editor, code));
|
||||
}
|
||||
|
||||
let content = fs::read_to_string(&temp_path)
|
||||
|
||||
Reference in New Issue
Block a user