Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/76892


Change subject: Some small touch-ups to plug-in code
......................................................................

Some small touch-ups to plug-in code

- Use stdlib's 'pathname' to make file path manipulations slightly
  more concise.
- Add some missing comments.

Change-Id: I1da958ce7c5f528628ab3b706229b7de7f16ec62
---
M lib/mediawiki-vagrant/helpers.rb
1 file changed, 17 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/92/76892/1

diff --git a/lib/mediawiki-vagrant/helpers.rb b/lib/mediawiki-vagrant/helpers.rb
index 54b2845..b634643 100644
--- a/lib/mediawiki-vagrant/helpers.rb
+++ b/lib/mediawiki-vagrant/helpers.rb
@@ -2,15 +2,26 @@
 # Helper methods for MediaWiki-Vagrant
 #
 require 'rbconfig'
+require 'pathname'
 
+## Shortcuts
+
+$VP = Pathname.new($DIR)  # Vagrant path
+$IP = $VP + 'mediawiki'   # MediaWiki path
+$PP = $VP + 'puppet'      # Puppet path
+
+
+# Are we running on windows?
 def windows?
     RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw32|windows/i
 end
 
+# Get short SHA1 of installed MediaWiki-Vagrant, if available.
 def commit
-    File.read("#{$DIR}/.git/refs/heads/master")[0..7] rescue nil
+       $VP.join('.git/refs/heads/master').read[0..8] rescue nil
 end
 
+# Try to ascertain the version of VirtualBox installed on the host.
 def virtualbox_version
     cmd = windows? ?
         '"%ProgramFiles%\\Oracle\\VirtualBox\\VBoxManage" -v 2>NUL' :
@@ -20,9 +31,11 @@
 
 # If it has been a week or more since remote commits have been fetched,
 # run 'git fetch origin', unless the user disabled automatic fetching.
+# You can disable automatic fetching by creating an empty 'no-updates'
+# file in the root directory of your repository.
 def update
-    unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist? "#{$DIR}/no-update"
-        system('git fetch origin') if Time.now - 
File.mtime("#{$DIR}/.git/FETCH_HEAD") > 604800 rescue nil
+    unless ENV.has_key? 'MWV_NO_UPDATE' or File.exist?($VP + 'no-update')
+        system('git fetch origin') if Time.now - File.mtime($VP + 
'.git/FETCH_HEAD') > 604800 rescue nil
     end
 end
 
@@ -52,7 +65,7 @@
 end
 
 # Migrate the content of old 'Roles' / 'Roles.yaml' files
-[File.join($DIR, 'Roles'), File.join($DIR, 'Roles.yaml')].each do |roles_file|
+[$VP + 'Roles', $VP + 'Roles.yaml'].each do |roles_file|
        begin
                roles = IO.readlines(roles_file).map { |line|
                        /^[^#]*role::(\S+)/.match(line) and $1

-- 
To view, visit https://gerrit.wikimedia.org/r/76892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1da958ce7c5f528628ab3b706229b7de7f16ec62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to