fix: auto-match layout template tag to CLI version in kratos new - #3870
Open
waterWang wants to merge 3 commits into
Open
fix: auto-match layout template tag to CLI version in kratos new#3870waterWang wants to merge 3 commits into
waterWang wants to merge 3 commits into
Conversation
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.
Description
Fixes #3868
Bug 1: Template version doesn't match CLI version
When using
kratos new(e.g. v2.9.2 CLI), the command always clones themainbranch ofkratos-layout, which currently contains the v3 template. This causes a mismatch: a v2.x CLI generates a v3 project template.Fix: Inject the CLI version (
release) into theprojectpackage viaproject.CLIVersion. When no explicit-bflag is given and the default service layout is used, the layout tag is automatically matched to the CLI version (e.g. CLI v2.9.2 → tagv2.9.2).Bug 2:
-b v2.9.2(tag) fails on repeated runsWhen
-bis a tag,git clone -b <tag>checks out a detached HEAD. ThePull()method inrepo.gocallsgit symbolic-ref HEADwhich fails on detached HEAD, causingkratos newto fail on the second project creation.Fix: In
Pull(), whengit symbolic-ref HEADfails (detached HEAD), fall back togit fetch origin <ref>+git checkout <ref>instead of returning an error.