feat(cli) - 修复 ensure ssh 过程中出现错误的 loading#298
Merged
Conversation
The create branch command imported the same utility symbols twice, which caused unnecessary clutter and could lead to confusion during maintenance.
- Removed the duplicated `use crate::util::{ensure_ssh_ready, safe_pull, PullOptions};` line.
- Kept a single import for those utilities and retained the import block for branch‑related helpers.
This change improves code readability and reduces the risk of accidental divergent imports in the future.
Why: - Push operations were scattered across many command modules, each handling SSH readiness and progress spinners separately. This caused code duplication, inconsistent error handling, and made future changes error‑prone. What: - Updated `util::sync::push::safe_push` to accept an `Option<String>` for the branch name, perform SSH readiness verification, execute the push with a unified spinner, and report success uniformly. - Added a spinner and success message inside `safe_push` so callers no longer need to wrap the call. - Adjusted all command callers (`branch::rename`, `commit`, `pr::create`, `pr::update`, `repo::push`) to use the new signature (`safe_push(Some(branch))` or `safe_push(None)`). - Fixed a bug in `branch::rename` where the wrong overload was called. - Cleaned up redundant imports and removed duplicated push calls. How: - Implemented `ensure_ssh_ready` check at the start of `safe_push`. - Determined the actual branch to push (provided or current) before invoking the spinner. - Wrapped the underlying `git_repo.push` call with `spinner!` to show progress. - Updated each command file to pass `Option<String>` and removed their own spinner handling. - Adjusted documentation comments to reflect new behavior. BREAKING CHANGE: `safe_push` signature changed from `fn safe_push(&str, bool)` to `fn safe_push(Option<String>, bool)`. Update any external usages accordingly. Closes #0
Add explicit SSH readiness checks before any git pull operation. Why: Users often encounter pull failures when the SSH key is not configured or the SSH agent is not running. By guaranteeing that SSH is ready, the commands become more robust in CI/CD and interactive environments. What: - Imported `ensure_ssh_ready` and added calls in `branch::create`, `pr::create::branch`, and `pr::merge` commands. - Wrapped pull calls with a spinner and used `PullOptions::no_stash` to avoid unintended stash side‑effects. - Cleaned up duplicate imports across the modified files. - Updated `util::sync::pull` to keep the spinner logic and preserve error handling. How: The new helper `ensure_ssh_ready()` validates SSH configuration (or prompts the user) and returns an error on failure. Each command now: 1. Calls `ensure_ssh_ready()` before pulling. 2. Shows a spinner while pulling the latest changes. 3. Executes `safe_pull(..., PullOptions::no_stash())` to fetch without stashing. This ensures consistent behavior across branch creation, PR creation, and PR merging workflows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Ready
Types of changes
Summary
在关键的分支和 PR 操作前验证 SSH 配置,避免因 SSH 错误导致的拉取失败。
Key Changes
ensure_ssh_ready调用PullOptions::no_stash()保持 stash 行为不变Changes
Features
Refactors
Others
Impact Analysis
Affected Modules
Risk Assessment
Overall risk: medium
Risk factors:
Mitigation:
--skip-ssh-check或类似的非交互式标志以在 CI 中绕过检查Testing Suggestions
--skip-ssh-check标志,确保流程不被阻塞Statistics
Review Info