From 634aa70523867b4e67e5c837695df8b6595c9ccb Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 7 Jun 2025 10:30:59 +0200 Subject: fix(back::config::BackRepositories): Strip a `.git` suffix from repo paths --- src/config/mod.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/config') 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) })?; -- cgit 1.4.1