Fix gitolito update_key bug. Push project colaborators git. Fix key update. Hide colaborators groups. Improve RPC XML tests. Refactor and code cleanup. Refs #2162

This commit is contained in:
Pavel Chipiga 2011-11-01 02:52:24 +02:00
parent 5ac70da272
commit 5c97e89829
9 changed files with 36 additions and 26 deletions

View File

@ -6,7 +6,7 @@ GIT
GIT
remote: git@github.com:warpc/gitolito.git
revision: 8608b9bdfd33e961d9f9d71dd594e62780c074f6
revision: 120992e79d079800f6efb07f100ab80437b20b43
specs:
gitolito (0.0.1)
grit

View File

@ -36,7 +36,7 @@ class Project < ActiveRecord::Base
before_save :check_owner_rel
after_create :attach_to_personal_repository
after_create :create_git_repo
after_create :create_git_repo
before_update :update_git_repo
after_destroy :destroy_git_repo
after_rollback lambda { destroy_git_repo rescue true if new_record? }

View File

@ -5,6 +5,23 @@ class Relation < ActiveRecord::Base
has_many :role_lines
has_many :roles, :autosave => true, :through => :role_lines
after_create {
with_ga do |ga|
if repo = ga.find_repo(target.git_repo_name) and key = object.ssh_key and key.present?
repo.add_key(key, 'RW', :force => true)
ga.save_and_release
end
end if target_type == 'Project' and object_type == 'User'
}
after_destroy {
with_ga do |ga|
if repo = ga.find_repo(target.git_repo_name) and key = object.ssh_key and key.present?
repo.rm_key(key)
ga.save_and_release
end
end if target_type == 'Project' and object_type == 'User'
}
scope :by_object, lambda {|obj| {:conditions => ['object_id = ? AND object_type = ?', obj.id, obj.class.to_s]}}
scope :by_target, lambda {|tar| {:conditions => ['target_id = ? AND target_type = ?', tar.id, tar.class.to_s]}}
end

View File

@ -87,7 +87,7 @@ class User < ActiveRecord::Base
def create_ssh_key(key)
with_ga do |ga|
ga.store_key! key
own_projects.each do |project|
projects.each do |project|
repo = ga.find_repo(project.git_repo_name)
repo.add_key(key, 'RW') if repo
end
@ -97,12 +97,8 @@ class User < ActiveRecord::Base
def update_ssh_key(old_key, new_key)
with_ga do |ga|
ga.repos.replace_key old_key, new_key #, options = {}
ga.replace_key! old_key, new_key
begin
ga.repos.replace_key old_key, new_key #, options = {}
rescue Gitolito::GitoliteAdmin::Repo::KeyDoesntExistsError
nil
end
ga.save_and_release
end
end

View File

@ -17,17 +17,17 @@
- if current_user.can_perform? 'collaborators', 'edit', @project
= link_to t("layout.projects.edit_collaborators"), edit_project_collaborators_path(@project)
%p
%b
= "#{t("layout.projects.groups")}:"
%ul
- @project.groups.each do |group|
%li
= link_to group.name, group_path(group)
- if (@project.owner == group)
= '(' + t("layout.owner") + ')'
%br
= link_to t("layout.projects.add_groups"), '#' #add_collaborators_project_path(@project)
/ %p
/ %b
/ = "#{t("layout.projects.groups")}:"
/ %ul
/ - @project.groups.each do |group|
/ %li
/ = link_to group.name, group_path(group)
/ - if (@project.owner == group)
/ = '(' + t("layout.owner") + ')'
/ %br
/ = link_to t("layout.projects.add_groups"), '#' #add_collaborators_project_path(@project)
/ .block.notice
/ %h3= t("layout.platforms.current_platform_header")

View File

@ -4,7 +4,7 @@
%li.first= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_project_path
%li.active= link_to t("layout.projects.show"), project_path(@project)
%li= link_to "git-repo", project_repo_path(@project)
%li= link_to t("layout.git.repositories.source"), project_repo_path(@project)
%li= link_to t("layout.projects.build"), build_project_path(@project)
.content

View File

@ -5,8 +5,8 @@ require 'xmlrpc/client'
require 'pp'
# Please correctly fill following vars
@host = 'localhost'
@port = 3000
@host = 'npp-build.rosalab.ru'
@port = 80
@user = 'pchipiga@ya.ru'
@password = '123456'

View File

@ -295,7 +295,7 @@ ru:
statistics_refreshed: Статистика обновлена
collaborators:
successfuly_changed: Список коллабораторов успешно изменен
successfully_changed: Список коллабораторов успешно изменен
error_in_changing: Ошибка изменения списка коллабораторов
auto_build_list:

View File

@ -83,9 +83,6 @@ Rosa::Application.routes.draw do
resources :collaborators, :only => [:index, :edit, :update] do
collection do
get :add
post :add
get :edit
post :update
end