feat(cli): mcc --version command 보완 - #80
Merged
Merged
Conversation
./mcc --version has never worked - Cobra only registers --version when the root command's Version field is set, and it wasn't, so the flag simply didn't exist (docs telling users to run it as a smoke test always failed with "unknown flag"). Pull the version from the VCS info Go embeds automatically for any build done inside a git checkout (default since Go 1.18, no ldflags or build script changes needed) - the short commit hash, plus "-dirty" if the working tree had uncommitted changes at build time. Falls back to "dev" when build info isn't available (e.g. go run).
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.
변경 내용
root command에
Version필드를 설정. 빌드 시스템에 ldflags 기반 버전 주입 패턴이 없어서(순수go build/make뿐), 별도 빌드 스크립트 변경 없이 Go 1.18+가 git 체크아웃 내부에서 빌드할 때 자동으로 심어주는 VCS 정보(runtime/debug.ReadBuildInfo())를 런타임에 읽어 사용 — 커밋 해시 12자리 + 워킹트리에 미커밋 변경이 있으면-dirty접미사. 빌드 정보를 못 읽는 환경(go run등)에서는"dev"로 폴백.