From 118455aa81aec4cc608c4b172423191791f63cf7 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Tue, 23 Aug 2011 19:40:49 +0800 Subject: [PATCH] Check if site is up-to-date --- app/models/site.rb | 8 ++++++-- app/views/admin/sites/_update.html.erb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 77571470..8cc32eee 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -13,8 +13,6 @@ class Site field :school field :department - field :up_to_date, :type => Boolean - def generate_keys private_key = OpenSSL::PKey::RSA.generate(2048) self.public_key = private_key.public_key.to_s @@ -25,4 +23,10 @@ class Site !self.roaming_id.blank? end + def up_to_date? + p res = %x(git remote show origin) + res = res.split('rails_3_1 (')[1].gsub!(')','').strip rescue nil + res.eql?('local out of date') ? false : true + end + end diff --git a/app/views/admin/sites/_update.html.erb b/app/views/admin/sites/_update.html.erb index 09bb04f3..c96072ca 100644 --- a/app/views/admin/sites/_update.html.erb +++ b/app/views/admin/sites/_update.html.erb @@ -1,4 +1,4 @@ -<% if @site.up_to_date %> +<% if @site.up_to_date? %> <%= t('admin.up_to_date') %> <% else %> <%= link_to t(:update), site_update_path %>