From 62c9522bf6fff1abcba84c35c97fa409d6d37f11 Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Mon, 13 Feb 2017 19:53:27 +0000 Subject: [PATCH] Fix bug in get_go_version_from_build_dockerfile. Previously, the first line of the Dockerfile would have been selected, regardless of its value. What we want is to actually select the first line matching the regex, and then extract the group corresponding to the Go version out of it. --- vagrant-common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant-common.rb b/vagrant-common.rb index 1967052e..27cfb716 100644 --- a/vagrant-common.rb +++ b/vagrant-common.rb @@ -18,7 +18,7 @@ end def get_go_version_from_build_dockerfile() go_regexp = /FROM golang:(\S*).*?/ dockerfile_path = File.expand_path(File.join(File.dirname(__FILE__), 'build', 'Dockerfile')) - go_version = File.readlines(dockerfile_path).first { |line| line.match(go_regexp) }.match(go_regexp).captures.first + go_version = File.readlines(dockerfile_path).select { |line| line.match(go_regexp) }.first.match(go_regexp).captures.first if go_version.nil? raise ArgumentError.new("Failed to read Go version from Dockerfile.") end