Browse Source

[#2492] Prefixed real versions with ~ when guessing the latest version

2.1.0 > ~2.1.0
v2.1.0 -> ~2.1.0
dev-master -> dev-master
Ryan Weaver 11 years ago
parent
commit
26179cc4b4
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Composer/Command/InitCommand.php

+ 11 - 1
src/Composer/Command/InitCommand.php

@@ -349,7 +349,17 @@ EOT
                         ));
                     }
 
-                    $requirement['version'] = $package->getPrettyVersion();
+                    $version = $package->getPrettyVersion();
+                    if (!$package->isDev()) {
+                        // remove the v prefix if there is one
+                        if (substr($version, 0, 1) == 'v') {
+                            $version = substr($version, 1);
+                        }
+
+                        // 2.1.0 -> ~2.1.0, 2.0-beta.1 -> ~2.0-beta.1
+                        $version = '~'.$version;
+                    }
+                    $requirement['version'] = $version;
 
                     $output->writeln(sprintf(
                         'Using version <info>%s</info> for <info>%s</info>',