jenkins-bot has submitted this change and it was merged.
Change subject: Shorter Windows and VirtualBox version detection
......................................................................
Shorter Windows and VirtualBox version detection
Ordinarily I'd hide these by moving them into a separate method, but
the way Vagrantfiles are executed makes that hard. I'd rather the reader's
attention flow past these helper methods to the configuration options, so I
used dirty Ruby tricks to make them more concise.
Change-Id: I4af087bb022aae84df3c687aba0f65de6f1c4bfb
---
M Vagrantfile
1 file changed, 7 insertions(+), 20 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Vagrantfile b/Vagrantfile
index 1c9a391..dabb889 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -22,25 +22,12 @@
#
require 'rbconfig'
-# Check if we're running on Windows.
-def windows?
- RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
-end
-# Get VirtualBox's version string by capturing the output of 'VBoxManage -v'.
-# Returns empty string if unable to determine version.
-def get_virtualbox_version
- begin
- if windows?
- ver = `"%ProgramFiles%\\Oracle\\VirtualBox\\VBoxManage" -v 2>NUL`
- else
- ver = `VBoxManage -v 2>/dev/null`
- end
- rescue
- ver = ''
- end
- /[\d\.]+/.match(ver).to_s
-end
+is_windows = RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
+virtualbox_version = /[\d\.]+/.match(is_windows ?
+ `"%ProgramFiles%\\Oracle\\VirtualBox\\VBoxManage" -v 2>NUL` :
+ `VBoxManage -v 2>/dev/null`).to_s rescue nil
+
Vagrant.configure('2') do |config|
@@ -102,10 +89,10 @@
# puppet.options << '--debug'
# Windows's Command Prompt has poor support for ANSI escape sequences.
- puppet.options << '--color=false' if windows?
+ puppet.options << '--color=false' if is_windows
puppet.facter = {
- 'virtualbox_version' => get_virtualbox_version,
+ 'virtualbox_version' => virtualbox_version,
'forwarded_port' => FORWARDED_PORT,
}
end
--
To view, visit https://gerrit.wikimedia.org/r/72662
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4af087bb022aae84df3c687aba0f65de6f1c4bfb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits