summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornickelc <constantin.nickel@gmail.com>2023-03-05 23:24:24 +0100
committerGitHub <noreply@github.com>2023-03-05 17:24:24 -0500
commit5e4faabfd36b3fae69dc15b2f39f18196bd5154c (patch)
tree7dfed17bf3bde8412ed2657fbdc1de696c6aa41a
parenta8446c53bb32fa7c2d1fc4cddb4720b737b2cc8a (diff)
Return the `GitRemoteRepo` type directly (#1328)
The type is unnecessarily wrapped and it's the only use for `GitConfigEntry::GitRemote` enum variant.
-rw-r--r--src/features/hyperlinks.rs4
-rw-r--r--src/git_config/git_config_entry.rs1
-rw-r--r--src/git_config/mod.rs8
3 files changed, 4 insertions, 9 deletions
diff --git a/src/features/hyperlinks.rs b/src/features/hyperlinks.rs
index 118d8355..841c7518 100644
--- a/src/features/hyperlinks.rs
+++ b/src/features/hyperlinks.rs
@@ -6,7 +6,7 @@ use regex::{Captures, Regex};
use crate::config::Config;
use crate::features::OptionValueFunction;
-use crate::git_config::{GitConfig, GitConfigEntry, GitRemoteRepo};
+use crate::git_config::{GitConfig, GitRemoteRepo};
pub fn make_feature() -> Vec<(String, OptionValueFunction)> {
builtin_feature!([
@@ -32,7 +32,7 @@ pub fn format_commit_line_with_osc8_commit_hyperlink<'a>(
format_osc8_hyperlink(&commit_link_format.replace("{commit}", commit), commit);
format!("{prefix}{formatted_commit}{suffix}")
})
- } else if let Some(GitConfigEntry::GitRemote(repo)) = config
+ } else if let Some(repo) = config
.git_config
.as_ref()
.and_then(GitConfig::get_remote_url)
diff --git a/src/git_config/git_config_entry.rs b/src/git_config/git_config_entry.rs
index c07fc0a0..ccb16c0e 100644
--- a/src/git_config/git_config_entry.rs
+++ b/src/git_config/git_config_entry.rs
@@ -9,7 +9,6 @@ use crate::errors::*;
#[derive(Clone, Debug)]
pub enum GitConfigEntry {
Style(String),
- GitRemote(GitRemoteRepo),
}
#[derive(Clone, Debug, PartialEq, Eq)]
diff --git a/src/git_config/mod.rs b/src/git_config/mod.rs
index 8246df4a..60fb0a62 100644
--- a/src/git_config/mod.rs
+++ b/src/git_config/mod.rs
@@ -96,17 +96,13 @@ impl GitConfig {
}
}
- pub fn get_remote_url(&self) -> Option<GitConfigEntry> {
+ pub fn get_remote_url(&self) -> Option<GitRemoteRepo> {
self.repo
.as_ref()?
.find_remote("origin")
.ok()?
.url()
- .and_then(|url| {
- GitRemoteRepo::from_str(url)
- .ok()
- .map(GitConfigEntry::GitRemote)
- })
+ .and_then(|url| GitRemoteRepo::from_str(url).ok())
}
pub fn for_each<F>(&self, regex: &str, mut f: F)