add args for committer name and email

This commit is contained in:
Quaternions 2024-01-11 13:48:57 -08:00
parent 816461e9f4
commit e12c13a1dd

View File

@ -29,6 +29,11 @@ struct Cli{
#[arg(long)] #[arg(long)]
no_template:Option<bool>, no_template:Option<bool>,
#[arg(long)]
git_committer_name:Option<String>,
#[arg(long)]
git_committer_email:Option<String>,
#[arg(long)] #[arg(long)]
asset_id:Option<AssetID>, asset_id:Option<AssetID>,
@ -114,6 +119,8 @@ async fn main()->AResult<()>{
write_scripts:!cli.no_scripts.unwrap_or(false), write_scripts:!cli.no_scripts.unwrap_or(false),
}), }),
Commands::DecompileHistoryIntoGit=>decompile_history_into_git(DecompileHistoryConfig{ Commands::DecompileHistoryIntoGit=>decompile_history_into_git(DecompileHistoryConfig{
git_committer_name:cli.git_committer_name.unwrap(),
git_committer_email:cli.git_committer_email.unwrap(),
cookie:cookie.unwrap(), cookie:cookie.unwrap(),
asset_id:cli.asset_id.unwrap(), asset_id:cli.asset_id.unwrap(),
output_folder:cli.output.unwrap(), output_folder:cli.output.unwrap(),
@ -669,6 +676,8 @@ fn decompile(config:DecompileConfig)->AResult<()>{
} }
struct WriteCommitConfig{ struct WriteCommitConfig{
git_committer_name:String,
git_committer_email:String,
output_folder:std::path::PathBuf, output_folder:std::path::PathBuf,
write_template:bool, write_template:bool,
write_models:bool, write_models:bool,
@ -704,7 +713,7 @@ fn write_commit(config:WriteCommitConfig,b:AResult<(AssetVersion,DecompiledConte
let date=asset_version.created; let date=asset_version.created;
let sig=git2::Signature::new("roblox-git-history","git_history@strafes.net",&git2::Time::new(date.timestamp(),0)).unwrap(); let sig=git2::Signature::new(config.git_committer_name.as_str(),config.git_committer_email.as_str(),&git2::Time::new(date.timestamp(),0)).unwrap();
let tree_id={ let tree_id={
let mut tree_index = repo.index()?; let mut tree_index = repo.index()?;
tree_index.add_all([config.output_folder].iter(),git2::IndexAddOption::DEFAULT,None)?; tree_index.add_all([config.output_folder].iter(),git2::IndexAddOption::DEFAULT,None)?;
@ -738,6 +747,8 @@ fn write_commit(config:WriteCommitConfig,b:AResult<(AssetVersion,DecompiledConte
struct DecompileHistoryConfig{ struct DecompileHistoryConfig{
cookie:String, cookie:String,
asset_id:AssetID, asset_id:AssetID,
git_committer_name:String,
git_committer_email:String,
output_folder:std::path::PathBuf, output_folder:std::path::PathBuf,
write_template:bool, write_template:bool,
write_models:bool, write_models:bool,
@ -772,6 +783,8 @@ async fn decompile_history_into_git(config:DecompileHistoryConfig)->AResult<()>{
.buffered(CONCURRENT_REQUESTS) .buffered(CONCURRENT_REQUESTS)
.for_each(|b:AResult<_>|async{ .for_each(|b:AResult<_>|async{
match write_commit(WriteCommitConfig{ match write_commit(WriteCommitConfig{
git_committer_name:config.git_committer_name.clone(),
git_committer_email:config.git_committer_email.clone(),
output_folder:config.output_folder.clone(), output_folder:config.output_folder.clone(),
write_template:config.write_template, write_template:config.write_template,
write_models:config.write_models, write_models:config.write_models,