Skip to content

Commit fe8ff7b

Browse files
Vitus213Samuka007
authored andcommitted
fix(rootfs): merge old codes to reduce difference
v1正常跑 用cargo clippy --fix修了一下 Merge remote-tracking branch 'upstream/main' into fk_merge
1 parent 86b8090 commit fe8ff7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1129
-1285
lines changed

Cargo.lock

Lines changed: 492 additions & 352 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/test_base/src/dadk_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ impl TestContext for DadkConfigTestContext {
4242
// 设置workdir
4343
std::env::set_current_dir(&test_base_path).expect("Failed to setup test base path");
4444

45-
let r = DadkConfigTestContext { test_base_path };
45+
4646

47-
r
47+
DadkConfigTestContext { test_base_path }
4848
}
4949
}
5050

dadk-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dadk-config"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2021"
55
authors = [
66
"longjin <[email protected]>",

dadk-config/src/common/target_arch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl Display for TargetArch {
8383
TargetArch::X86_64 => write!(f, "x86_64"),
8484
TargetArch::RiscV64 => write!(f, "riscv64"),
8585
TargetArch::AArch64 => write!(f, "aarch64"),
86+
TargetArch::LoongArch64 => write!(f, "loongarch64"),
8687
}
8788
}
8889
}

dadk-config/src/common/task.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl BuildConfig {
6969
}
7070

7171
pub fn validate(&self) -> Result<()> {
72-
return Ok(());
72+
Ok(())
7373
}
7474

7575
pub fn trim(&mut self) {
@@ -101,7 +101,7 @@ impl InstallConfig {
101101
"InstallConfig: in_dragonos_path should be an Absolute path",
102102
));
103103
}
104-
return Ok(());
104+
Ok(())
105105
}
106106

107107
pub fn trim(&mut self) {}
@@ -121,7 +121,7 @@ impl CleanConfig {
121121
}
122122

123123
pub fn validate(&self) -> Result<()> {
124-
return Ok(());
124+
Ok(())
125125
}
126126

127127
pub fn trim(&mut self) {
@@ -153,7 +153,7 @@ impl Dependency {
153153
if self.version.is_empty() {
154154
return Err(Error::msg("version is empty"));
155155
}
156-
return Ok(());
156+
Ok(())
157157
}
158158

159159
pub fn trim(&mut self) {
@@ -162,7 +162,7 @@ impl Dependency {
162162
}
163163

164164
pub fn name_version(&self) -> String {
165-
return format!("{}-{}", self.name, self.version);
165+
format!("{}-{}", self.name, self.version)
166166
}
167167
}
168168

@@ -200,7 +200,7 @@ impl TaskEnv {
200200
if self.key.is_empty() {
201201
return Err(Error::msg("Env: key is empty"));
202202
}
203-
return Ok(());
203+
Ok(())
204204
}
205205
}
206206

dadk-config/src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ mod tests {
256256
temp_file.write_all(toml_content.as_bytes())?;
257257
let path = temp_file.path().to_path_buf();
258258
let manifest = DadkManifestFile::load(&path)?;
259-
assert_eq!(manifest.used_default, true);
259+
assert!(manifest.used_default);
260260
assert_eq!(
261261
manifest.metadata.rootfs_config,
262262
PathBuf::from("config/rootfs.toml")

dadk-config/src/rootfs/fstype.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ mod tests {
3333
#[test]
3434
fn test_deserialize_fat32_lowercase() {
3535
let r = deserialize_fs_type("fat32");
36-
assert_eq!(r.is_ok(), true);
36+
assert!(r.is_ok());
3737
let fs_type = r.unwrap();
3838
assert_eq!(fs_type, FsType::Fat32);
3939
}
4040

4141
#[test]
4242
fn test_deserialize_fat32_mixed_case() {
4343
let r = deserialize_fs_type("FAT32");
44-
assert_eq!(r.is_ok(), true);
44+
assert!(r.is_ok());
4545
let fs_type = r.unwrap();
4646
assert_eq!(fs_type, FsType::Fat32);
4747
}

dadk-config/src/utils.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ pub fn apply_kv_array(
9090

9191
key_strings.insert(key, arg.to_owned());
9292
continue;
93+
} else if single_value_keys.contains(&arg.as_str()) || multi_value_keys.contains(arg) {
94+
return Err(anyhow!("Invalid argument: {}", arg));
9395
} else {
94-
if single_value_keys.contains(&arg.as_str()) || multi_value_keys.contains(arg) {
95-
return Err(anyhow!("Invalid argument: {}", arg));
96-
} else {
97-
key_strings.insert(arg.to_owned(), arg.to_owned());
98-
}
96+
key_strings.insert(arg.to_owned(), arg.to_owned());
9997
}
10098
}
10199

dadk-config/tests/test_boot_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const BOOT_CONFIG_FILE_NAME: &str = "config/boot.toml";
1111
#[test]
1212
fn test_load_boot_config_template(ctx: &DadkConfigTestContext) {
1313
let boot_config_path = ctx.templates_dir().join(BOOT_CONFIG_FILE_NAME);
14-
assert_eq!(boot_config_path.exists(), true);
15-
assert_eq!(boot_config_path.is_file(), true);
14+
assert!(boot_config_path.exists());
15+
assert!(boot_config_path.is_file());
1616
let _manifest = BootConfigFile::load(&boot_config_path).expect("Failed to load boot config");
1717
// TODO 校验 manifest 中的字段是否齐全
1818
}

dadk-config/tests/test_dadk_manifest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const DADK_MANIFEST_FILE_NAME: &str = "dadk-manifest.toml";
1111
#[test]
1212
fn test_load_dadk_manifest_template(ctx: &DadkConfigTestContext) {
1313
let manifest_path = ctx.templates_dir().join(DADK_MANIFEST_FILE_NAME);
14-
assert_eq!(manifest_path.exists(), true);
15-
assert_eq!(manifest_path.is_file(), true);
14+
assert!(manifest_path.exists());
15+
assert!(manifest_path.is_file());
1616
let manifest = DadkManifestFile::load(&manifest_path).expect("Failed to load manifest");
1717
// 验证 dadk-manifest.toml 已经包含了所有字段
18-
assert_eq!(manifest.used_default, false);
18+
assert!(!manifest.used_default);
1919
}

0 commit comments

Comments
 (0)