Repository navigation
fix(git): 用户取消或放过凭据询问后不再询问是否重试(#2231) - #142
Merged
Merged
Conversation
AskPass 会话记录本次 Git 进程是否有询问没得到回答(用户取消,或询问超过 180 秒过期)。认证失败后的重试循环看到这个标记就直接返回失败,不再弹出“是否在 Lithe 中重新输入”的询问:用户已经拒绝回答,再问一次只会重复同一个问题。回答了但认证仍被拒的情况照旧询问是否重试;助手自己退出、远程 Git 不算未回答。
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 22:52
This was referenced Nov 20, 2026
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.
关联 Issue
1lck/Lithe-IDEA#2231(远程开发完整设计)中 AskPass 的后续修正。桌面端接入 AskPass 的 Draft 是 1lck/Lithe-IDEA#2253,在那里的端到端测试中发现了本问题。
类型
改动说明
原来的问题
用户在 Git 第一次询问用户名时直接取消,助手失败、Git 以
could not read Username结束。execute_git_with_environment的重试循环只看 stderr 里的认证失败标记、是否是传输命令、请求是否允许询问,不知道这次失败是用户自己拒绝回答造成的,于是又弹出“Git 认证失败,是否在 Lithe 中重新输入?”。用户刚拒绝过,再问一次只是重复同一个问题。询问超过 180 秒没人回答时也一样:重试询问又会等 180 秒,最后报 “Git authentication retry expired”,而不是原本的认证失败。git-host(
authentication.rs)Session新增unanswered标记和Session::unanswered():本会话有询问没得到宿主的回答就置位,包括宿主用respond(id, None)取消,以及询问在等待回答阶段超过 180 秒过期。log-exempt: User cancellation不记录,过期仍记vcs.authentication.response_failed(wait_answer/TimedOut)。git(
process.rs)capture_git_attempt,返回GitAttempt { output, prompt_unanswered };capture_git_process签名不变,只取output,其他调用方和十几处GitProcessOutput字面量都不用改。远程 Git 不走本机的 AskPass 通道,prompt_unanswered恒为 false。attempt.prompt_unanswered为真时直接返回这次的失败,不再询问是否重试。回答了但仍被拒(比如密码错误)、或凭据助手给了错误凭据而没有任何询问时,照旧询问是否绕过凭据助手重试。attempt改名为round,避免和新的GitAttempt混淆;事件里的attempt字段值不变(round + 2)。文档
rust/contracts/rust-core-api.md的git.authRespond:写明取消(null)后 Core 直接返回认证失败、不询问重试,过期同样如此;所以宿主在用户关闭对话框时不必再取消整个操作;retry: true的事件只出现在没有询问被取消或过期的失败之后。原文 “Hosts also cancel its owning operation when the user cancels the dialog” 删除:Go 桌面端(#2253)只回答 null,不取消操作。本 PR 不改插件契约、能力版本或插件函数协议,不需要更新协议更新记录。
测试
authentication/tests.rs:回答送达后unanswered()为假;取消后为真(取消前为假);询问过期后为真;助手自己离开后为假。current_exe(),Rust 测试二进制没有早期助手模式入口,无法替 Git 回答。端到端用桌面端真实 Core + Git 的测试验证(见下)。验证
cargo fmt --all -- --checkcargo clippy -p lithe-git -p lithe-git-host --all-targets -- -D warningscargo test -p lithe-git -p lithe-git-hostcargo test -p lithe-platform-tests askpasscargo test -p lithe-core gitLITHE_CORE_RUST_DIR=<本分支> scripts/desktop/desktop-go.sh test ./internal/core -run TestGitAuthentication -v:对拒绝认证的 HTTP 远程 fetch,第一个问题就取消["user", "retry"]变为["user"],远程没收到任何凭据./internal/workbench -run 'TestCloneAsksForCredentialsInTheWindow|TestGitAuth':回答用户名和密码后被拒,仍询问是否重试,Esc 取消未能执行的检查: Windows 本地没有运行;改动不含平台分支,依靠 CI。
后续
合入后桌面端把
PINNED_CORE_REVISION升到本 PR 的合入 commit,并把TestGitAuthenticationCancelledQuestionSendsNothing收紧为询问序列必须恰好是["user"]。