Skip to content

Commit f9e86a0

Browse files
committed
rustfmt
1 parent 444f3b2 commit f9e86a0

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

Diff for: src/error.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ error_chain! {
1010
}
1111
}
1212

13-
pub fn default_error_handler(error: &Error, output: &mut dyn Write) {
14-
writeln!(output, "{}: {}", "[onefetch error]".red(), error).ok();
13+
pub fn default_error_handler(e: &Error, output: &mut dyn Write) {
14+
writeln!(output, "{}: {}", "[onefetch error]".red(), e).ok();
15+
16+
for e in e.iter().skip(1) {
17+
writeln!(output, "caused by: {}", e).ok();
18+
}
1519
}

Diff for: src/info.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,11 @@ impl std::fmt::Display for Info {
376376
impl Info {
377377
#[tokio::main]
378378
pub async fn new(config: Options) -> Result<Info> {
379-
let repo = Repository::discover(&config.path).chain_err(||"Could not find a valid git repo on the current path")?;
380-
let workdir = repo.workdir().chain_err(||"Unable to run onefetch on bare git repo")?;
379+
let repo = Repository::discover(&config.path)
380+
.chain_err(|| "Could not find a valid git repo on the current path")?;
381+
let workdir = repo
382+
.workdir()
383+
.chain_err(|| "Unable to run onefetch on bare git repo")?;
381384
let workdir_str = workdir.to_str().unwrap();
382385
let (languages_stats, number_of_lines) =
383386
Language::get_language_stats(workdir_str, &config.excluded)?;
@@ -485,7 +488,9 @@ impl Info {
485488
}
486489

487490
async fn get_repo_name_and_url(repo: &Repository) -> (String, String) {
488-
let config = repo.config().chain_err(|| "Could not retrieve git configuration data");
491+
let config = repo
492+
.config()
493+
.chain_err(|| "Could not retrieve git configuration data");
489494
let mut remote_url = String::new();
490495
let mut repository_name = String::new();
491496

@@ -518,9 +523,15 @@ impl Info {
518523
}
519524

520525
async fn get_current_commit_info(repo: &Repository) -> Result<CommitInfo> {
521-
let head = repo.head().chain_err(|| "Error while retrieving reference information")?;
522-
let head_oid = head.target().ok_or("Error while retrieving reference information")?;
523-
let refs = repo.references().chain_err(|| "Error while retrieving reference information")?;
526+
let head = repo
527+
.head()
528+
.chain_err(|| "Error while retrieving reference information")?;
529+
let head_oid = head
530+
.target()
531+
.ok_or("Error while retrieving reference information")?;
532+
let refs = repo
533+
.references()
534+
.chain_err(|| "Error while retrieving reference information")?;
524535
let refs_info = refs
525536
.filter_map(|reference| match reference {
526537
Ok(reference) => match (reference.target(), reference.shorthand()) {

Diff for: src/language.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ impl Language {
184184
ignored_directories: &[String],
185185
) -> Result<(Vec<(Language, f64)>, usize)> {
186186
let tokei_langs = project_languages(&dir, ignored_directories);
187-
let languages_stat =
188-
Language::get_languages_stat(&tokei_langs).ok_or("ErrorKind::SourceCodeNotFound()")?;
187+
let languages_stat = Language::get_languages_stat(&tokei_langs)
188+
.ok_or("Could not find any source code in this directory")?;
189189
let mut stat_vec: Vec<(_, _)> = languages_stat.into_iter().collect();
190190
stat_vec.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap().reverse());
191191
let loc = get_total_loc(&tokei_langs);

0 commit comments

Comments
 (0)