Skip to content

Commit

Permalink
[ISSUE #241]Optimize the init command code (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm authored Oct 23, 2023
1 parent 80fce36 commit 9fb6a2c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions volo-cli/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 {
Expand Down

0 comments on commit 9fb6a2c

Please sign in to comment.