From b67d8037ef0d32208f16ee9dd6131e31f91689d0 Mon Sep 17 00:00:00 2001 From: he1pa <18012015693@163.com> Date: Wed, 11 Dec 2024 16:43:08 +0800 Subject: [PATCH 1/7] fix: fix lsp watcher. remove feature, wait for `kcl mod metadata` to read only Signed-off-by: he1pa <18012015693@163.com> --- .github/workflows/macos_test.yaml | 2 +- .github/workflows/ubuntu_test.yaml | 2 +- .github/workflows/windows_test.yaml | 2 +- kclvm/tools/src/LSP/src/state.rs | 19 ++++++++++++------- kclvm/tools/src/LSP/src/tests.rs | 3 ++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/macos_test.yaml b/.github/workflows/macos_test.yaml index 3be0f9236..96502779c 100644 --- a/.github/workflows/macos_test.yaml +++ b/.github/workflows/macos_test.yaml @@ -33,7 +33,7 @@ jobs: - name: Install KCL CLI run: | - go install kcl-lang.io/cli/cmd/kcl@c5ecdd12a97ca836a34744cd2f4d561eaae381ff + go install kcl-lang.io/cli/cmd/kcl@main echo "$(go env GOPATH)/bin" >> $GITHUB_PATH echo "${{ github.workspace }}/go/bin" >> $GITHUB_PATH diff --git a/.github/workflows/ubuntu_test.yaml b/.github/workflows/ubuntu_test.yaml index 90baece76..de8fbc61d 100644 --- a/.github/workflows/ubuntu_test.yaml +++ b/.github/workflows/ubuntu_test.yaml @@ -57,7 +57,7 @@ jobs: shell: bash - name: Install KCL CLI run: | - go install kcl-lang.io/cli/cmd/kcl@c5ecdd12a97ca836a34744cd2f4d561eaae381ff + go install kcl-lang.io/cli/cmd/kcl@main echo "$(go env GOPATH)/bin" >> $GITHUB_PATH echo "${{ github.workspace }}/go/bin" >> $GITHUB_PATH - name: Unit test diff --git a/.github/workflows/windows_test.yaml b/.github/workflows/windows_test.yaml index 2f8addeb5..b55178641 100644 --- a/.github/workflows/windows_test.yaml +++ b/.github/workflows/windows_test.yaml @@ -34,7 +34,7 @@ jobs: - name: Install KCL shell: powershell run: | - go install kcl-lang.io/cli/cmd/kcl@c5ecdd12a97ca836a34744cd2f4d561eaae381ff + go install kcl-lang.io/cli/cmd/kcl@main $GoPath = go env GOPATH $GoInstallBin = Join-Path $GoPath "bin" $Env:PATH += ";$GoInstallBin" diff --git a/kclvm/tools/src/LSP/src/state.rs b/kclvm/tools/src/LSP/src/state.rs index f94417079..d377b153b 100644 --- a/kclvm/tools/src/LSP/src/state.rs +++ b/kclvm/tools/src/LSP/src/state.rs @@ -193,13 +193,18 @@ impl LanguageServerState { for event in self.fs_event_watcher._receiver.try_iter() { if let Ok(e) = event { match e.kind { - notify::EventKind::Modify(_) => { - let paths = e.paths; - let kcl_config_file: Vec = filter_kcl_config_file(&paths); - if !kcl_config_file.is_empty() { - return Some(Event::FileWatcher(FileWatcherEvent::ChangedConfigFile( - kcl_config_file, - ))); + notify::EventKind::Modify(kind) => { + if let notify::event::ModifyKind::Data(data_change) = kind { + if let notify::event::DataChange::Content = data_change { + let paths = e.paths; + let kcl_config_file: Vec = filter_kcl_config_file(&paths); + if !kcl_config_file.is_empty() { + // TODO: wait for fix `kcl mod metadata` to read only. Otherwise it will lead to an infinite loop + // return Some(Event::FileWatcher( + // FileWatcherEvent::ChangedConfigFile(kcl_config_file), + // )); + } + } } } notify::EventKind::Remove(remove_kind) => { diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index d035748ef..8556e6bb3 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -1527,7 +1527,8 @@ fn complete_import_external_file_e2e_test() { } } -#[test] +// TODO: wait for fix `kcl mod metadata` to read only. Otherwise it will lead to an infinite loop +// #[test] fn mod_file_watcher_test() { let path = PathBuf::from(".") .join("src") From 3ab1ac8a18a8c29d09f252e9be5b45bb99a4418f Mon Sep 17 00:00:00 2001 From: he1pa <18012015693@163.com> Date: Fri, 13 Dec 2024 11:14:12 +0800 Subject: [PATCH 2/7] add arg `--update` for `kcl mod metadata` Signed-off-by: he1pa <18012015693@163.com> --- kclvm/driver/src/toolchain.rs | 1 + .../completion_test/import/external/external_1/kcl.mod | 1 - kclvm/tools/src/LSP/src/tests.rs | 3 ++- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kclvm/driver/src/toolchain.rs b/kclvm/driver/src/toolchain.rs index 95677f6bc..13774c6ed 100644 --- a/kclvm/driver/src/toolchain.rs +++ b/kclvm/driver/src/toolchain.rs @@ -59,6 +59,7 @@ impl + Send + Sync> Toolchain for CommandToolchain { match Command::new(&self.path) .arg("mod") .arg("metadata") + .arg("--update") .current_dir(manifest_path) .output() { diff --git a/kclvm/tools/src/LSP/src/test_data/completion_test/import/external/external_1/kcl.mod b/kclvm/tools/src/LSP/src/test_data/completion_test/import/external/external_1/kcl.mod index 8ea06569b..4ae72f07f 100644 --- a/kclvm/tools/src/LSP/src/test_data/completion_test/import/external/external_1/kcl.mod +++ b/kclvm/tools/src/LSP/src/test_data/completion_test/import/external/external_1/kcl.mod @@ -2,4 +2,3 @@ [dependencies] k8s = { oci = "oci://ghcr.io/kcl-lang/k8s", tag = "1.28" } - diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index 8556e6bb3..6143fb414 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -1486,7 +1486,7 @@ fn complete_import_external_file_e2e_test() { }, }, ); - wait_async!(2000); + wait_async!(5000); let id = server.next_request_id.get(); server.next_request_id.set(id.wrapping_add(1)); @@ -1528,6 +1528,7 @@ fn complete_import_external_file_e2e_test() { } // TODO: wait for fix `kcl mod metadata` to read only. Otherwise it will lead to an infinite loop +#[allow(dead_code)] // #[test] fn mod_file_watcher_test() { let path = PathBuf::from(".") From 3b920dd64d827850d26c8ba5d45100120397d01c Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 16 Dec 2024 15:17:47 +0800 Subject: [PATCH 3/7] fix: fix native mod metadata Signed-off-by: zongz --- kclvm/Cargo.lock | 259 +++++++++++++++++- kclvm/config/Cargo.toml | 1 + kclvm/config/src/modfile.rs | 24 ++ kclvm/driver/src/client/mod.rs | 2 +- .../driver/src/test_data/kpm_metadata/kcl.mod | 2 +- .../src/test_data/kpm_metadata/kcl.mod.lock | 10 +- .../main_pkg/kcl.mod.lock | 1 - .../flask-demo-kcl-manifests_ade147b | 1 + .../src/test_data/test_vendor/flask_ade147b | 1 + .../test_vendor/flask_manifests_ade147b | 1 + kclvm/driver/src/tests.rs | 31 ++- 11 files changed, 298 insertions(+), 35 deletions(-) create mode 160000 kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b create mode 160000 kclvm/driver/src/test_data/test_vendor/flask_ade147b create mode 160000 kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b diff --git a/kclvm/Cargo.lock b/kclvm/Cargo.lock index 91b611b1f..f2c9a0670 100644 --- a/kclvm/Cargo.lock +++ b/kclvm/Cargo.lock @@ -1444,6 +1444,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1452,12 +1570,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1912,6 +2041,7 @@ dependencies = [ "serde_json", "serde_yaml", "toml", + "url", ] [[package]] @@ -2008,7 +2138,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -2311,6 +2441,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "llvm-sys" version = "120.3.2" @@ -4042,6 +4178,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "tar" version = "0.4.41" @@ -4201,6 +4348,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ "displaydoc", + "zerovec", ] [[package]] @@ -4560,12 +4708,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-casing" version = "0.1.0" @@ -4625,9 +4767,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -4635,6 +4777,18 @@ dependencies = [ "serde", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -5111,6 +5265,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "xattr" version = "1.3.1" @@ -5146,8 +5312,75 @@ dependencies = [ "winapi", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "synstructure 0.13.1", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "synstructure 0.13.1", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] diff --git a/kclvm/config/Cargo.toml b/kclvm/config/Cargo.toml index c8344dda7..6e854242d 100644 --- a/kclvm/config/Cargo.toml +++ b/kclvm/config/Cargo.toml @@ -24,3 +24,4 @@ kclvm-ast = {path = "../ast"} dirs = "5.0.0" md-5 = "0.8.0" regex = "1.10.4" +url = "2.5.4" diff --git a/kclvm/config/src/modfile.rs b/kclvm/config/src/modfile.rs index fa54ebafc..61d7f6b9c 100644 --- a/kclvm/config/src/modfile.rs +++ b/kclvm/config/src/modfile.rs @@ -10,6 +10,7 @@ use std::{ path::{Path, PathBuf}, }; use toml; +use url::Url; use crate::path::ModRelativePath; @@ -114,6 +115,29 @@ pub struct LockDependency { pub path: Option, } +impl LockDependency { + pub fn gen_filename(&self) -> String { + if let Some(git_url) = &self.url { + if let Ok(parsed_url) = Url::parse(git_url) { + if let Some(last_segment) = parsed_url.path_segments().and_then(|segments| segments.last()) { + let trimmed_segment = last_segment.trim_end_matches(".git"); + return trimmed_segment.to_string(); + } + } + } + + if let Some(oci_repo) = &self.repo { + if let Ok(parsed_url) = Url::parse(oci_repo) { + if let Some(last_segment) = parsed_url.path_segments().and_then(|segments| segments.last()) { + return last_segment.to_string(); + } + } + } + + return self.name.replace('-', "_"); + } +} + #[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq)] pub struct GitSource { /// The URL of the Git repository. diff --git a/kclvm/driver/src/client/mod.rs b/kclvm/driver/src/client/mod.rs index 7e1dc17b6..037c1e504 100644 --- a/kclvm/driver/src/client/mod.rs +++ b/kclvm/driver/src/client/mod.rs @@ -265,7 +265,7 @@ impl ModClient { lock_dep.full_name.clone() } else if let Some(git_url) = &lock_dep.url { Some(self.get_local_path_from_dep( - &lock_dep.name, + &lock_dep.gen_filename(), &Dependency::Git(GitSource { git: git_url.to_string(), branch: lock_dep.branch.clone(), diff --git a/kclvm/driver/src/test_data/kpm_metadata/kcl.mod b/kclvm/driver/src/test_data/kpm_metadata/kcl.mod index c8325a3b6..58b2a49f8 100644 --- a/kclvm/driver/src/test_data/kpm_metadata/kcl.mod +++ b/kclvm/driver/src/test_data/kpm_metadata/kcl.mod @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.4" [dependencies] -kcl4 = { git = "test_url", tag = "v0.0.1" } +flask_manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b", version = "0.0.1" } diff --git a/kclvm/driver/src/test_data/kpm_metadata/kcl.mod.lock b/kclvm/driver/src/test_data/kpm_metadata/kcl.mod.lock index 409a419c6..4dc847701 100644 --- a/kclvm/driver/src/test_data/kpm_metadata/kcl.mod.lock +++ b/kclvm/driver/src/test_data/kpm_metadata/kcl.mod.lock @@ -1,7 +1,7 @@ [dependencies] - [dependencies.kcl4] - name = "kcl4" - full_name = "kcl4_0.0.1" + [dependencies.flask_manifests] + name = "flask_manifests" + full_name = "flask_manifests_0.0.1" version = "0.0.1" - url = "test_url" - git_tag = "v0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + commit = "ade147b" diff --git a/kclvm/driver/src/test_data/kpm_metadata_with_line/main_pkg/kcl.mod.lock b/kclvm/driver/src/test_data/kpm_metadata_with_line/main_pkg/kcl.mod.lock index 176cb7dec..8165e52f9 100644 --- a/kclvm/driver/src/test_data/kpm_metadata_with_line/main_pkg/kcl.mod.lock +++ b/kclvm/driver/src/test_data/kpm_metadata_with_line/main_pkg/kcl.mod.lock @@ -3,4 +3,3 @@ name = "dep-with-line" full_name = "dep-with-line_0.0.1" version = "0.0.1" - sum = "O2Z1djaB1lC38kNfhwUUYAlqGKE7seUqqys3DPcJfEw=" diff --git a/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b b/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b new file mode 160000 index 000000000..ade147b7f --- /dev/null +++ b/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b @@ -0,0 +1 @@ +Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a diff --git a/kclvm/driver/src/test_data/test_vendor/flask_ade147b b/kclvm/driver/src/test_data/test_vendor/flask_ade147b new file mode 160000 index 000000000..ade147b7f --- /dev/null +++ b/kclvm/driver/src/test_data/test_vendor/flask_ade147b @@ -0,0 +1 @@ +Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a diff --git a/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b b/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b new file mode 160000 index 000000000..ade147b7f --- /dev/null +++ b/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b @@ -0,0 +1 @@ +Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a diff --git a/kclvm/driver/src/tests.rs b/kclvm/driver/src/tests.rs index fb68bf670..3bfcde9ba 100644 --- a/kclvm/driver/src/tests.rs +++ b/kclvm/driver/src/tests.rs @@ -188,15 +188,15 @@ fn test_fill_pkg_maps_for_k_file() { let pkg_maps = opts.package_maps.clone(); assert_eq!(pkg_maps.len(), 1); - assert!(pkg_maps.get("kcl4").is_some()); + assert!(pkg_maps.get("flask_manifests").is_some()); assert_eq!( - PathBuf::from(pkg_maps.get("kcl4").unwrap().clone()) + PathBuf::from(pkg_maps.get("flask_manifests").unwrap().clone()) .canonicalize() .unwrap() .display() .to_string(), PathBuf::from(vendor_home) - .join("kcl4_v0.0.1") + .join("flask-demo-kcl-manifests_ade147b") .canonicalize() .unwrap() .display() @@ -273,19 +273,22 @@ fn test_tool_fetch_metadata(tool: impl Toolchain) { let metadata = tool.fetch_metadata(path.clone()); let pkgs = metadata.unwrap().packages.clone(); assert_eq!(pkgs.len(), 1); - assert!(pkgs.get("kcl4").is_some()); - assert_eq!(pkgs.get("kcl4").unwrap().name, "kcl4"); + assert!(pkgs.get("flask_manifests").is_some()); + assert_eq!(pkgs.get("flask_manifests").unwrap().name, "flask_manifests"); + + let manifest_path = pkgs.get("flask_manifests") + .unwrap() + .manifest_path + .clone(); + println!("Manifest path: {:?}", manifest_path); + + let canonicalized_manifest_path = manifest_path.canonicalize(); + println!("Canonicalized manifest path: {:?}", canonicalized_manifest_path); + assert_eq!( - pkgs.get("kcl4") - .unwrap() - .manifest_path - .clone() - .canonicalize() - .unwrap() - .display() - .to_string(), + canonicalized_manifest_path.unwrap().display().to_string(), PathBuf::from(vendor_home) - .join("kcl4_v0.0.1") + .join("flask-demo-kcl-manifests_ade147b") .canonicalize() .unwrap() .display() From 4492adce502d3b8714c63f121658cc184c5a4832 Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 16 Dec 2024 15:19:08 +0800 Subject: [PATCH 4/7] fix: make fmt Signed-off-by: zongz --- kclvm/config/src/modfile.rs | 10 ++++++++-- kclvm/driver/src/tests.rs | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/kclvm/config/src/modfile.rs b/kclvm/config/src/modfile.rs index 61d7f6b9c..3c5410d2b 100644 --- a/kclvm/config/src/modfile.rs +++ b/kclvm/config/src/modfile.rs @@ -119,7 +119,10 @@ impl LockDependency { pub fn gen_filename(&self) -> String { if let Some(git_url) = &self.url { if let Ok(parsed_url) = Url::parse(git_url) { - if let Some(last_segment) = parsed_url.path_segments().and_then(|segments| segments.last()) { + if let Some(last_segment) = parsed_url + .path_segments() + .and_then(|segments| segments.last()) + { let trimmed_segment = last_segment.trim_end_matches(".git"); return trimmed_segment.to_string(); } @@ -128,7 +131,10 @@ impl LockDependency { if let Some(oci_repo) = &self.repo { if let Ok(parsed_url) = Url::parse(oci_repo) { - if let Some(last_segment) = parsed_url.path_segments().and_then(|segments| segments.last()) { + if let Some(last_segment) = parsed_url + .path_segments() + .and_then(|segments| segments.last()) + { return last_segment.to_string(); } } diff --git a/kclvm/driver/src/tests.rs b/kclvm/driver/src/tests.rs index 3bfcde9ba..e98fddcf1 100644 --- a/kclvm/driver/src/tests.rs +++ b/kclvm/driver/src/tests.rs @@ -276,14 +276,14 @@ fn test_tool_fetch_metadata(tool: impl Toolchain) { assert!(pkgs.get("flask_manifests").is_some()); assert_eq!(pkgs.get("flask_manifests").unwrap().name, "flask_manifests"); - let manifest_path = pkgs.get("flask_manifests") - .unwrap() - .manifest_path - .clone(); + let manifest_path = pkgs.get("flask_manifests").unwrap().manifest_path.clone(); println!("Manifest path: {:?}", manifest_path); let canonicalized_manifest_path = manifest_path.canonicalize(); - println!("Canonicalized manifest path: {:?}", canonicalized_manifest_path); + println!( + "Canonicalized manifest path: {:?}", + canonicalized_manifest_path + ); assert_eq!( canonicalized_manifest_path.unwrap().display().to_string(), From e6992a6f5a6f06e000036ac2a2bb54bc1868c6d6 Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 16 Dec 2024 15:34:34 +0800 Subject: [PATCH 5/7] fix: rm git submodule Signed-off-by: zongz --- .../src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b | 1 - 1 file changed, 1 deletion(-) delete mode 160000 kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b diff --git a/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b b/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b deleted file mode 160000 index ade147b7f..000000000 --- a/kclvm/driver/src/test_data/test_vendor/flask-demo-kcl-manifests_ade147b +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a From 3576bbc32d0182b1b385b9c545a91aa370ecc29b Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 16 Dec 2024 15:36:41 +0800 Subject: [PATCH 6/7] fix: rm git submodule Signed-off-by: zongz --- kclvm/driver/src/test_data/test_vendor/flask_ade147b | 1 - 1 file changed, 1 deletion(-) delete mode 160000 kclvm/driver/src/test_data/test_vendor/flask_ade147b diff --git a/kclvm/driver/src/test_data/test_vendor/flask_ade147b b/kclvm/driver/src/test_data/test_vendor/flask_ade147b deleted file mode 160000 index ade147b7f..000000000 --- a/kclvm/driver/src/test_data/test_vendor/flask_ade147b +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a From c89f4dd39e3565d08c07cba4fa22787b8fb7d2a5 Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 16 Dec 2024 15:38:41 +0800 Subject: [PATCH 7/7] fix: rm git submodules Signed-off-by: zongz --- kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b | 1 - 1 file changed, 1 deletion(-) delete mode 160000 kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b diff --git a/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b b/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b deleted file mode 160000 index ade147b7f..000000000 --- a/kclvm/driver/src/test_data/test_vendor/flask_manifests_ade147b +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ade147b7fba59c29c64b0fdb540c6f0fa7cabd1a