Skip to content

Commit 4f9d2b3

Browse files
committed
Fix baseline tests for list_apps env resolution and digest fallback
1 parent fe27a62 commit 4f9d2b3

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/backends/distrobox/distrobox.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,9 +1265,10 @@ Categories=Utility;Network;";
12651265

12661266
let db = Distrobox::new(
12671267
NullCommandRunnerBuilder::new()
1268-
.cmd(&["printenv", "HOME"], "/home/me")
1269-
.cmd(&["printenv", "XDG_DATA_HOME"], "")
1270-
.cmd(&["printenv", "HOME"], "/home/me")
1268+
.cmd(
1269+
&["env", "-0"],
1270+
"HOME=/home/me\0XDG_DATA_HOME=/home/me/.local/share\0",
1271+
)
12711272
.cmd(
12721273
&["ls", "/home/me/.local/share/applications"],
12731274
"ubuntu-vim.desktop\n",
@@ -1319,9 +1320,10 @@ Categories=Utility;Security;";
13191320

13201321
let db = Distrobox::new(
13211322
NullCommandRunnerBuilder::new()
1322-
.cmd(&["printenv", "HOME"], "/home/me")
1323-
.cmd(&["printenv", "XDG_DATA_HOME"], "")
1324-
.cmd(&["printenv", "HOME"], "/home/me")
1323+
.cmd(
1324+
&["env", "-0"],
1325+
"HOME=/home/me\0XDG_DATA_HOME=/home/me/.local/share\0",
1326+
)
13251327
.cmd(
13261328
&["ls", "/home/me/.local/share/applications"],
13271329
"ubuntu-Proton Authenticator.desktop\n",

src/dialogs/create_distrobox_helpers.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,15 @@ pub fn derive_image_prefill(
164164
}
165165
}
166166

167-
// 2) collect numeric-version tags
167+
// 2) prefer digest-pinned candidates as provided by the source ordering
168+
for img in &matching {
169+
let (_repo, _tag_opt, digest_opt) = split_repo_tag_digest(img.as_str());
170+
if digest_opt.is_some() {
171+
return (filter, Some((*img).clone()));
172+
}
173+
}
174+
175+
// 3) collect numeric-version tags
168176
let mut semvers: Vec<(&String, Vec<u64>)> = Vec::new();
169177
for img in &matching {
170178
let (_repo, tag_opt, _digest) = split_repo_tag_digest(img.as_str());
@@ -193,7 +201,7 @@ pub fn derive_image_prefill(
193201
return (filter, Some(semvers[0].0.clone()));
194202
}
195203

196-
// 3) fallback: pick first non-edge matching
204+
// 4) fallback: pick first non-edge matching
197205
for img in &matching {
198206
let (_repo, tag_opt, _digest) = split_repo_tag_digest(img.as_str());
199207
if let Some(tag) = tag_opt {

0 commit comments

Comments
 (0)