Skip to content

crates/minimal: make minimal update update sideloads as well - #172

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/checkers
Apr 28, 2026
Merged

twitchyliquid64 merged 1 commit into
mainfrom
tom/checkers

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Update command now refreshes git-based upstreams and any configured git dependencies.
    • Configuration file is rewritten when the upstream or any git dependency changes.
    • Per-dependency status messages show old→new ref updates (uses "" when no prior ref).

@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Update command now refreshes git-based upstream sideloads: it checks out each sideload's configured branch, compares the obtained commit ref to the existing locked_commit, records per-sideload new refs when changed, and updates minimal.toml (including per-sideload messages) if any upstream or sideload changed.

Changes

Cohort / File(s) Summary
Update command sideload refresh
crates/minimal/src/cmd_update.rs
Adds logic to checkout configured git branches for sideloads, detect ref differences against locked_commit, return Some(new_ref) only on change, extend write condition to include sideload changes, emit per-sideload "updated from … to …" messages, and update upstream.sideload[i].locked_commit in the TOML document.

Sequence Diagram

sequenceDiagram
    participant Cmd as Update Command
    participant Git as Git Repo
    participant Sideload as Sideload Config
    participant TOML as minimal.toml

    Cmd->>Sideload: enumerate configured sideloads
    loop per sideload
        Cmd->>Git: checkout sideload.branch
        Git-->>Cmd: commit_ref
        Cmd->>Sideload: compare commit_ref vs locked_commit
        alt ref differs
            Cmd->>Cmd: record new_ref (Some)
            Cmd->>Cmd: log "updated from X to Y"
        else no change or non-git
            Cmd->>Cmd: record None
        end
    end
    alt any upstream or sideload changed
        Cmd->>TOML: update upstream and upstream.sideload[i].locked_commit entries
        TOML-->>Cmd: file written
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • norrietaylor
  • bryan-minimal
  • msample

Poem

🐇 I hopped through branches, nibbling at each ref,

updated sideloads now sit snug and deft.
From to pinned, the commits align,
TOML hums softly — all refs in a line.
A rabbit’s small cheer for a tidy design.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: extending the minimal update command to also update sideloads in addition to its existing functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/checkers

Comment @coderabbitai help to get the list of available commands and usage tips.

@bryan-minimal bryan-minimal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@twitchyliquid64
twitchyliquid64 enabled auto-merge (rebase) April 28, 2026 22:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/minimal/src/cmd_update.rs (1)

42-66: Please add a regression test for mixed sideload updates.

This path now couples checkout results back to upstream.sideload[i] by index and only rewrites changed git sideloads. A focused test with mixed Git/Dir sideloads and changed/unchanged branches would make this much safer.

As per coding guidelines, **/*.rs: Frequently run cargo test -p <crate name> when iterating on code changes to spot compilation errors, issues, and test failures.

Also applies to: 95-110

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/minimal/src/cmd_update.rs` around lines 42 - 66, The current update
logic builds sideload_updates by index and only rewrites changed Git sideloads,
which can break when sideloads are mixed types; add a regression test in the
crate that constructs an mfile.upstream with mixed sideloads (use both
mfile::LinkConfig::Git and a Dir sideload), stub or simulate vcs.checkout_of to
return both a changed and an unchanged branch result, call the update path that
produces sideload_updates (the code that computes sideload_updates in
cmd_update.rs) and assert that only the Git sideload with a changed commit is
flagged/rewritten while the Dir and unchanged Git entries remain untouched;
reference the functions/types mfile.upstream.sideloads(), LinkConfig::Git,
checkout_of, and the sideload_updates outcome to locate and validate the
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/minimal/src/cmd_update.rs`:
- Around line 98-104: The println that builds the "Sideload {}:{} updated..."
message is using as_inline_table() to read locked_commit which fails for
array-of-tables entries; change the lookup to directly index the sideload entry
(doc["upstream"]["sideload"][i]["locked_commit"]) and call
as_str().unwrap_or("<unpinned>") (or equivalent safe as_str handling) so
locked_commit is read correctly for both inline-table and [[upstream.sideload]]
formats; update the expression in the println that currently references
as_inline_table() to use this direct indexing.

---

Nitpick comments:
In `@crates/minimal/src/cmd_update.rs`:
- Around line 42-66: The current update logic builds sideload_updates by index
and only rewrites changed Git sideloads, which can break when sideloads are
mixed types; add a regression test in the crate that constructs an
mfile.upstream with mixed sideloads (use both mfile::LinkConfig::Git and a Dir
sideload), stub or simulate vcs.checkout_of to return both a changed and an
unchanged branch result, call the update path that produces sideload_updates
(the code that computes sideload_updates in cmd_update.rs) and assert that only
the Git sideload with a changed commit is flagged/rewritten while the Dir and
unchanged Git entries remain untouched; reference the functions/types
mfile.upstream.sideloads(), LinkConfig::Git, checkout_of, and the
sideload_updates outcome to locate and validate the behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e6a71849-caa0-4c44-afdf-868d0420b6e2

📥 Commits

Reviewing files that changed from the base of the PR and between 7967845 and 39680dd.

📒 Files selected for processing (1)
  • crates/minimal/src/cmd_update.rs

Comment thread crates/minimal/src/cmd_update.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/minimal/src/cmd_update.rs`:
- Around line 95-109: The loop that updates sideload pins currently always
reads/writes doc["upstream"]["sideload"], which misses the canonical "sideloads"
key and can panic; update the code in the sideload_updates handling (the for (i,
rev) in sideload_updates loop and the place where
doc["upstream"]["sideload"][i]["locked_commit"] is set) to first choose the
correct node: let key = if doc["upstream"].get("sideloads").is_some() {
"sideloads" } else { "sideload" }; then use doc["upstream"][key][i] for
reads/prints and set the locked_commit on that selected node (and avoid direct
unwraps by using get()/and_then(|v| v.as_str()).unwrap_or("<unpinned>") as
already used).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b147af6-72c4-424a-aae1-f5dae5447b2c

📥 Commits

Reviewing files that changed from the base of the PR and between 39680dd and 30fd0a3.

📒 Files selected for processing (1)
  • crates/minimal/src/cmd_update.rs

Comment on lines +95 to +109
// Update sideloads
for (i, rev) in sideload_updates.into_iter().enumerate() {
if let Some(new_rev) = rev {
println!(
"Sideload {}:{} updated from {} to {}",
doc["upstream"]["sideload"][i]["repo"].as_str().unwrap(),
doc["upstream"]["sideload"][i]["branch"].as_str().unwrap(),
doc["upstream"]["sideload"][i]
.get("locked_commit")
.and_then(|s| s.as_str())
.unwrap_or("<unpinned>"),
new_rev
);

doc["upstream"]["sideload"][i]["locked_commit"] = value(new_rev.clone());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Honor both sideloads and legacy sideload keys when writing sideload pins.

mfile::Upstream accepts both TOML spellings, but Lines 100-109 always read and mutate doc["upstream"]["sideload"]. If a minimal.toml uses the canonical sideloads key, this block will update the wrong node and can panic on the unwrap()s even though the sideload was parsed successfully.

Suggested change
+        let sideload_key = if doc["upstream"].get("sideloads").is_some() {
+            "sideloads"
+        } else {
+            "sideload"
+        };
+
         // Update sideloads
         for (i, rev) in sideload_updates.into_iter().enumerate() {
             if let Some(new_rev) = rev {
                 println!(
                     "Sideload {}:{} updated from {} to {}",
-                    doc["upstream"]["sideload"][i]["repo"].as_str().unwrap(),
-                    doc["upstream"]["sideload"][i]["branch"].as_str().unwrap(),
-                    doc["upstream"]["sideload"][i]
+                    doc["upstream"][sideload_key][i]["repo"].as_str().unwrap(),
+                    doc["upstream"][sideload_key][i]["branch"].as_str().unwrap(),
+                    doc["upstream"][sideload_key][i]
                         .get("locked_commit")
                         .and_then(|s| s.as_str())
                         .unwrap_or("<unpinned>"),
                     new_rev
                 );
 
-                doc["upstream"]["sideload"][i]["locked_commit"] = value(new_rev.clone());
+                doc["upstream"][sideload_key][i]["locked_commit"] = value(new_rev.clone());
             }
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Update sideloads
for (i, rev) in sideload_updates.into_iter().enumerate() {
if let Some(new_rev) = rev {
println!(
"Sideload {}:{} updated from {} to {}",
doc["upstream"]["sideload"][i]["repo"].as_str().unwrap(),
doc["upstream"]["sideload"][i]["branch"].as_str().unwrap(),
doc["upstream"]["sideload"][i]
.get("locked_commit")
.and_then(|s| s.as_str())
.unwrap_or("<unpinned>"),
new_rev
);
doc["upstream"]["sideload"][i]["locked_commit"] = value(new_rev.clone());
let sideload_key = if doc["upstream"].get("sideloads").is_some() {
"sideloads"
} else {
"sideload"
};
// Update sideloads
for (i, rev) in sideload_updates.into_iter().enumerate() {
if let Some(new_rev) = rev {
println!(
"Sideload {}:{} updated from {} to {}",
doc["upstream"][sideload_key][i]["repo"].as_str().unwrap(),
doc["upstream"][sideload_key][i]["branch"].as_str().unwrap(),
doc["upstream"][sideload_key][i]
.get("locked_commit")
.and_then(|s| s.as_str())
.unwrap_or("<unpinned>"),
new_rev
);
doc["upstream"][sideload_key][i]["locked_commit"] = value(new_rev.clone());
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/minimal/src/cmd_update.rs` around lines 95 - 109, The loop that
updates sideload pins currently always reads/writes doc["upstream"]["sideload"],
which misses the canonical "sideloads" key and can panic; update the code in the
sideload_updates handling (the for (i, rev) in sideload_updates loop and the
place where doc["upstream"]["sideload"][i]["locked_commit"] is set) to first
choose the correct node: let key = if doc["upstream"].get("sideloads").is_some()
{ "sideloads" } else { "sideload" }; then use doc["upstream"][key][i] for
reads/prints and set the locked_commit on that selected node (and avoid direct
unwraps by using get()/and_then(|v| v.as_str()).unwrap_or("<unpinned>") as
already used).

@twitchyliquid64
twitchyliquid64 merged commit 173cd1d into main Apr 28, 2026
7 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/checkers branch April 28, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants