Skip to content

Commit bfad179

Browse files
committed
normalizeVersion
1 parent 9c910e3 commit bfad179

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/gonyx/cmd/cherry-pick.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The --release flag can be specified multiple times to cherry-pick to multiple re
3939
},
4040
}
4141

42-
cmd.Flags().StringSliceVar(&opts.Releases, "release", []string{}, "Release version(s) to cherry-pick to (e.g., v1.0, v1.1). Can be specified multiple times.")
42+
cmd.Flags().StringSliceVar(&opts.Releases, "release", []string{}, "Release version(s) to cherry-pick to (e.g., 1.0, v1.1). 'v' prefix is optional. Can be specified multiple times.")
4343

4444
return cmd
4545
}
@@ -64,7 +64,10 @@ func runCherryPick(cmd *cobra.Command, args []string, opts *CherryPickOptions) {
6464
// Determine which releases to target
6565
var releases []string
6666
if len(opts.Releases) > 0 {
67-
releases = opts.Releases
67+
// Normalize versions to ensure they have 'v' prefix
68+
for _, rel := range opts.Releases {
69+
releases = append(releases, normalizeVersion(rel))
70+
}
6871
log.Infof("Using specified release versions: %v", releases)
6972
} else {
7073
// Find the nearest stable tag
@@ -159,6 +162,14 @@ func getCurrentBranch() (string, error) {
159162
return strings.TrimSpace(string(output)), nil
160163
}
161164

165+
// normalizeVersion ensures the version has a 'v' prefix
166+
func normalizeVersion(version string) string {
167+
if !strings.HasPrefix(version, "v") {
168+
return "v" + version
169+
}
170+
return version
171+
}
172+
162173
// findNearestStableTag finds the nearest tag matching v*.*.* pattern and returns major.minor
163174
func findNearestStableTag(commitSHA string) (string, error) {
164175
// Get tags that are ancestors of the commit, sorted by version

0 commit comments

Comments
 (0)