Skip to content

Commit

Permalink
os/linux.rb: wsl_version: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information
maxim-belkin and MikeMcQuaid committed Feb 27, 2023
1 parent c9b289f commit dda83d7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Library/Homebrew/os/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ def wsl?

sig { returns(Version) }
def wsl_version
Version::NULL unless wsl?
return Version::NULL unless wsl?
kernel = OS.kernel_version.to_s
return Version.new("2 (Microsoft Store)") if Version.new(T.must(kernel[/^([0-9.]*)-.*/,
1])) > Version.new("5.15")
return Version.new("2") if kernel.include?("-microsoft")
return Version.new("1") if kernel.include?("-Microsoft")

Version::NULL
if Version.new(T.must(kernel[/^([0-9.]*)-.*/, 1])) > Version.new("5.15")
Version.new("2 (Microsoft Store)")
elsif kernel.include?("-microsoft")
Version.new("2")
elsif kernel.include?("-Microsoft")
Version.new("1")
else
Version::NULL
end
end
end

Expand Down

0 comments on commit dda83d7

Please sign in to comment.