diff --git a/volo-cli/src/init.rs b/volo-cli/src/init.rs index 3451f70f..fb3cf2cb 100644 --- a/volo-cli/src/init.rs +++ b/volo-cli/src/init.rs @@ -183,24 +183,21 @@ impl CliCommand for Init { fn run(&self, cx: crate::context::Context) -> anyhow::Result<()> { volo_build::util::with_config(|config| { let mut lock = None; - - if self.git.is_some() { - let r#ref = self.r#ref.as_deref().unwrap_or("HEAD"); - let lock_value = get_repo_latest_commit_id(self.git.as_ref().unwrap(), r#ref)?; - let _ = lock.insert(lock_value); - } let mut idl = Idl::new(); idl.includes = self.includes.clone(); + + // Handling Git-Based Template Creation if let Some(git) = self.git.as_ref() { + let r#ref = self.r#ref.as_deref().unwrap_or("HEAD"); + let lock_value = get_repo_latest_commit_id(git, r#ref)?; + let _ = lock.insert(lock_value); idl.source = Source::Git(GitSource { repo: git.clone(), r#ref: None, lock, }); - idl.path = self.idl.clone(); - } else { - idl.path = self.idl.clone(); } + idl.path = self.idl.clone(); let mut entry = Entry { protocol: idl.protocol(), @@ -213,8 +210,7 @@ impl CliCommand for Init { self.copy_thrift_template(entry.clone())?; } - if self.git.as_ref().is_some() { - } else { + if self.git.as_ref().is_none() { // we will move volo.yml to volo-gen, so we need to add .. to includes and idl path let idl = entry.idls.get_mut(0).unwrap(); if let Some(includes) = &mut idl.includes {