-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/release token #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…1 22:56:12\n\n* chore: quick update feat/manager at 2026-01-21 23:01:56
Summary of ChangesHello @kooksee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces significant new functionality to the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces significant new features to the protobuild tool, including init and doctor commands for project initialization and environment diagnostics, and a web command that launches a web-based UI for visual configuration editing, dependency management, plugin configuration, and proto file browsing. The changes involve adding new Go files for these commands and their web server implementation, updating README.md and README_CN.md to document these new features and a project roadmap, and refactoring internal configuration types into a new internal/config package. Additionally, the protoc-gen-retag plugin's options handling is adjusted, and the project version is updated to v0.1.1. Review comments suggest improving the escapeJSON function in the web UI by using json.Marshal for robustness, optimizing the runDoctor command to avoid redundant checks by caching results, and considering caching or asynchronous processing for handleProjectStats to enhance performance for large projects.
| func escapeJSON(s string) string { | ||
| s = strings.ReplaceAll(s, "\\", "\\\\") | ||
| s = strings.ReplaceAll(s, "\"", "\\\"") | ||
| s = strings.ReplaceAll(s, "\n", "\\n") | ||
| s = strings.ReplaceAll(s, "\r", "\\r") | ||
| s = strings.ReplaceAll(s, "\t", "\\t") | ||
| return s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
escapeJSON 函数手动实现了对 JSON 字符串的转义,这可能无法覆盖所有边界情况,容易出错。建议使用标准库 encoding/json 中的 json.Marshal 来进行更安全、更健壮的 JSON 序列化。
| func escapeJSON(s string) string { | |
| s = strings.ReplaceAll(s, "\\", "\\\\") | |
| s = strings.ReplaceAll(s, "\"", "\\\"") | |
| s = strings.ReplaceAll(s, "\n", "\\n") | |
| s = strings.ReplaceAll(s, "\r", "\\r") | |
| s = strings.ReplaceAll(s, "\t", "\\t") | |
| return s | |
| func escapeJSON(s string) string { | |
| b, err := json.Marshal(s) | |
| if err != nil { | |
| // Fallback for safety, though Marshal on a string should not fail. | |
| return `"` + strings.ReplaceAll(s, `"`, `\"`) + `"` | |
| } | |
| return string(b) | |
| } |
| if len(issues) > 0 { | ||
| fmt.Printf("❌ 发现 %d 个问题需要修复:\n", len(issues)) | ||
| for _, item := range issues { | ||
| result := item.Check() | ||
| fmt.Printf(" • %s: %s\n", item.Name, result.Message) | ||
| if result.Help != "" { | ||
| fmt.Printf(" 💡 %s\n", result.Help) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if len(warnings) > 0 { | ||
| fmt.Printf("⚠️ 发现 %d 个可选组件未安装:\n", len(warnings)) | ||
| for _, item := range warnings { | ||
| result := item.Check() | ||
| fmt.Printf(" • %s: %s\n", item.Name, result.Message) | ||
| if result.Help != "" { | ||
| fmt.Printf(" 💡 %s\n", result.Help) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func (s *Server) handleProjectStats(w http.ResponseWriter, r *http.Request) { | ||
| s.mu.RLock() | ||
| cfg := s.config | ||
| s.mu.RUnlock() | ||
|
|
||
| stats := ProjectStats{ | ||
| ProtoRoots: cfg.Root, | ||
| VendorDir: cfg.Vendor, | ||
| DependencyCount: len(cfg.Depends), | ||
| PluginCount: len(cfg.Plugins), | ||
| } | ||
|
|
||
| baseDir := filepath.Dir(s.configPath) | ||
|
|
||
| // Count proto files in root directories | ||
| for _, root := range cfg.Root { | ||
| rootPath := filepath.Join(baseDir, root) | ||
| filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error { | ||
| if err != nil { | ||
| return nil | ||
| } | ||
| if !info.IsDir() && strings.HasSuffix(path, ".proto") { | ||
| stats.ProtoFiles++ | ||
|
|
||
| // Count lines, messages, and services | ||
| content, err := os.ReadFile(path) | ||
| if err == nil { | ||
| lines := strings.Split(string(content), "\n") | ||
| stats.TotalLines += len(lines) | ||
|
|
||
| for _, line := range lines { | ||
| trimmed := strings.TrimSpace(line) | ||
| if strings.HasPrefix(trimmed, "message ") { | ||
| stats.MessageCount++ | ||
| } else if strings.HasPrefix(trimmed, "service ") { | ||
| stats.ServiceCount++ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return nil | ||
| }) | ||
| } | ||
|
|
||
| // Count vendor files | ||
| if cfg.Vendor != "" { | ||
| vendorPath := filepath.Join(baseDir, cfg.Vendor) | ||
| filepath.Walk(vendorPath, func(path string, info fs.FileInfo, err error) error { | ||
| if err != nil { | ||
| return nil | ||
| } | ||
| if !info.IsDir() && strings.HasSuffix(path, ".proto") { | ||
| stats.VendorFiles++ | ||
| } | ||
| return nil | ||
| }) | ||
| } | ||
|
|
||
| w.Header().Set("Content-Type", "application/json") | ||
| json.NewEncoder(w).Encode(stats) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.