Repository navigation
feat(git): auto-fetch on an interval so behind counts detect remote updates - #1310
Open
Michael-py001 wants to merge 1 commit into
Open
Michael-py001 wants to merge 1 commit into
Michael-py001 wants to merge 1 commit into
Conversation
|
Thanks for the pull request! It doesn't follow CONTRIBUTING.md yet:
感谢提交!这个 PR 还不符合 CONTRIBUTING.md:
Without an accepted issue, it is closed after 7 days. Docs, translations and small fixes (a 7 天内仍没有被认可的 Issue,会自动关闭。文档、翻译和小修复(标题为 |
This branch has not been deployed
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.
关联
Fixes #1307
问题
远端有新提交时,BaoCode 的 behind 计数不更新,必须手动 Fetch 才知道有更新。根因是 behind 来自
git status --porcelain --branch读的本地 remote-tracking ref,而代码库没有任何自动 fetch;状态刷新只由文件监听触发,不会 fetch。改动
加入可配置的后台自动 fetch,沿用 VS Code
git.autofetch的思路:git.autofetchInterval(settings.json):两次后台 fetch 的间隔秒数,正整数生效,缺省/0 为关闭。通过followSettingsFiles的静态回调读取,设置变更时重新布防计时器。IdeGitRepository为每个仓库(工作区、worktree、子模块、SSH 远端仓库)各自布防一个周期计时器;仅当当前分支有 upstream 时才 fetch,避免无跟踪分支对每个 remote 做无用的git fetch --all。fetch 走已有的fetch(),串行排队并强制刷新状态,因此 behind 计数随之更新。dispose()取消计时器并移除监听。验证
dart analyze:3 个改动文件无问题。flutter test --no-pub test/ide/git/git_repository_test.dart:10/10 通过(含 2 个新测试)。flutter test --no-pub test/ide/git/:220 通过、3 失败;3 个失败均为未改动文件中的既有 Windows 平台问题(CRLF 行尾与\//路径分隔符),已单独复核:ask_ai_test.dart、git_blame_test.dart、git_service_test.dart。说明
按 CONTRIBUTING.md,大改动应先在 issue 讨论再提 PR。本 PR 对应 #1307,如有不同设计倾向(例如改成窗口聚焦时 fetch、或默认开启),我按 maintainer 意见调整。