Set up the flake repo directory.
This commit is contained in:
@@ -2,6 +2,10 @@ use crate::cli::parameters::BuildArgs;
|
||||
use crate::config::Config;
|
||||
use crate::config::TargetConfig;
|
||||
use crate::error::CustomError;
|
||||
use crate::fs_util::assert_directory;
|
||||
use crate::fs_util::is_git_repo;
|
||||
use crate::git_util::git_force_into_state;
|
||||
use crate::git_util::git_init_at_rev;
|
||||
|
||||
pub(crate) async fn run_build(args: BuildArgs) -> Result<(), CustomError> {
|
||||
println!("{:?}", args);
|
||||
@@ -18,12 +22,41 @@ pub(crate) async fn run_build(args: BuildArgs) -> Result<(), CustomError> {
|
||||
}
|
||||
};
|
||||
|
||||
prepare_flake_repo(target_config).await?;
|
||||
prepare_flake_repo(&config, target_config).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn prepare_flake_repo(target_config: &TargetConfig) -> Result<(), CustomError> {
|
||||
todo!()
|
||||
async fn prepare_flake_repo(
|
||||
config_root: &Config,
|
||||
target_config: &TargetConfig,
|
||||
) -> Result<(), CustomError> {
|
||||
let flake_directory = target_config.get_flake_directory(config_root)?;
|
||||
assert_directory!(
|
||||
&flake_directory,
|
||||
"Creating flake directory {}",
|
||||
(&flake_directory).to_string_lossy()
|
||||
);
|
||||
|
||||
if is_git_repo(&flake_directory).await? {
|
||||
// Clean up the existing clone
|
||||
git_force_into_state(
|
||||
&flake_directory,
|
||||
target_config.get_branch()?,
|
||||
"origin",
|
||||
target_config.get_repo()?,
|
||||
target_config.get_revision()?,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
git_init_at_rev(
|
||||
&flake_directory,
|
||||
target_config.get_branch()?,
|
||||
target_config.get_repo()?,
|
||||
target_config.get_revision()?,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user