Ori.livneh has uploaded a new change for review.

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


Change subject: Nudge user to 'git pull' if lagging behind remote
......................................................................

Nudge user to 'git pull' if lagging behind remote

If MediaWiki-Vagrant is running from a clone of the git repository and if it
detects that it is lagging behind the remote master, it will emit a message
encouraging the user to update to the latest version via a 'git pull'. It will
also run 'git fetch', but no more than once a week. These behaviors fail
silently.

Change-Id: I4af087bb022aae84df3c687aba0f65de6f1c4bfb
---
M Vagrantfile
1 file changed, 14 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/62/72662/1

diff --git a/Vagrantfile b/Vagrantfile
index 1c9a391..33196bd 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
+windows = RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
+virtualbox_version = /[\d\.]+/.match(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 windows
 
         puppet.facter = {
-            'virtualbox_version' => get_virtualbox_version,
+            'virtualbox_version' => virtualbox_version,
             'forwarded_port' => FORWARDED_PORT,
         }
     end
@@ -113,6 +100,13 @@
 end
 
 begin
+    `git fetch origin` if Time.now - File.mtime('./.git/FETCH_HEAD') > 604800
+     n = %x[git rev-list HEAD...origin/master --count].to_i
+     puts "You are #{n} commits behind master. Please run 'git pull' to 
update." if n > 0
+rescue
+end
+
+begin
     require_relative 'Vagrantfile-extra'
 rescue LoadError
     # No local Vagrantfile overrides.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4af087bb022aae84df3c687aba0f65de6f1c4bfb
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