From bc1962b9ea2a26e72230192506009e6ae7ea119a Mon Sep 17 00:00:00 2001 From: ciaranj Date: Tue, 26 Jun 2012 16:15:14 +0100 Subject: [PATCH 1/3] Change public keys editing, back path to my/account --- app/views/gitolite_public_keys/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gitolite_public_keys/edit.html.erb b/app/views/gitolite_public_keys/edit.html.erb index 78b7a15eb..b498dae37 100644 --- a/app/views/gitolite_public_keys/edit.html.erb +++ b/app/views/gitolite_public_keys/edit.html.erb @@ -1,4 +1,4 @@ -

<%= link_to l(:label_public_keys), public_keys_path %> » <%= h @gitolite_public_key %>

+

<%= link_to l(:label_public_keys), :controller=> "my", :action => "account" %> » <%= h @gitolite_public_key %>

<%= error_messages_for :gitolite_public_key %> From a709ab643990a79bfa36e4ed697380221ec5d542 Mon Sep 17 00:00:00 2001 From: ciaranj Date: Fri, 29 Jun 2012 09:18:49 +0100 Subject: [PATCH 2/3] Cache calls to 'entries' The Hosting adapter causes multiple calls to be sent to 'entries' on the git_adapter(repositories_controller_path#show_with_git_instructions adds a second (non vanilla chiliproject) call. As this method is very expensive, this has a performance impact we can avoid! It might be better to provide a dedicated method to the patched git_adapter to determine whether a repository is 'empty' or not rather than having to fetch the entries, but this will work for now. --- lib/git_hosting/patches/git_adapter_patch.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/git_hosting/patches/git_adapter_patch.rb b/lib/git_hosting/patches/git_adapter_patch.rb index d97624bd2..bcdf00a95 100644 --- a/lib/git_hosting/patches/git_adapter_patch.rb +++ b/lib/git_hosting/patches/git_adapter_patch.rb @@ -7,6 +7,7 @@ def self.included(base) unloadable end + base.send(:alias_method_chain, :entries, :entry_caching) begin base.send(:alias_method_chain, :scm_cmd, :sudo) rescue Exception =>e @@ -34,6 +35,11 @@ def client_command_with_sudo end end + def entries_with_entry_caching(path=nil, identifier=nil) + return @entries if @entries + @entries= entries_without_entry_caching(path, identifier) + @entries + end def scm_cmd_with_sudo(*args, &block) From 10578995f6ff79e444d8bd3c804a079e851bab87 Mon Sep 17 00:00:00 2001 From: ciaranj Date: Fri, 29 Jun 2012 08:53:14 +0100 Subject: [PATCH 3/3] Avoid un-neccessary gitolite configuration updates There is some logic in update_repositories to avoid 'recursion' however this does not protect against the case where an observed change leads to multiple calls to update_repositories for the same project (or projects.) An example change that could cause this is is to add a *group* with commit rights as a project's member. The update_repositories method will then get called for both the group's addition and each subsequent member of that group. This change avoids those un-neccessary secondary calls. --- lib/git_hosting.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/git_hosting.rb b/lib/git_hosting.rb index 8bcea3432..06e19b84f 100755 --- a/lib/git_hosting.rb +++ b/lib/git_hosting.rb @@ -344,6 +344,7 @@ def self.move_repository(old_name, new_name) end @@recursionCheck = false + @@projects_so_far= [] def self.update_repositories(projects, is_repo_delete) @@ -356,13 +357,14 @@ def self.update_repositories(projects, is_repo_delete) logger.debug "Updating repositories..." projects = (projects.is_a?(Array) ? projects : [projects]) - + + @@projects_so_far.each { |p| logger.info p.name } + projects= projects.select{|p| !@@projects_so_far.include?(p) } # Don't bother doing anything if none of the projects we've been handed have a Git repository unless projects.detect{|p| p.repository.is_a?(Repository::Git) }.nil? - #lock if !lock(5) @@recursionCheck = false @@ -383,7 +385,7 @@ def self.update_repositories(projects, is_repo_delete) changed = false projects.select{|p| p.repository.is_a?(Repository::Git)}.each do |project| - + @@projects_so_far << project repo_name = repository_name(project) #check for delete -- if delete we can just