Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #241]Optimize the init command code #242

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading