feat(updater): 引入 24 小时静默更新检测与一键升级功能
- 新增 `updater` 模块实现 GitHub Release 版本异步检查与本地缓存 - 新增 `git air update` 与 `git air version` 命令支持一键升级及版本检查 - 优化 CLI 终端交互,在首页渲染时提供友好的新版本升级提示卡片
This commit is contained in:
1 parent
10cbfc39a5
commit
7632652b7b
9 files changed
+398
-64
No files matched your search
+14
-1
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/unclesam-ly/git-air/internal/llm"
|
||||
"github.com/unclesam-ly/git-air/internal/reviewer"
|
||||
"github.com/unclesam-ly/git-air/internal/ui"
|
||||
"github.com/unclesam-ly/git-air/internal/updater"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
@@ -21,6 +22,9 @@ var rootCmd = &cobra.Command{
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := cmd.Context()
|
||||
|
||||
// 后台非阻塞异步检查新版本
|
||||
updateCh := updater.CheckAsync()
|
||||
|
||||
// 1. 检查并获取 Diff
|
||||
if flagCached, _ := cmd.Flags().GetBool("cached"); flagCached {
|
||||
args = append([]string{"--cached"}, args...)
|
||||
@@ -96,7 +100,16 @@ var rootCmd = &cobra.Command{
|
||||
|
||||
ui.PrintFooter()
|
||||
|
||||
// 8. 门禁阻断检测 (Pre-commit 拦截逻辑)
|
||||
// 8. 检查新版本提醒(非阻塞)
|
||||
select {
|
||||
case info := <-updateCh:
|
||||
if info != nil {
|
||||
ui.PrintUpdateBanner(info.CurrentVersion, info.LatestVersion, info.ReleaseURL)
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
||||
// 9. 门禁阻断检测 (Pre-commit 拦截逻辑)
|
||||
outText := reviewOutput.String()
|
||||
hasBlocker := strings.Contains(outText, "[BLOCKER]") || strings.Contains(outText, "[CRITICAL]")
|
||||
hasReject := strings.Contains(outText, "[REJECT]")
|
||||
|
||||
Reference in new issue
Block a user