From c8fe02160e11d946c68754803b27a6c7e70be0fb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 12 Jan 2024 23:00:34 -0800 Subject: [PATCH] wip --- src/main.rs | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5cb0c58..498f0a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -816,7 +816,7 @@ struct WriteCommitConfig{ write_scripts:bool, } -async fn write_commit(config:WriteCommitConfig,b:Result,tokio::task::JoinError>,repo:&git2::Repository)->AResult<()>{ +async fn write_commit(config:WriteCommitConfig,b:Result,tokio::task::JoinError>,repo:&gix::Repository)->AResult<()>{ let (asset_version,context)=b??; println!("writing files for version {}",asset_version.assetVersionNumber); @@ -847,12 +847,14 @@ async fn write_commit(config:WriteCommitConfig,b:Result{ - let commit=reference.peel_to_commit()?; + let commit=reference.peel_to_commit_in_place()?; //test tree against commit tree to see if there is any changes let commit_tree=commit.tree()?; - let diff=repo.diff_tree_to_tree(Some(&commit_tree),Some(&tree),None)?; + let diff=repo.diff_resource_cache(Some(&commit_tree),Some(&tree),None)?; if diff.deltas().count()==0{ println!("no changes"); return Ok(()); } - parents.push(commit); + parents.push(commit.id()); }, Err(e)=>println!("repo head error {:?}",e), }; - repo.commit( - Some("HEAD"),//update_ref - &sig,//author + repo.commit_as( &sig,//commiter - &format!("v{}", asset_version.assetVersionNumber),//message + &sig,//author + "HEAD", + &format!("v{}",asset_version.assetVersionNumber),//message &tree,//tree (basically files) - parents.iter().collect::>>().as_slice(),//parents + parents,//parents )?; //commit @@ -913,7 +915,14 @@ async fn decompile_history_into_git(config:DecompileHistoryConfig)->AResult<()>{ versions_path.push("versions.json"); let asset_list:Vec=serde_json::from_reader(std::fs::File::open(versions_path)?)?; - let repo=git2::Repository::init(config.output_folder.clone())?; + let repo=gix::discover(gix::create::into( + config.output_folder.as_path(), + gix::create::Kind::Bare, + gix::create::Options{ + destination_must_be_empty:true, + fs_capabilities:None + } + )?)?; //decompile all versions futures::stream::iter(asset_list.into_iter() @@ -962,7 +971,14 @@ async fn download_and_decompile_history_into_git(config:DownloadAndDecompileHist //poll paged list of all asset versions let asset_list=get_version_history(&client,&config.cookie.as_str(),config.asset_id).await?; - let repo=git2::Repository::init(config.output_folder.clone())?; + let repo=gix::discover(gix::create::into( + config.output_folder.as_path(), + gix::create::Kind::Bare, + gix::create::Options{ + destination_must_be_empty:true, + fs_capabilities:None + } + )?)?; //download all versions let asset_id_string=config.asset_id.to_string();