Add run command#44
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as "CLI Handler"
participant Repo as "Repository"
participant Git as "Git Ops"
participant Shell as "Shell Executor"
participant State as "Run State"
User->>CLI: kin run -c "command" [--continue-on-failure]
CLI->>Repo: open repository
Repo->>Git: resolve upstream/base and merge-base
Git->>Repo: derive stack branches and topologically sort
loop for each branch (base → tips)
Repo->>State: persist current index & original checkout
Repo->>Git: checkout <branch>
Git->>Shell: run sh -c "command"
Shell->>CLI: stream stdout/stderr
Shell->>State: report success/failure for branch
alt failure & continue_on_failure == false
State->>Git: checkout original branch
Git->>CLI: return error (stop)
end
end
State->>Git: restore original checkout
CLI->>User: print summary (succeeded/failed branches)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/run.rs`:
- Around line 28-34: The cleanup currently assumes original_branch
(current_branch_name) is always present and ignores non-zero exits from external
checkouts; fix by capturing both the current branch name (current_branch_name)
and the original commit id (head_id = head.peel_to_commit()?.id()) and, in the
checkout_original_branch logic (and any checkout code around the 153-161
region), attempt to restore by: if original branch name Some(s) run `git
checkout s` and check Command::status().success(), else run `git checkout
<head_id>` to restore detached HEAD; always inspect the Command::status() return
and propagate an Err when status.success() is false so failed checkouts are not
silently ignored.
- Around line 21-23: The run function currently opens the repo and then checks
out/mutates branches without persisting resumable state; before any branch
checkout or mutation in run (and in the branch-processing block spanning the
section handling branch iteration), construct a RunState (or similar struct)
capturing the list of target branches, current index, args (RunArgs) and write
it to durable storage (e.g. via a new persist_run_state(repo, &run_state)
helper) so that interruption allows kin continue/abort; update the persisted
state after each successful branch completion (increment current index and
persist) and remove/mark finished on successful overall completion, and ensure
error paths call a persist_failure/mark_aborted helper so state reflects partial
progress for continue/abort handlers.
In `@src/main.rs`:
- Around line 67-68: Add integration tests for the new Run(RunArgs) subcommand:
create tests in the tests/ directory (e.g., tests/integration_run.rs) that
exercise the happy path (successful traversal of branches), the
--continue-on-failure behavior (ensure subsequent branches are processed when a
branch fails), and restoration of the original checkout after a failure (verify
the working branch is the same as before invoking kin run). Locate the
Run(RunArgs) handler in the CLI entry points and invoke the binary via the test
harness (or helper functions used by other integration tests) to mimic real git
repositories, asserting branch states and repository contents before and after
runs; include setup/teardown to create multi-branch repos and simulate a failure
on one branch to validate cleanup and continuation behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 27b71b79-92d0-48a4-93ce-e58b0cc3e7c1
📒 Files selected for processing (5)
README.mddocs/cli_reference.mdsrc/commands/mod.rssrc/commands/run.rssrc/main.rs
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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 `@tests/integration_run.rs`:
- Around line 1-131: Add integration tests that exercise the run-state lifecycle
by creating new #[test] functions (e.g., run_status_after_failed_run,
run_abort_restores_state, run_continue_resumes_run) that reuse setup_run_repo(),
kin_cmd(), run_ok(), read_lines(), and current_branch() to: 1) invoke kin run
with a failing command that leaves .git/kindra_run_state.json, 2) call kin
status via kin_cmd() and assert its stdout reports the stored run state, 3) call
kin abort via kin_cmd() and assert the file .git/kindra_run_state.json is
removed and the original checkout (checked with current_branch() or git
rev-parse HEAD via git_stdout) is restored, and 4) optionally call kin continue
with --continue-on-failure semantics and assert remaining branches are processed
and state removed; ensure each test asserts expected exit status
(success/failure) and uses read_lines() to validate run.log where applicable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: db704d86-7e0d-4cd0-9df5-6e045c523d45
📒 Files selected for processing (9)
README.mddocs/cli_reference.mdsrc/commands/abort_cmd.rssrc/commands/continue_cmd.rssrc/commands/mod.rssrc/commands/run.rssrc/commands/status_cmd.rssrc/main.rstests/integration_run.rs
Stack
Summary by CodeRabbit
New Features
kin runto execute a shell command across stack branches in topological order with a--continue-on-failureoption and summary reporting.continue,abort, andstatusnow surface and control in-progress run operations (progress, resume, abort).Documentation
runcommand.Tests