diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-07 10:30:59 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-07 10:30:59 +0200 |
commit | 634aa70523867b4e67e5c837695df8b6595c9ccb (patch) | |
tree | 0c7c34e223760797d0f905cb67b57539e6bbca0f /src/config/mod.rs | |
parent | chore(version): v0.1.2 (diff) | |
download | back-634aa70523867b4e67e5c837695df8b6595c9ccb.zip |
fix(back::config::BackRepositories): Strip a `.git` suffix from repo paths
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r-- | src/config/mod.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 07c6c29..f9ae103 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -16,6 +16,7 @@ use std::{ }; use git_bug::{entities::issue::Issue, replica::Replica}; +use log::info; use serde::Deserialize; use url::Url; @@ -81,6 +82,7 @@ impl BackRepositories { #[derive(Debug)] pub struct BackRepository { + /// The path to the repository, with a possible `.git` suffix stripped. repo_path: PathBuf, } @@ -139,9 +141,21 @@ impl BackConfig { })? .lines() .try_fold(vec![], |mut acc, path| { - acc.push(BackRepository { - repo_path: PathBuf::from(path), - }); + let mut path = PathBuf::from(path); + + let repo_path = if path + .extension() + .is_some_and(|ext| ext.eq_ignore_ascii_case("git")) + { + info!("Removing a `.git` suffix from path: {}", path.display()); + + path.set_extension(""); + path + } else { + path + }; + + acc.push(BackRepository { repo_path }); Ok::<_, Error>(acc) })?; |