[200_69] 修复 gfproject.json 合并逻辑,支持单命令回退#697
Conversation
Greptile SummaryThis PR refactors the Confidence Score: 5/5Safe to merge; all findings are P2 style and minor performance suggestions. The refactoring is well-structured: struct-based error handling is cleaner than the old in-place cleanup, the merge logic is correct, and the new test covers both the deep-merge and fallback scenarios. The three findings are all P2 — a redundant config load (performance/TOCTOU), a missing blank line, and a leading comment in the test file that violates the project style guide. None of these affect correctness. src/goldfish.hpp — redundant double-load of gfproject config (lines 5514–5516) and missing blank line between function definitions (line 4233). Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[repl_for_community_edition] --> B[load_gfproject_config\ngf_lib]
B --> C{command in\nmerged config?}
C -- yes --> D[goldfish_run_tool]
D --> E[resolve_gfproject_tool\nloads config AGAIN]
E --> F{has local\noverride AND\nlib tool?}
F -- yes --> G[goldfish_run_tool_with_config\nmerged_tool, allow_fallback=true]
G -- success --> Z[return 0]
G -- fail: -1 --> H[goldfish_run_tool_with_config\nlib_tool, allow_builtin_fallback]
H -- success --> Z
H -- fail: -1 --> I[fall through to\nhardcoded handlers]
F -- no --> J[goldfish_run_tool_with_config\nmerged_tool, allow_builtin_fallback]
J -- success --> Z
J -- fail: -1 --> I
C -- no --> I
I --> K{command?}
K -- help --> L[display_help]
K -- version --> M[display_version]
K -- eval/load/repl/run --> N[hardcoded handler]
|
| ;; 添加 tools/help 到 load path,以便导入 (liii goldhelp) | ||
| ;; 注意:假设运行测试时工作目录是项目根目录 | ||
| (set! *load-path* (cons "tools/help" *load-path*)) |
There was a problem hiding this comment.
Test file should start with
(import ...), not comments
Per the project convention in CLAUDE.md, test files must start directly with (import ...) (no license text, no leading comments). This file begins with two ;; comment lines and a (set! *load-path* ...) expression before the import block. The load-path setup is functionally necessary, but the leading comments should be removed to comply with the style rule.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| } | ||
| static string | ||
| find_tool_root_by_command (const char* gf_lib, const string& command) { |
There was a problem hiding this comment.
Missing blank line between function definitions
goldfish_run_tool closes on line 4233 and find_tool_root_by_command begins on the very next line with no blank line separator. All other adjacent function definitions in this file have at least one blank line between them.
| } | |
| static string | |
| find_tool_root_by_command (const char* gf_lib, const string& command) { | |
| } | |
| static string | |
| find_tool_root_by_command (const char* gf_lib, const string& command) { |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
No description provided.