schubergphilis / knife-github

Chef knife plugin to interact with the github enterprise appliance
Other
2 stars 4 forks source link

Wrong results when bumping version major and minor. #19

Open sbotman opened 10 years ago

sbotman commented 10 years ago

Bumping version with -M -m will need some extra logic within this function.

      def choose_version(version)
          if version =~ /(\d+)\.(\d+)\.(\d+)/
             major = $1
             minor = $2
             patch = $3
             major = major.to_i + 1 if config[:major]
             minor = minor.to_i + 1 if config[:minor]
             patch = patch.to_i + 1 if config[:patch]
             version = "#{major}.#{minor}.#{patch}"
             Chef::Log.debug("New version is #{version}")
          else
             Chef::Log.error("Version is in a format I cannot auto auto-update")
             exit 1
          end
          version
      end

Example, my current version is: 1.3.5 Bumping patch with -p will result into: 1.3.6 (seems ok) Bumping minor with -m will result into: 1.4.5 (not ok, should be 1.4.0) Bumping major with -M will result into: 2.3.5 (not ok, should be 2.0.0)

sbpadmin commented 10 years ago

Ahh yes, you are right!!

Sent from my iPhone

On 1 nov. 2013, at 22:01, "Sander Botman" notifications@github.com<mailto:notifications@github.com> wrote:

Bumping version with -M -m will need some extra logic within this function.

  def choose_version(version)
      if version =~ /(\d+)\.(\d+)\.(\d+)/
         major = $1
         minor = $2
         patch = $3
         major = major.to_i + 1 if config[:major]
         minor = minor.to_i + 1 if config[:minor]
         patch = patch.to_i + 1 if config[:patch]
         version = "#{major}.#{minor}.#{patch}"
         Chef::Log.debug("New version is #{version}")
      else
         Chef::Log.error("Version is in a format I cannot auto auto-update")
         exit 1
      end
      version
  end

Example, my current version is: 1.3.5 Bumping patch with -p will result into: 1.3.6 (seems ok) Bumping minor with -m will result into: 1.4.5 (not ok, should be 1.4.0) Bumping major with -M will result into: 2.3.5 (not ok, should be 2.0.0)

— Reply to this email directly or view it on GitHubhttps://github.com/schubergphilis/knife-github/issues/19.