Skip to content

Commit c1472bf

Browse files
committed
feat(core): ignore missing snapTo dependencies by default
Closes #173
1 parent a5a997a commit c1472bf

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

src/context.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ impl Context {
8888
for instance in self.instances.iter() {
8989
match *instance.state.borrow() {
9090
InstanceState::Valid(_) => continue,
91+
InstanceState::Suspect(_) => {
92+
if self.config.rcfile.strict {
93+
std::process::exit(1);
94+
} else {
95+
continue;
96+
}
97+
}
9198
_ => std::process::exit(1),
9299
}
93100
}

src/effects/fix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub fn run(ctx: Context) -> Context {
6262
},
6363
InstanceState::Suspect(variant) => match variant {
6464
SuspectInstance::RefuseToBanLocal
65+
| SuspectInstance::DependsOnMissingSnapTarget
6566
| SuspectInstance::RefuseToPinLocal
6667
| SuspectInstance::RefuseToSnapLocal
6768
| SuspectInstance::InvalidLocalVersion => {

src/effects/ui.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ impl Ui<'_> {
168168
UnfixableInstance::SameRangeMismatch => {
169169
info!("{count} {icon} {name} {state_links}");
170170
}
171-
UnfixableInstance::DependsOnMissingSnapTarget => {
172-
info!("{count} {icon} {name} {state_links}");
173-
}
174171
}
175172
}
176173
InvalidInstance::Conflict(variant) => {
@@ -201,6 +198,9 @@ impl Ui<'_> {
201198
InstanceState::Suspect(variant) => {
202199
let icon = self.warn_icon();
203200
match variant {
201+
SuspectInstance::DependsOnMissingSnapTarget => {
202+
info!("{count} {icon} {name} {state_links}");
203+
}
204204
SuspectInstance::RefuseToBanLocal => {
205205
info!("{count} {icon} {name} {state_links}");
206206
}
@@ -332,9 +332,6 @@ impl Ui<'_> {
332332
UnfixableInstance::SameRangeMismatch => {
333333
info!(" {icon} {actual} {location} {state_link}");
334334
}
335-
UnfixableInstance::DependsOnMissingSnapTarget => {
336-
info!(" {icon} {actual} {location} {state_link}");
337-
}
338335
},
339336
InvalidInstance::Conflict(variant) => match variant {
340337
SemverGroupAndVersionConflict::MatchConflictsWithHighestOrLowestSemver => {
@@ -361,6 +358,9 @@ impl Ui<'_> {
361358
InstanceState::Suspect(variant) => {
362359
let icon = self.warn_icon();
363360
match variant {
361+
SuspectInstance::DependsOnMissingSnapTarget => {
362+
info!(" {icon} {actual} {location} {state_link}");
363+
}
364364
SuspectInstance::RefuseToBanLocal => {
365365
info!(" {icon} {actual} {location} {state_link}");
366366
}

src/instance_state.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ pub enum UnfixableInstance {
169169
/// - ? Instance has no semver group
170170
/// - ? We can't know what range the user wants and have to ask them
171171
SameRangeMismatch,
172-
/// - ✓ Instance is in a snapped to version group
173-
/// - ✘ An instance of the same dependency was not found in any of the snapped
174-
/// to packages
175-
/// - ✘ This is a misconfiguration resulting in this instance being orphaned
176-
DependsOnMissingSnapTarget,
177172
}
178173

179174
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
@@ -238,4 +233,9 @@ pub enum SuspectInstance {
238233
/// - ! Local Instance has no version property
239234
/// - ! Not an error on its own unless an instance of it mismatches
240235
InvalidLocalVersion,
236+
/// - ✓ Instance is in a snapped to version group
237+
/// - ✘ An instance of the same dependency was not found in any of the snapped
238+
/// to packages
239+
/// - ! This is a misconfiguration resulting in this instance being orphaned
240+
DependsOnMissingSnapTarget,
241241
}

src/visit_packages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub fn visit_packages(ctx: Context) -> Context {
381381
} else {
382382
debug!(" no target version was found");
383383
dependency.instances.borrow().iter().for_each(|instance| {
384-
instance.mark_unfixable(DependsOnMissingSnapTarget);
384+
instance.mark_suspect(DependsOnMissingSnapTarget);
385385
});
386386
}
387387
}

src/visit_packages_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ fn instance_cannot_find_a_snapped_to_version() {
24952495
overridden: None,
24962496
},
24972497
ExpectedInstance {
2498-
state: InstanceState::unfixable(DependsOnMissingSnapTarget),
2498+
state: InstanceState::suspect(DependsOnMissingSnapTarget),
24992499
dependency_name: "foo",
25002500
id: "foo in /dependencies of follower",
25012501
actual: "1.0.0",

0 commit comments

Comments
 (0)