Skip to content
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
49 changes: 2 additions & 47 deletions src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use globset::GlobBuilder;
use indexmap::IndexMap;
use itertools::Itertools;
use petgraph::prelude::*;
use serde::de;
use serde_derive::{Deserialize, Serialize};
use std::borrow::Cow;
use std::cmp::Ordering;
Expand Down Expand Up @@ -125,10 +124,10 @@ pub struct Task {
pub timeout: Option<String>,

// normal type
#[serde(default, deserialize_with = "deserialize_run_entries")]
#[serde(default, deserialize_with = "deserialize_arr")]
pub run: Vec<RunEntry>,

#[serde(default, deserialize_with = "deserialize_run_entries")]
#[serde(default, deserialize_with = "deserialize_arr")]
pub run_windows: Vec<RunEntry>,
Comment on lines +127 to 131
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code references deserialize_arr function but this function is not visible in the current diff. Ensure that deserialize_arr provides the same deserialization behavior as the removed deserialize_run_entries function, particularly handling string, object, and array inputs for RunEntry types.

Copilot uses AI. Check for mistakes.

// command type
Expand Down Expand Up @@ -722,50 +721,6 @@ impl Default for Task {
}
}

pub fn deserialize_run_entries<'de, D>(
deserializer: D,
) -> std::result::Result<Vec<RunEntry>, D::Error>
where
D: de::Deserializer<'de>,
{
struct RunEntriesVisitor;
impl<'de> de::Visitor<'de> for RunEntriesVisitor {
type Value = Vec<RunEntry>;
fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
formatter.write_str("string | object | array of string/object")
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(vec![RunEntry::Script(v.to_string())])
}

fn visit_map<M>(self, map: M) -> std::result::Result<Self::Value, M::Error>
where
M: de::MapAccess<'de>,
{
let entry: RunEntry =
de::Deserialize::deserialize(de::value::MapAccessDeserializer::new(map))?;
Ok(vec![entry])
}

fn visit_seq<S>(self, mut seq: S) -> std::result::Result<Self::Value, S::Error>
where
S: de::SeqAccess<'de>,
{
let mut v = vec![];
while let Some(entry) = seq.next_element::<RunEntry>()? {
v.push(entry);
}
Ok(v)
}
}

deserializer.deserialize_any(RunEntriesVisitor)
}

impl Display for Task {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let cmd = self
Expand Down
Loading