1pub mod accept_maintainership;
2pub mod cli_interactor;
3pub mod client;
4pub mod content_tags;
5pub mod fetch;
6pub mod git;
7pub mod git_events;
8pub mod list;
9pub mod login;
10pub mod mbox_parser;
11pub mod push;
12pub mod repo_ref;
13pub mod repo_state;
14pub mod transport;
17pub mod utils;
18
19use anyhow::{Result, anyhow};
20use directories::ProjectDirs;
21use nostr_sdk::Url;
22
23pub fn get_dirs() -> Result<ProjectDirs> {
24 ProjectDirs::from("", "", "ngit").ok_or(anyhow!(
25 "should find operating system home directories with rust-directories crate"
26 ))
27}
28
29pub trait UrlWithoutSlash {
30 fn as_str_without_trailing_slash(&self) -> &str;
31 fn to_string_without_trailing_slash(&self) -> String;
32}
33
34impl UrlWithoutSlash for Url {
35 fn as_str_without_trailing_slash(&self) -> &str {
36 let url_str = self.as_str();
37 if let Some(without) = url_str.strip_suffix('/') {
38 without
39 } else {
40 url_str
41 }
42 }
43
44 fn to_string_without_trailing_slash(&self) -> String {
45 self.as_str_without_trailing_slash().to_string()
46 }
47}