Skip to content
Extraits de code Groupes Projets
Valider feb47df9 rédigé par MrZYX's avatar MrZYX
Parcourir les fichiers

total refactor of version header. X-Git-Update: ISO 8601 formated date of the...

total refactor of version header. X-Git-Update: ISO 8601 formated date of the last commit, X-Git-Revision: sha1 hash of the last commit
parent e02c3eaf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base ...@@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
before_filter :count_requests before_filter :count_requests
before_filter :set_invites before_filter :set_invites
before_filter :set_locale before_filter :set_locale
before_filter :set_git_header
before_filter :which_action_and_user before_filter :which_action_and_user
prepend_before_filter :clear_gc_stats prepend_before_filter :clear_gc_stats
...@@ -33,6 +34,11 @@ class ApplicationController < ActionController::Base ...@@ -33,6 +34,11 @@ class ApplicationController < ActionController::Base
end end
end end
def set_git_header
headers['X-Git-Update'] = GIT_UPDATE unless GIT_UPDATE.nil?
headers['X-Git-Revision'] = GIT_REVISION unless GIT_REVISION.nil?
end
def which_action_and_user def which_action_and_user
str = "event=request_with_user controller=#{self.class} action=#{self.action_name} " str = "event=request_with_user controller=#{self.class} action=#{self.action_name} "
if current_user if current_user
......
#original from https://github.com/jopper/diaspora # Copyright (c) 2010, Diaspora Inc. This file is
#modified by David Morley # licensed under the Affero General Public License version 3 or later. See
require 'time' # the COPYRIGHT file.
def last_modified
git_last='git log -1 --pretty=format:"%cd"'
filepath = Rails.root.join('tmp', '.last_pull')
time_min = 60
@header_name = "X-Git-Update"
if File.writable?(filepath)
begin
mtime = File.mtime(filepath)
last = IO.readlines(filepath).at(0)
rescue Exception => e
Rails.logger.info("Failed to read git status #{filepath}: #{e}")
end
end
if (mtime.nil? || mtime < Time.now-time_min)
last = `#{git_last}`
begin
f = File.open(filepath, 'w')
f.puts(last)
f.close
rescue Exception => e
Rails.logger.info("Failed to log git status #{filepath}: #{e}")
end
end
last
headers[@header_name] = "#{last}"
end
git_cmd = `git log -1 --format="%H %ci"`
if git_cmd =~ /^([\d\w]+?)\s(.+)$/
GIT_REVISION = $1
GIT_UPDATE = $2.strip
else
GIT_REVISION = nil
GIT_UPDATE = nil
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter