Skip to content

Commit b7d0c45

Browse files
committed
clean the code
1 parent f7bfa70 commit b7d0c45

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/config/models/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod test;
2929
use anyhow::{bail, Context, Result};
3030
use schemars::JsonSchema;
3131
use serde::Deserialize;
32-
use source::{workspace, Source};
32+
use source::{workspace::WorkspaceConfig, Source};
3333
use std::path::{Path, PathBuf};
3434
use tracing::log;
3535

@@ -120,7 +120,7 @@ pub async fn load_workspace_config(
120120
) -> Result<Option<PathBuf>> {
121121
let cargo_toml = current_path.join("Cargo.toml");
122122
if cargo_toml.exists() {
123-
if let Ok(workspace) = workspace::workspace_from_manifest(&cargo_toml).await {
123+
if let Ok(workspace) = WorkspaceConfig::new(&cargo_toml).await {
124124
match workspace_name {
125125
Some(name) => {
126126
if let Some(workspace) = workspace.get_workspace_by_name(&name) {

src/config/models/source/workspace.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use anyhow::{Context, Result};
22
use cargo_metadata::{Metadata, MetadataCommand};
3+
use serde::{Deserialize, Serialize};
34
use std::path::Path;
45
use std::path::PathBuf;
56
use tokio::task::spawn_blocking;
67

7-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
8+
#[derive(Debug, Clone, Serialize, Deserialize)]
89
pub struct WorkspaceConfig {
910
pub metadata: Metadata,
1011
}
@@ -21,12 +22,12 @@ impl WorkspaceConfig {
2122
}
2223

2324
pub fn get_default_workspace(self) -> Option<PathBuf> {
24-
if let Some(default_members) = self.metadata.workspace_default_members.first() {
25+
if let Some(default_member) = self.metadata.workspace_default_members.first() {
2526
if let Some(found) = self
2627
.metadata
2728
.packages
2829
.into_iter()
29-
.find(|p| p.id == *default_members)
30+
.find(|p| p.id == *default_member)
3031
{
3132
return Some(found.manifest_path.clone().into());
3233
}
@@ -51,9 +52,3 @@ impl WorkspaceConfig {
5152
None
5253
}
5354
}
54-
55-
/// Load the trunk configuration from the cargo manifest
56-
pub async fn workspace_from_manifest(file: impl AsRef<Path>) -> anyhow::Result<WorkspaceConfig> {
57-
let workspace_config = WorkspaceConfig::new(file.as_ref()).await?;
58-
Ok(workspace_config)
59-
}

0 commit comments

Comments
 (0)