@@ -19,6 +19,7 @@ package update
1919import (
2020 "fmt"
2121 "net/http"
22+ "os"
2223 "os/exec"
2324 "strings"
2425
@@ -28,6 +29,9 @@ import (
2829
2930// Validate checks the input info provided for the update and populates the cliVersion
3031func (opts * Update ) Validate () error {
32+ if err := opts .validateEqualVersions (); err != nil {
33+ return fmt .Errorf ("failed to validate equal versions: %w" , err )
34+ }
3135 if err := opts .validateGitRepo (); err != nil {
3236 return fmt .Errorf ("failed to validate git repository: %w" , err )
3337 }
@@ -117,3 +121,23 @@ func validateReleaseAvailability(version string) error {
117121 resp .StatusCode , version )
118122 }
119123}
124+
125+ // validateEqualVersions checks if from-version and to-version are the same.
126+ // If they are equal, logs an appropriate message and exits successfully.
127+ func (opts * Update ) validateEqualVersions () error {
128+ if opts .FromVersion == opts .ToVersion {
129+ // Check if this is the latest version to provide appropriate message
130+ latestVersion , err := fetchLatestRelease ()
131+ if err != nil {
132+ return fmt .Errorf ("failed to fetch latest release for messaging: %w" , err )
133+ }
134+
135+ if opts .ToVersion == latestVersion {
136+ log .Infof ("Your project already uses the latest version (%s). No action taken." , opts .FromVersion )
137+ } else {
138+ log .Infof ("Your project already uses the specified version (%s). No action taken." , opts .FromVersion )
139+ }
140+ os .Exit (0 )
141+ }
142+ return nil
143+ }
0 commit comments