fix: NO_COLOR does not win over CLICOLOR_FORCE under --color=auto
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 internal/cli/colorflag.go 开始:文中所述的优先级位于第 101-103 行,rewriteEnviron 中的 NO_COLOR 重写位于第 115-135 行,第 155-168 行附近的处理逻辑也需要关注。修复方法是在 --color=auto 下且 NO_COLOR 非空时,在 colorprofile 读取之前从环境中删除 CLICOLOR_FORCE。使用 NO_COLOR=1 CLICOLOR_FORCE=1 codegraph version | cat -v 复现问题,然后为该输入添加一个测试,断言 ESC 字节数为零,该测试在当前代码上应当失败。
由索引模型根据 Issue 内容生成。
描述
What happens
$ NO_COLOR=1 CLICOLOR_FORCE=1 codegraph version | cat -v
^[[1;38;2;95;215;255mcodegraph dev^[[m ^[[2;38;2;147;161;161m(commit unknown, built unknown)^[[m ...
Under --color=auto, rewriteEnviron rewrites NO_COLOR to NO_COLOR=1 but passes CLICOLOR_FORCE through unchanged, and colorprofile lets CLICOLOR_FORCE win.
What you expected instead
No escape bytes. The code's stated order is NO_COLOR > CLICOLOR_FORCE > CLICOLOR=0 > TTY.
Steps to reproduce
Run the command above with any build of main.
Version
main at d384473e (built locally, codegraph dev)
Platform
macOS 27 arm64
How did you install it?
Built from source
Evidence
internal/cli/colorflag.go:101-103(stated order),:115-135(NO_COLOR rewritten, CLICOLOR_FORCE kept),:155-168
Acceptance criteria
- With a non-empty
NO_COLOR,--color=autodropsCLICOLOR_FORCEbefore colorprofile sees it. - A test covering
NO_COLOR=1 CLICOLOR_FORCE=1asserts zero ESC bytes, and fails on the current code.
Source (GSD planning files, archived at d384473e): .planning/milestones/v0.14.0-MILESTONE-AUDIT.md (T-04-30)
🤖 Generated with Claude Code
- 主要语言
- Go
- 星标
- 0
- 派生
- 0
- 平均合并
- 5 小时 16 分钟
- 30 天内合并 PR
- 107
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
seanb4t/codegraph-go 的其他 Issue
-
area:indexer bug needs-triage
难度 2/5 1-3 小时 新手友好度 82/100
seanb4t/codegraph-go#385 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
seanb4t/codegraph-go#380 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 2/5 1-3 小时 新手友好度 82/100
seanb4t/codegraph-go#379 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 1/5 1-3 小时 新手友好度 84/100
seanb4t/codegraph-go#362 ·
维护者通常 1 天内回复
-
area:query bug priority:low spec-needed
难度 2/5 1-3 小时 新手友好度 80/100
seanb4t/codegraph-go#355 ·
维护者通常 1 天内回复
查看 seanb4t/codegraph-go 的全部 Issue
相似的 Issue
-
enhancement exporter/awskinesis needs triage
难度 2/5 1-3 小时 新手友好度 70/100
open-telemetry/opentelemetry-collector-contrib#53334 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
erigontech/erigon#26523 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
SocialGouv/iterion#3376 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
seaweedfs/seaweedfs#12740 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复