Skip to content

Commit 16e1637

Browse files
authored
Preserve dependencies order (#166)
When the same dependency exists multiple times in the dependency tree with slightly different attributes, we prefer the one closer to the root, but if they appear on the same level, the order matters (the first one wins). The PR makes protofetch process dependencies in the order they are defined in protofetch.toml, which should make resolution reproducible.
1 parent 90e515d commit 16e1637

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/model/protodep.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::model::{
77
};
88
use log::{debug, error};
99
use serde::{Deserialize, Serialize};
10-
use std::{collections::HashMap, path::Path, str::FromStr};
11-
use toml::Value;
10+
use std::{path::Path, str::FromStr};
11+
use toml::{map::Map, Value};
1212

1313
#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Default)]
1414
#[serde(default)]
@@ -46,7 +46,7 @@ impl ProtodepDescriptor {
4646
}
4747

4848
pub fn from_toml_str(data: &str) -> Result<ProtodepDescriptor, ParseError> {
49-
let mut toml_value = toml::from_str::<HashMap<String, Value>>(data)?;
49+
let mut toml_value = toml::from_str::<Map<String, Value>>(data)?;
5050

5151
let proto_out_dir = toml_value
5252
.remove("proto_outdir")

src/model/protofetch/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod resolved;
44
use regex_lite::Regex;
55
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
66
use std::{
7-
collections::HashMap,
87
fmt::{Debug, Display, Write},
98
path::{Path, PathBuf},
109
str::FromStr,
@@ -472,7 +471,7 @@ impl Descriptor {
472471
}
473472

474473
pub fn from_toml_str(data: &str) -> Result<Descriptor, ParseError> {
475-
let mut toml_value = toml::from_str::<HashMap<String, Value>>(data)?;
474+
let mut toml_value = toml::from_str::<Map<String, Value>>(data)?;
476475

477476
let name = toml_value
478477
.remove("name")

0 commit comments

Comments
 (0)