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 | |
parent | chore(version): v0.1.2 (diff) | |
download | back-634aa70523867b4e67e5c837695df8b6595c9ccb.zip |
fix(back::config::BackRepositories): Strip a `.git` suffix from repo paths
-rw-r--r-- | src/config/mod.rs | 20 | ||||
-rw-r--r-- | src/error/mod.rs | 5 |
2 files changed, 21 insertions, 4 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) })?; diff --git a/src/error/mod.rs b/src/error/mod.rs index f109e11..0d25d90 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -58,7 +58,10 @@ pub enum Error { #[error("while trying to read an identity's data from a replica: {0}")] RepoIdentityRead(#[from] replica::entity::read::Error<Identity>), - #[error("failed to find the repository at path: '{repository_path}'")] + #[error( + "failed to find the repository at path: '{repository_path}' (Not registered in \ + projects.list)" + )] RepoFind { repository_path: PathBuf }, #[error("while iteration over the refs in a repository: {0}")] |