From 3d8ee620875085ae7e8d7ef31f4f8e3738cfdca1 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 7 Feb 2022 18:49:59 +0300 Subject: style(rust): Format all Rust code with rustfmt Change-Id: Iab7e00cc26a4f9727d3ab98691ef379921a33052 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5240 Tested-by: BuildkiteCI Reviewed-by: kanepyork Reviewed-by: Profpatsch Reviewed-by: grfn Reviewed-by: tazjin --- users/Profpatsch/git-db/git-db.rs | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'users/Profpatsch/git-db/git-db.rs') diff --git a/users/Profpatsch/git-db/git-db.rs b/users/Profpatsch/git-db/git-db.rs index 5c6bb1f85646..c8019bf03661 100644 --- a/users/Profpatsch/git-db/git-db.rs +++ b/users/Profpatsch/git-db/git-db.rs @@ -2,7 +2,7 @@ extern crate git2; use std::os::unix::ffi::OsStrExt; use std::path::PathBuf; -const DEFAULT_BRANCH : &str = "refs/heads/main"; +const DEFAULT_BRANCH: &str = "refs/heads/main"; fn main() { let git_db_dir = std::env::var_os("GIT_DB_DIR").expect("set GIT_DB_DIR"); @@ -16,8 +16,12 @@ fn main() { .bare(true) .mkpath(true) .description("git-db database") - .initial_head(DEFAULT_BRANCH) - ).expect(&format!("unable to create or open bare git repo at {}", &git_db.display())); + .initial_head(DEFAULT_BRANCH), + ) + .expect(&format!( + "unable to create or open bare git repo at {}", + &git_db.display() + )); let mut index = repo.index().expect("cannot get the git index file"); eprintln!("{:#?}", index.version()); @@ -34,8 +38,9 @@ fn main() { let data = "hi, it’s me".as_bytes(); - index.add_frombuffer( - &git2::IndexEntry { + index + .add_frombuffer( + &git2::IndexEntry { mtime: now_git_time, ctime: now_git_time, // don’t make sense @@ -50,25 +55,26 @@ fn main() { flags_extended: 0, path: "hi.txt".as_bytes().to_owned(), }, - data - ).expect("could not add data to index"); + data, + ) + .expect("could not add data to index"); let oid = index.write_tree().expect("could not write index tree"); - let to_add_tree = repo.find_tree(oid) + let to_add_tree = repo + .find_tree(oid) .expect("we just created this tree, where did it go?"); let parent_commits = match repo.find_reference(DEFAULT_BRANCH) { - Ok(ref_) => vec![ - ref_ - .peel_to_commit() - .expect(&format!("reference {} does not point to a commit", DEFAULT_BRANCH)) - ], + Ok(ref_) => vec![ref_.peel_to_commit().expect(&format!( + "reference {} does not point to a commit", + DEFAULT_BRANCH + ))], Err(err) => match err.code() { // no commit exists yet git2::ErrorCode::NotFound => vec![], _ => panic!("could not read latest commit from {}", DEFAULT_BRANCH), - } + }, }; repo.commit( Some(DEFAULT_BRANCH), @@ -79,7 +85,6 @@ fn main() { I wonder if it supports extended commit descriptions?\n", &to_add_tree, &parent_commits.iter().collect::>()[..], - ).expect("could not commit the index we just wrote"); - - + ) + .expect("could not commit the index we just wrote"); } -- cgit 1.4.1