schubergphilis / knife-github

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

problem with version check when ' is used #14

Closed sbotman closed 10 years ago

sbotman commented 10 years ago

In the following function, the regex doesn't work if the version is between ' ' instead of " ". This will result in no version at all :(

      def get_cookbook_version()
          version = nil
          cpath = get_cookbook_path(@cookbook_name)
          File.foreach("#{cpath}/metadata.rb") do |line|
              if line =~ /version.*"(.*)"/i
# problem with -> version          '0.1.21'
                 version = $1
                 break
              end
          end
          if version.nil?
             Chef::Log.error("Cannot get the version for cookbook #{@cookbook_name}")
             exit 1
          end
          version
      end
sbotman commented 10 years ago

solved