Skip to content

Commit

Permalink
Merge pull request #569 from gauge-sh/fix-sync-multi-path-modules
Browse files Browse the repository at this point in the history
Fix multi-path modules adding duplicate dependencies in `tach sync`
  • Loading branch information
emdoyle authored Jan 25, 2025
2 parents 7697ef1 + 542533e commit c1d53f6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/config/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,26 @@ impl ConfigEditor for ProjectConfig {
toml_edit::Value::Array(array),
)) = table.get_mut("depends_on")
{
array.push(dependency);
// Check if dependency already exists
let exists = array.iter().any(|item| {
match item {
// Check for string match
toml_edit::Value::String(s) => {
s.value() == dependency
}
// Check for object with matching path
toml_edit::Value::InlineTable(t) => t
.get("path")
.and_then(|p| p.as_str())
.map(|p| p == dependency)
.unwrap_or(false),
_ => false,
}
});

if !exists {
array.push(dependency);
}
} else {
table.insert(
"depends_on",
Expand Down

0 comments on commit c1d53f6

Please sign in to comment.