Merge branch 'master' of github.com:warpc/rosa-build

This commit is contained in:
George Vinogradov 2011-10-28 01:39:27 +04:00
commit 69a0277c58
5 changed files with 8 additions and 54 deletions

View File

@ -20,7 +20,7 @@ class Platform < ActiveRecord::Base
after_create :make_owner_rel after_create :make_owner_rel
# before_save :create_directory # before_save :create_directory
before_save :make_owner_rel before_save :make_owner_rel
after_destroy :remove_directory # after_destroy :remove_directory
before_create :xml_rpc_create before_create :xml_rpc_create
before_destroy :xml_rpc_destroy before_destroy :xml_rpc_destroy
# before_update :check_freezing # before_update :check_freezing
@ -118,7 +118,7 @@ class Platform < ActiveRecord::Base
def xml_rpc_clone(new_unixname) def xml_rpc_clone(new_unixname)
# return true # return true
result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] + '/platforms'
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else else

View File

@ -20,13 +20,12 @@ class Project < ActiveRecord::Base
validates :owner, :presence => true validates :owner, :presence => true
validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?} validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
# attr_accessible :visibility attr_accessible :category_id, :name, :unixname, :description, :visibility
attr_readonly :unixname attr_readonly :unixname
scope :recent, order("name ASC") scope :recent, order("name ASC")
scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} } scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} }
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}} scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") } scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") }
before_create :create_git_repo, :make_owner_rel before_create :create_git_repo, :make_owner_rel
@ -34,15 +33,8 @@ class Project < ActiveRecord::Base
before_destroy :destroy_git_repo before_destroy :destroy_git_repo
# before_create :xml_rpc_create # before_create :xml_rpc_create
# before_destroy :xml_rpc_destroy # before_destroy :xml_rpc_destroy
before_save :make_owner_rel
after_create :attach_to_personal_repository after_create :attach_to_personal_repository
# before_create :xml_rpc_create
# before_destroy :xml_rpc_destroy
attr_accessible :visibility
def attach_to_personal_repository def attach_to_personal_repository
repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository) repositories << self.owner.personal_repository if !repositories.exists?(:id => self.owner.personal_repository)
end end
@ -60,9 +52,6 @@ class Project < ActiveRecord::Base
def git_repo_path def git_repo_path
@git_repo_path ||= File.join(APP_CONFIG['root_path'], 'git_projects', "#{git_repo_name}.git") @git_repo_path ||= File.join(APP_CONFIG['root_path'], 'git_projects', "#{git_repo_name}.git")
end end
def git_repo_clone_path
"git@gitolite:#{git_repo_name}.git"
end
def git_repo_name def git_repo_name
[owner.uname, unixname].join('/') [owner.uname, unixname].join('/')
end end

View File

@ -15,8 +15,8 @@ class Repository < ActiveRecord::Base
has_many :members, :through => :objects, :source => :object, :source_type => 'User' has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true validates :name, :uniqueness => {:scope => :platform_id}, :presence => true
validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ } validates :unixname, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }
validates :platform_id, :presence => true validates :platform_id, :presence => true
scope :recent, order("name ASC") scope :recent, order("name ASC")
@ -33,7 +33,7 @@ class Repository < ActiveRecord::Base
add_downloads_symlink unless self.hidden? add_downloads_symlink unless self.hidden?
} }
attr_accessible :visibility attr_accessible :visibility, :name, :unixname, :platform_id
def path def path
build_path(unixname) build_path(unixname)

View File

@ -1,38 +1,3 @@
require 'digest/md5'
TEST_USERS =
[
['yaroslav@markin.net' , 'Yaroslav Markin'] ,
['timothy.tsvetkov@gmail.com' , 'Timothy Tsvetkov'] ,
['alexey.nayden@gmail.com' , 'Alexey Nayden']
]
TEST_USERS.each do |tuser|
email = tuser[0]
next if User.find_by_email(email)
name = tuser[1]
pass = Digest::MD5.hexdigest(name)[0..6]
user = User.create! :name => name, :email => email, :password => pass, :password_confirmation => pass
puts "Created user #{name} (#{email}) and password #{pass}"
end
=begin
TEST_PLATFORMS = %w(cooker Mandriva2010-10 Mandriva2011.4)
TEST_PROJECTS = %w(gcc glibc mysql-dev ruby ruby1.9 mc mesa avrdude vim gvim openssh-server openssh nethack binutils build-essentials rpm rpmtools ffmpeg mkvtoolnix libogg mpg123 openbox openoffice.org)
TEST_PLATFORMS.each do |platform|
p = Platform.find_or_create_by_name(platform)
TEST_PROJECTS.each do |project|
pr = Project.find_or_initialize_by_platform_id_and_name(p.id, project)
pr.unixname = pr.name
puts "#{project} added to #{platform}" if pr.new_record?
pr.save!
end
end
=end
ARCHES = %w(i586 i686 x86_64 mips powerpc) ARCHES = %w(i586 i686 x86_64 mips powerpc)
ARCHES.each do |arch| ARCHES.each do |arch|
Arch.find_or_create_by_name arch Arch.find_or_create_by_name arch

View File

@ -19,8 +19,8 @@ class BuildServer
end end
def self.add_platform name, root_folder, distrib_type, repos = {:src => [], :rpm => []} def self.add_platform name, platforms_root_folder, distrib_type, repos = {:src => [], :rpm => []}
self.client.call('add_platform', name, root_folder, repos, distrib_type) self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type)
end end