mirror of
https://github.com/denisidoro/navi.git
synced 2026-07-20 16:50:38 +00:00
formated properly
This commit is contained in:
parent
970cd7f5f0
commit
3a7adbe24d
2 changed files with 11 additions and 13 deletions
|
|
@ -1,10 +1,10 @@
|
|||
use crate::prelude::*;
|
||||
use remove_dir_all::remove_dir_all;
|
||||
use std::env::current_exe;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::{create_dir_all, File, read_link};
|
||||
use std::fs::{create_dir_all, read_link, File};
|
||||
use std::io::BufReader;
|
||||
use thiserror::Error;
|
||||
use std::env::current_exe;
|
||||
|
||||
pub trait ToStringExt {
|
||||
fn to_string(&self) -> String;
|
||||
|
|
@ -43,13 +43,12 @@ pub fn open<P: AsRef<Path>>(filename: P) -> Result<File> {
|
|||
|
||||
pub fn read_lines<P: AsRef<Path>>(filename: P) -> Result<impl Iterator<Item = Result<String>>> {
|
||||
let file = open(filename.as_ref())?;
|
||||
Ok(BufReader::new(file)
|
||||
.lines()
|
||||
.map(|line| line.map_err(Error::from)))
|
||||
Ok(BufReader::new(file).lines().map(|line| line.map_err(Error::from)))
|
||||
}
|
||||
|
||||
fn pathbuf_to_string<P: AsRef<Path>>(pathbuf: P) -> Result<String> {
|
||||
Ok(pathbuf.as_ref()
|
||||
Ok(pathbuf
|
||||
.as_ref()
|
||||
.as_os_str()
|
||||
.to_str()
|
||||
.ok_or_else(|| InvalidPath(pathbuf.as_ref().to_path_buf()))
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ pub fn meta(uri: &str) -> (String, String, String) {
|
|||
} else {
|
||||
// Users can pass name starting wirh a slash
|
||||
let first_char = uri.chars().next();
|
||||
|
||||
|
||||
if first_char == Some('/') {
|
||||
format!("https://github.com{uri}")
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
format!("https://github.com/{uri}")
|
||||
}
|
||||
}
|
||||
|
|
@ -70,7 +69,7 @@ mod tests {
|
|||
assert_eq!(user, "user".to_string());
|
||||
assert_eq!(repo, "repo".to_string());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_meta_github_repo_name() {
|
||||
let (actual_uri, user, repo) = meta("user/repo");
|
||||
|
|
@ -78,7 +77,7 @@ mod tests {
|
|||
assert_eq!(user, "user".to_string());
|
||||
assert_eq!(repo, "repo".to_string());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_meta_github_repo_name_with_slash() {
|
||||
let (actual_uri, user, repo) = meta("/user/repo");
|
||||
|
|
@ -86,7 +85,7 @@ mod tests {
|
|||
assert_eq!(user, "user".to_string());
|
||||
assert_eq!(repo, "repo".to_string());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_meta_github_clean_link() {
|
||||
let (actual_uri, user, repo) = meta("github.com/user/repo");
|
||||
|
|
@ -94,7 +93,7 @@ mod tests {
|
|||
assert_eq!(user, "user".to_string());
|
||||
assert_eq!(repo, "repo".to_string());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_meta_random_git_provider_http() {
|
||||
let (actual_uri, user, repo) = meta("https://sr.ht/user/repo");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue