[#345] remove deprecated dynamic finder methods
This commit is contained in:
parent
62c290dd0d
commit
2ee3ea93bd
|
@ -87,6 +87,6 @@ class Admin::UsersController < Admin::BaseController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_user
|
def find_user
|
||||||
@user = User.find_by_uname!(params[:id]) if params[:id]
|
@user = User.find_by!(uname: params[:id]) if params[:id].present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,8 +78,8 @@ class ApplicationController < ActionController::Base
|
||||||
return current_user
|
return current_user
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
params['user_id'] && User.find_by_id(params['user_id']) ||
|
params['user_id'] && User.find(params['user_id']) ||
|
||||||
params['group_id'] && Group.find_by_id(params['group_id']) || current_user
|
params['group_id'] && Group.find(params['group_id']) || current_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Groups::MembersController < Groups::BaseController
|
||||||
def update
|
def update
|
||||||
params['user'].keys.each do |user_id|
|
params['user'].keys.each do |user_id|
|
||||||
role = params['user'][user_id]
|
role = params['user'][user_id]
|
||||||
if relation = @group.actors.where(actor_id: user_id, actor_type: 'User') #find_by_actor_id_and_actor_type(user_id, 'User')
|
if relation = @group.actors.where(actor_id: user_id, actor_type: 'User')
|
||||||
relation.update_all(role: role) if @group.owner.id.to_s != user_id
|
relation.update_all(role: role) if @group.owner.id.to_s != user_id
|
||||||
else
|
else
|
||||||
relation = @group.actors.build(actor_id: user_id, actor_type: 'User', role: role)
|
relation = @group.actors.build(actor_id: user_id, actor_type: 'User', role: role)
|
||||||
|
@ -34,7 +34,7 @@ class Groups::MembersController < Groups::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def add
|
def add
|
||||||
@user = User.find_by_uname(params[:user_uname])
|
@user = User.find_by uname: params[:user_uname]
|
||||||
if !@user
|
if !@user
|
||||||
flash[:error] = t("flash.collaborators.wrong_user", uname: params[:user_uname])
|
flash[:error] = t("flash.collaborators.wrong_user", uname: params[:user_uname])
|
||||||
elsif @group.add_member(@user, params[:role])
|
elsif @group.add_member(@user, params[:role])
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Projects::CommentsController < Projects::BaseController
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_commentable
|
def find_commentable
|
||||||
@commentable = params[:issue_id].present? && @project.issues.find_by_serial_id(params[:issue_id]) ||
|
@commentable = params[:issue_id].present? && @project.issues.find_by(serial_id: params[:issue_id]) ||
|
||||||
params[:commit_id].present? && @project.repo.commit(params[:commit_id])
|
params[:commit_id].present? && @project.repo.commit(params[:commit_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
else
|
else
|
||||||
raise 'Provider #{provider} not handled'
|
raise 'Provider #{provider} not handled'
|
||||||
end
|
end
|
||||||
user = User.find_or_initialize_by_email(auth['info']['email'])
|
user = User.find_or_initialize_by email: auth['info']['email']
|
||||||
if user.new_record?
|
if user.new_record?
|
||||||
user.name = name
|
user.name = name
|
||||||
user.uname = name.gsub(/\s/, '').underscore
|
user.uname = name.gsub(/\s/, '').underscore
|
||||||
|
|
|
@ -420,7 +420,7 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_packages(pkg_hash, project_name)
|
def set_packages(pkg_hash, project_name)
|
||||||
prj = Project.joins(repositories: :platform).where('platforms.id = ?', save_to_platform.id).find_by_name!(project_name)
|
prj = Project.joins(repositories: :platform).where('platforms.id = ?', save_to_platform.id).find_by!(name: project_name)
|
||||||
build_package(pkg_hash['srpm'], 'source', prj) {|p| p.save!}
|
build_package(pkg_hash['srpm'], 'source', prj) {|p| p.save!}
|
||||||
pkg_hash['rpm'].each do |rpm_hash|
|
pkg_hash['rpm'].each do |rpm_hash|
|
||||||
build_package(rpm_hash, 'binary', prj) {|p| p.save!}
|
build_package(rpm_hash, 'binary', prj) {|p| p.save!}
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Comment < ActiveRecord::Base
|
||||||
commentable.subscribes.create(user: user) if !commentable.subscribes.exists?(user_id: user.id)
|
commentable.subscribes.create(user: user) if !commentable.subscribes.exists?(user_id: user.id)
|
||||||
elsif commit_comment?
|
elsif commit_comment?
|
||||||
recipients = project.admins
|
recipients = project.admins
|
||||||
recipients << user << User.find_by_email(commentable.try(:committer).try(:email)) # commentor and committer
|
recipients << user << User.find_by(email: commentable.try(:committer).try(:email)) # commentor and committer
|
||||||
recipients.compact.uniq.each do |user|
|
recipients.compact.uniq.each do |user|
|
||||||
options = {project_id: project.id, subscribeable_id: commentable_id, subscribeable_type: commentable.class.name, user_id: user.id}
|
options = {project_id: project.id, subscribeable_id: commentable_id, subscribeable_type: commentable.class.name, user_id: user.id}
|
||||||
Subscribe.subscribe_to_commit(options) if Subscribe.subscribed_to_commit?(project, user, commentable)
|
Subscribe.subscribe_to_commit(options) if Subscribe.subscribed_to_commit?(project, user, commentable)
|
||||||
|
|
|
@ -27,7 +27,7 @@ module ActsLikeMember
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def find_by_insensitive_uname(uname)
|
def find_by_insensitive_uname(uname)
|
||||||
find_by_uname(uname) || by_uname(uname).first
|
find_by(uname: uname) || by_uname(uname).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_by_insensitive_uname!(uname)
|
def find_by_insensitive_uname!(uname)
|
||||||
|
|
|
@ -21,7 +21,7 @@ module BuildListObserver
|
||||||
if status == self.class::SUCCESS
|
if status == self.class::SUCCESS
|
||||||
# Update project average build time
|
# Update project average build time
|
||||||
begin
|
begin
|
||||||
statistic = project.project_statistics.find_or_create_by_arch_id(arch_id)
|
statistic = project.project_statistics.find_or_create_by arch_id: arch_id
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Feed::Comment
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_notify_on_new_comment?(subscribe)
|
def can_notify_on_new_comment?(subscribe)
|
||||||
notifier = SettingsNotifier.find_by_user_id(subscribe.user_id)
|
notifier = SettingsNotifier.find_by user_id: subscribe.user_id
|
||||||
notifier && notifier.new_comment && notifier.can_notify
|
notifier && notifier.new_comment && notifier.can_notify
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Feed::Git
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'Hash' # 'Gollum::Committer'
|
when 'Hash' # 'Gollum::Committer'
|
||||||
actor = User.find_by_uname! record[:actor_name]
|
actor = User.find_by! uname: record[:actor_name]
|
||||||
project = Project.find record[:project_id]
|
project = Project.find record[:project_id]
|
||||||
|
|
||||||
project.admins.each do |recipient|
|
project.admins.each do |recipient|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module FileStoreClean
|
||||||
|
|
||||||
def destroy_files_from_file_store(args = sha1_of_file_store_files)
|
def destroy_files_from_file_store(args = sha1_of_file_store_files)
|
||||||
files = *args
|
files = *args
|
||||||
token = User.find_by_uname('file_store').authentication_token
|
token = User.find_by(uname: 'file_store').authentication_token
|
||||||
uri = URI APP_CONFIG['file_store_url']
|
uri = URI APP_CONFIG['file_store_url']
|
||||||
Net::HTTP.start(uri.host, uri.port) do |http|
|
Net::HTTP.start(uri.host, uri.port) do |http|
|
||||||
files.each do |sha1|
|
files.each do |sha1|
|
||||||
|
|
|
@ -106,7 +106,7 @@ module Git
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_srpm(srpm_path = srpm.path, branch_name = 'import')
|
def import_srpm(srpm_path = srpm.path, branch_name = 'import')
|
||||||
token = User.find_by_uname('rosa_system').authentication_token
|
token = User.find_by(uname: 'rosa_system').authentication_token
|
||||||
opts = [srpm_path, path, branch_name, Rails.root.join('bin', 'file-store.rb'), token, APP_CONFIG['file_store_url']].join(' ')
|
opts = [srpm_path, path, branch_name, Rails.root.join('bin', 'file-store.rb'), token, APP_CONFIG['file_store_url']].join(' ')
|
||||||
system("#{Rails.root.join('bin', 'import_srpm.sh')} #{opts} >> /dev/null 2>&1")
|
system("#{Rails.root.join('bin', 'import_srpm.sh')} #{opts} >> /dev/null 2>&1")
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,13 +71,13 @@ class GitHook
|
||||||
def find_user(user)
|
def find_user(user)
|
||||||
if user.blank?
|
if user.blank?
|
||||||
# Local push
|
# Local push
|
||||||
User.find_by_email(project.repo.commit(newrev).author.email) rescue nil
|
User.find_by(email: project.repo.commit(newrev).author.email) rescue nil
|
||||||
elsif user =~ /\Auser-\d+\Z/
|
elsif user =~ /\Auser-\d+\Z/
|
||||||
# git push over http
|
# git push over http
|
||||||
User.find(user.gsub('user-', ''))
|
User.find(user.gsub('user-', ''))
|
||||||
elsif user =~ /\Akey-\d+\Z/
|
elsif user =~ /\Akey-\d+\Z/
|
||||||
# git push over ssh
|
# git push over ssh
|
||||||
SshKey.find_by_id(user.gsub('key-', '')).try(:user)
|
SshKey.find(user.gsub('key-', '')).try(:user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,7 +41,7 @@ class MassBuild < ActiveRecord::Base
|
||||||
next if name.blank?
|
next if name.blank?
|
||||||
name.chomp!; name.strip!
|
name.chomp!; name.strip!
|
||||||
|
|
||||||
if project = Project.joins(:repositories).where('repositories.id in (?)', save_to_platform.repository_ids).find_by_name(name)
|
if project = Project.joins(:repositories).where('repositories.id in (?)', save_to_platform.repository_ids).find_by(name: name)
|
||||||
begin
|
begin
|
||||||
return if self.reload.stop_build
|
return if self.reload.stop_build
|
||||||
increase_rt = increase_release_tag?
|
increase_rt = increase_release_tag?
|
||||||
|
|
|
@ -223,13 +223,13 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.cache.fetch([platform_name, token, :platform_allowed], expires_in: 2.minutes) do
|
Rails.cache.fetch([platform_name, token, :platform_allowed], expires_in: 2.minutes) do
|
||||||
platform = Platform.find_by_name platform_name
|
platform = Platform.find_by name: platform_name
|
||||||
next false unless platform
|
next false unless platform
|
||||||
next true unless platform.hidden?
|
next true unless platform.hidden?
|
||||||
next false unless token
|
next false unless token
|
||||||
next true if platform.tokens.by_active.where(authentication_token: token).exists?
|
next true if platform.tokens.by_active.where(authentication_token: token).exists?
|
||||||
|
|
||||||
user = User.find_by_authentication_token token
|
user = User.find_by authentication_token: token
|
||||||
current_ability = Ability.new(user)
|
current_ability = Ability.new(user)
|
||||||
if user && current_ability.can?(:show, platform)
|
if user && current_ability.can?(:show, platform)
|
||||||
true
|
true
|
||||||
|
|
|
@ -21,7 +21,7 @@ class PlatformContent
|
||||||
bfp_name = @path.match(/\/#{@platform.name}\/repository\/[\w]+\//)
|
bfp_name = @path.match(/\/#{@platform.name}\/repository\/[\w]+\//)
|
||||||
return nil unless bfp_name
|
return nil unless bfp_name
|
||||||
bfp_name = bfp_name[0].gsub(/\/#{@platform.name}\/repository\//, '').gsub('/', '')
|
bfp_name = bfp_name[0].gsub(/\/#{@platform.name}\/repository\//, '').gsub('/', '')
|
||||||
build_for_platform = Platform.main.find_by_name bfp_name
|
build_for_platform = Platform.main.find_by name: bfp_name
|
||||||
return nil unless build_for_platform
|
return nil unless build_for_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
# see: Issue #6
|
# see: Issue #6
|
||||||
before_validation -> { self.arch_id = Arch.find_by_name('x86_64').id }, on: :create
|
before_validation -> { self.arch_id = Arch.find_by(name: 'x86_64').id }, on: :create
|
||||||
# field "not_delete" can be changed only if build has been completed
|
# field "not_delete" can be changed only if build has been completed
|
||||||
before_validation -> { self.not_delete = false unless build_completed?; true }
|
before_validation -> { self.not_delete = false unless build_completed?; true }
|
||||||
validates :product_id,
|
validates :product_id,
|
||||||
|
|
|
@ -165,7 +165,7 @@ class Project < ActiveRecord::Base
|
||||||
#path #share by NFS
|
#path #share by NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_for(mass_build, repository_id, arch = Arch.find_by_name('i586'), priority = 0, increase_rt = false)
|
def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false)
|
||||||
build_for_platform = mass_build.build_for_platform
|
build_for_platform = mass_build.build_for_platform
|
||||||
save_to_platform = mass_build.save_to_platform
|
save_to_platform = mass_build.save_to_platform
|
||||||
user = mass_build.user
|
user = mass_build.user
|
||||||
|
@ -245,7 +245,7 @@ class Project < ActiveRecord::Base
|
||||||
archive = archive_by_treeish_and_format tag.name, format
|
archive = archive_by_treeish_and_format tag.name, format
|
||||||
sha1 = Digest::SHA1.file(archive[:path]).hexdigest
|
sha1 = Digest::SHA1.file(archive[:path]).hexdigest
|
||||||
unless FileStoreClean.file_exist_on_file_store? sha1
|
unless FileStoreClean.file_exist_on_file_store? sha1
|
||||||
token = User.find_by_uname('rosa_system').authentication_token
|
token = User.find_by(uname: 'rosa_system').authentication_token
|
||||||
begin
|
begin
|
||||||
resp = JSON `curl --user #{token}: -POST -F 'file_store[file]=@#{archive[:path]};filename=#{name}-#{tag.name}.#{tag_file_format(format)}' #{APP_CONFIG['file_store_url']}/api/v1/upload`
|
resp = JSON `curl --user #{token}: -POST -F 'file_store[file]=@#{archive[:path]};filename=#{name}-#{tag.name}.#{tag_file_format(format)}' #{APP_CONFIG['file_store_url']}/api/v1/upload`
|
||||||
rescue # Dont care about it
|
rescue # Dont care about it
|
||||||
|
|
|
@ -35,13 +35,13 @@ class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
def regenerate(build_for_platform_id = nil)
|
def regenerate(build_for_platform_id = nil)
|
||||||
build_for_platform = Platform.main.find build_for_platform_id if platform.personal?
|
build_for_platform = Platform.main.find build_for_platform_id if platform.personal?
|
||||||
status = repository_statuses.find_or_create_by_platform_id(build_for_platform.try(:id) || platform_id)
|
status = repository_statuses.find_or_create_by(platform_id: build_for_platform.try(:id) || platform_id)
|
||||||
status.regenerate
|
status.regenerate
|
||||||
end
|
end
|
||||||
|
|
||||||
def resign
|
def resign
|
||||||
if platform.main?
|
if platform.main?
|
||||||
status = repository_statuses.find_or_create_by_platform_id(platform_id)
|
status = repository_statuses.find_or_create_by(platform_id: platform_id)
|
||||||
status.resign
|
status.resign
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
%tr{class: cycle("odd", "even")}
|
%tr{class: cycle("odd", "even")}
|
||||||
%td= check_box_tag 'request_ids[]', request.id
|
%td= check_box_tag 'request_ids[]', request.id
|
||||||
%td= request.name
|
%td= request.name
|
||||||
- @user = User.find_by_email(request.email) if request.approved
|
- @user = User.find_by(email: request.email) if request.approved
|
||||||
%td= link_to_if @user, request.email, @user
|
%td= link_to_if @user, request.email, @user
|
||||||
%td= request.interest
|
%td= request.interest
|
||||||
%td= request.more
|
%td= request.more
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace :add_branch do
|
||||||
dst_branch = ENV['DST_BRANCH']
|
dst_branch = ENV['DST_BRANCH']
|
||||||
group = ENV['GROUP']
|
group = ENV['GROUP']
|
||||||
say "START add branch #{dst_branch} from #{src_branch} in #{group} group"
|
say "START add branch #{dst_branch} from #{src_branch} in #{group} group"
|
||||||
Group.find_by_uname(group).projects.find_each do |p|
|
Group.find_by(uname: group).projects.find_each do |p|
|
||||||
next if p.repo.branches.map(&:name).include?(dst_branch)
|
next if p.repo.branches.map(&:name).include?(dst_branch)
|
||||||
next if p.repo.branches.map(&:name).exclude?(src_branch)
|
next if p.repo.branches.map(&:name).exclude?(src_branch)
|
||||||
say "===== Process #{p.name} project"
|
say "===== Process #{p.name} project"
|
||||||
|
@ -32,7 +32,7 @@ namespace :add_branch do
|
||||||
src_branch = ENV['SRC_BRANCH'] || 'import_mandriva2011'
|
src_branch = ENV['SRC_BRANCH'] || 'import_mandriva2011'
|
||||||
dst_branch = ENV['DST_BRANCH'] || 'rosa2012lts'
|
dst_branch = ENV['DST_BRANCH'] || 'rosa2012lts'
|
||||||
say "START add branch #{dst_branch} from #{src_branch}"
|
say "START add branch #{dst_branch} from #{src_branch}"
|
||||||
Platform.find_by_name(dst_branch).repositories.each do |r|
|
Platform.find_by(name: dst_branch).repositories.each do |r|
|
||||||
say "=== Process #{r.name} repo"
|
say "=== Process #{r.name} repo"
|
||||||
r.projects.find_each do |p|
|
r.projects.find_each do |p|
|
||||||
next if p.repo.branches.map(&:name).include?(dst_branch)
|
next if p.repo.branches.map(&:name).include?(dst_branch)
|
||||||
|
@ -46,9 +46,9 @@ namespace :add_branch do
|
||||||
desc "Add branch for owner projects by list"
|
desc "Add branch for owner projects by list"
|
||||||
task list: :environment do
|
task list: :environment do
|
||||||
source = ENV['SOURCE'] || 'https://dl.dropbox.com/u/984976/texlive.txt'
|
source = ENV['SOURCE'] || 'https://dl.dropbox.com/u/984976/texlive.txt'
|
||||||
owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'import')
|
owner = User.find_by(uname: ENV['OWNER']) || Group.find_by!(uname: ENV['OWNER'] || 'import')
|
||||||
platform = Platform.find_by_name!(ENV['PLATFORM'] || 'rosa2012.1')
|
platform = Platform.find_by!(name: ENV['PLATFORM'] || 'rosa2012.1')
|
||||||
repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main')
|
repo = platform.repositories.find_by!(name: ENV['REPO'] || 'main')
|
||||||
src_branch = ENV['SRC_BRANCH'] || 'import_cooker'
|
src_branch = ENV['SRC_BRANCH'] || 'import_cooker'
|
||||||
dst_branch = ENV['DST_BRANCH'] || 'rosa2012.1'
|
dst_branch = ENV['DST_BRANCH'] || 'rosa2012.1'
|
||||||
say "START fork from #{src_branch} to #{dst_branch} branch using #{source} for #{owner.uname}. Add to repo '#{platform.name}/#{repo.name}'."
|
say "START fork from #{src_branch} to #{dst_branch} branch using #{source} for #{owner.uname}. Add to repo '#{platform.name}/#{repo.name}'."
|
||||||
|
|
|
@ -5,9 +5,8 @@ namespace :import do
|
||||||
desc "Load projects"
|
desc "Load projects"
|
||||||
task projects: :environment do
|
task projects: :environment do
|
||||||
source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/package_list.txt'
|
source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/package_list.txt'
|
||||||
#owner = User.find_by_uname(ENV['OWNER_UNAME']) || Group.find_by_uname(ENV['OWNER_UNAME']) || User.first
|
owner = Group.find_by uname: "npp_team"
|
||||||
owner = Group.find_by_uname("npp_team")
|
platform = Platform.find_by name: "RosaNPP" # RosaNPP
|
||||||
platform = Platform.find_by_name("RosaNPP") # RosaNPP
|
|
||||||
repo = platform.repositories.first rescue nil
|
repo = platform.repositories.first rescue nil
|
||||||
say "START import projects from '#{source}' for '#{owner.uname}'.#{repo ? " To repo '#{platform.name}/#{repo.name}'." : ''}"
|
say "START import projects from '#{source}' for '#{owner.uname}'.#{repo ? " To repo '#{platform.name}/#{repo.name}'." : ''}"
|
||||||
ask 'Press enter to continue'
|
ask 'Press enter to continue'
|
||||||
|
@ -33,9 +32,9 @@ namespace :import do
|
||||||
list = ENV['LIST'] #|| 'https://dl.dropbox.com/u/984976/alt_import.txt'
|
list = ENV['LIST'] #|| 'https://dl.dropbox.com/u/984976/alt_import.txt'
|
||||||
mask = ENV['MASK'] || '*.src.rpm'
|
mask = ENV['MASK'] || '*.src.rpm'
|
||||||
hidden = ENV['HIDDEN'] == 'true' ? true : false
|
hidden = ENV['HIDDEN'] == 'true' ? true : false
|
||||||
owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'altlinux')
|
owner = User.find_by(uname: ENV['OWNER']) || Group.find_by!(uname: ENV['OWNER'] || 'altlinux')
|
||||||
platform = Platform.find_by_name!(ENV['PLATFORM'] || 'altlinux5')
|
platform = Platform.find_by!(name: ENV['PLATFORM'] || 'altlinux5')
|
||||||
repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main')
|
repo = platform.repositories.find_by!(name: ENV['REPO'] || 'main')
|
||||||
clear = ENV['CLEAR'] == 'true' ? true : false
|
clear = ENV['CLEAR'] == 'true' ? true : false
|
||||||
|
|
||||||
say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'."
|
say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'."
|
||||||
|
@ -47,10 +46,10 @@ namespace :import do
|
||||||
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
||||||
repo.projects << project rescue nil
|
repo.projects << project rescue nil
|
||||||
else # check if project already added
|
else # check if project already added
|
||||||
if project = repo.projects.find_by_name(name) || repo.projects.by_name(name).first # fallback to speedup
|
if project = repo.projects.find_by(name: name) || repo.projects.by_name(name).first # fallback to speedup
|
||||||
print "Found project '#{project.name_with_owner}' in '#{platform.name}/#{repo.name}'."
|
print "Found project '#{project.name_with_owner}' in '#{platform.name}/#{repo.name}'."
|
||||||
elsif scoped = Project.where(owner_id: owner.id, owner_type: owner.class) and
|
elsif scoped = Project.where(owner_id: owner.id, owner_type: owner.class) and
|
||||||
project = scoped.find_by_name(name) || scoped.by_name(name).first
|
project = scoped.find_by(name: name) || scoped.by_name(name).first
|
||||||
begin
|
begin
|
||||||
repo.projects << project rescue nil
|
repo.projects << project rescue nil
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -109,10 +108,10 @@ namespace :import do
|
||||||
desc "Parse repository for changes"
|
desc "Parse repository for changes"
|
||||||
task parse: :environment do
|
task parse: :environment do
|
||||||
release = ENV['RELEASE'] || 'official/2011'
|
release = ENV['RELEASE'] || 'official/2011'
|
||||||
platform = Platform.find_by_name(ENV['PLATFORM'] || "mandriva2011")
|
platform = Platform.find_by(name: ENV['PLATFORM'] || "mandriva2011")
|
||||||
repository = platform.repositories.find_by_name(ENV['REPOSITORY'] || 'main')
|
repository = platform.repositories.find_by(name: ENV['REPOSITORY'] || 'main')
|
||||||
source = ENV['DESTINATION'] || File.join(APP_CONFIG['root_path'], 'mirror.yandex.ru', 'mandriva', release, 'SRPMS', repository.name, '{release,updates}')
|
source = ENV['DESTINATION'] || File.join(APP_CONFIG['root_path'], 'mirror.yandex.ru', 'mandriva', release, 'SRPMS', repository.name, '{release,updates}')
|
||||||
owner = Group.find_or_create_by_uname(ENV['OWNER'] || 'import') {|g| g.name = g.uname; g.owner = User.first}
|
owner = Group.find_or_create_by(uname: ENV['OWNER'] || 'import') {|g| g.name = g.uname; g.owner = User.first}
|
||||||
branch = ENV['BRANCH'] || "import_#{platform.name}"
|
branch = ENV['BRANCH'] || "import_#{platform.name}"
|
||||||
|
|
||||||
say "START (#{Time.now.utc})"
|
say "START (#{Time.now.utc})"
|
||||||
|
@ -127,10 +126,10 @@ namespace :import do
|
||||||
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
|
||||||
print "Use project #{project.name_with_owner}. "
|
print "Use project #{project.name_with_owner}. "
|
||||||
else # search project through repository
|
else # search project through repository
|
||||||
if project = repository.projects.find_by_name(name) || repository.projects.by_name(name).first # fallback to speedup
|
if project = repository.projects.find_by(name: name) || repository.projects.by_name(name).first # fallback to speedup
|
||||||
print "Found project #{project.name_with_owner} in #{platform.name}/#{repository.name}. "
|
print "Found project #{project.name_with_owner} in #{platform.name}/#{repository.name}. "
|
||||||
elsif scoped = Project.where(owner_id: owner.id, owner_type: owner.class) and
|
elsif scoped = Project.where(owner_id: owner.id, owner_type: owner.class) and
|
||||||
project = scoped.find_by_name(name) || scoped.by_name(name).first
|
project = scoped.find_by(name: name) || scoped.by_name(name).first
|
||||||
repository.projects << project
|
repository.projects << project
|
||||||
print "Add project #{project.name_with_owner} to #{platform.name}/#{repository.name}. "
|
print "Add project #{project.name_with_owner} to #{platform.name}/#{repository.name}. "
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,15 +5,15 @@ namespace :repositories do
|
||||||
repo_dirs = Dir["/root/mandriva_main_git/*.git"]
|
repo_dirs = Dir["/root/mandriva_main_git/*.git"]
|
||||||
total = repo_dirs.length
|
total = repo_dirs.length
|
||||||
|
|
||||||
cooker = Platform.find_by_name!("cooker")
|
cooker = Platform.find_by! name: "cooker"
|
||||||
main = cooker.repositories.find_by_name!("main")
|
main = cooker.repositories.find_by! name: "main"
|
||||||
|
|
||||||
repo_dirs.each_with_index do |repo_dir, index|
|
repo_dirs.each_with_index do |repo_dir, index|
|
||||||
project_name = File.basename(repo_dir, ".git")
|
project_name = File.basename(repo_dir, ".git")
|
||||||
|
|
||||||
puts "Creating project(#{index}/#{total}): #{project_name}"
|
puts "Creating project(#{index}/#{total}): #{project_name}"
|
||||||
|
|
||||||
if main.projects.find_by_name(project_name)
|
if main.projects.find_by name: project_name
|
||||||
puts "\t Already created. Skipping"
|
puts "\t Already created. Skipping"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace :new_core do
|
||||||
task update_packages: :environment do
|
task update_packages: :environment do
|
||||||
say "[#{Time.zone.now}] Starting to extract rpms..."
|
say "[#{Time.zone.now}] Starting to extract rpms..."
|
||||||
|
|
||||||
token = User.find_by_uname('rosa_system').authentication_token
|
token = User.find_by(uname: 'rosa_system').authentication_token
|
||||||
BuildList.where(new_core: true).
|
BuildList.where(new_core: true).
|
||||||
where(status: [
|
where(status: [
|
||||||
BuildList::SUCCESS,
|
BuildList::SUCCESS,
|
||||||
|
|
|
@ -30,10 +30,10 @@ end
|
||||||
namespace :projects do
|
namespace :projects do
|
||||||
desc 'Add projects from one platform repository to another'
|
desc 'Add projects from one platform repository to another'
|
||||||
task copy_to_repo: :environment do
|
task copy_to_repo: :environment do
|
||||||
source_platform = Platform.find_by_name!(ENV['SRC_PLATFORM'])
|
source_platform = Platform.find_by! name: ENV['SRC_PLATFORM']
|
||||||
dest_platform = Platform.find_by_name!(ENV['DST_PLATFORM'])
|
dest_platform = Platform.find_by! name: ENV['DST_PLATFORM']
|
||||||
source_repo = source_platform.repositories.find_by_name!(ENV['SRC_REPO'])
|
source_repo = source_platform.repositories.find_by! name: ENV['SRC_REPO']
|
||||||
dest_repo = dest_platform.repositories.find_by_name!(ENV['DST_REPO'])
|
dest_repo = dest_platform.repositories.find_by! name: ENV['DST_REPO']
|
||||||
|
|
||||||
say "Add from repo '#{source_platform.name}/#{source_repo.name}' to repo '#{dest_platform.name}/#{dest_repo.name}'."
|
say "Add from repo '#{source_platform.name}/#{source_repo.name}' to repo '#{dest_platform.name}/#{dest_repo.name}'."
|
||||||
source_repo.projects.each do |pr|
|
source_repo.projects.each do |pr|
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace :remove_branch do
|
||||||
branch = ENV['BRANCH']
|
branch = ENV['BRANCH']
|
||||||
group = ENV['GROUP']
|
group = ENV['GROUP']
|
||||||
say "START remove branch #{branch} from #{group} group"
|
say "START remove branch #{branch} from #{group} group"
|
||||||
Group.find_by_uname(group).projects.find_each do |p|
|
Group.find_by(uname: group).projects.find_each do |p|
|
||||||
next if p.repo.branches.map(&:name).exclude?(branch)
|
next if p.repo.branches.map(&:name).exclude?(branch)
|
||||||
say "===== Process #{p.name} project"
|
say "===== Process #{p.name} project"
|
||||||
p.repo.git.native(:branch, {}, '-D', branch)
|
p.repo.git.native(:branch, {}, '-D', branch)
|
||||||
|
|
|
@ -156,14 +156,14 @@ shared_examples_for 'platform admin user' do
|
||||||
it 'should be able to perform regenerate_metadata action' do
|
it 'should be able to perform regenerate_metadata action' do
|
||||||
put :regenerate_metadata, id: @repository.id, platform_id: @platform.id
|
put :regenerate_metadata, id: @repository.id, platform_id: @platform.id
|
||||||
response.should redirect_to(platform_repository_path(@platform, @repository))
|
response.should redirect_to(platform_repository_path(@platform, @repository))
|
||||||
@repository.repository_statuses.find_by_platform_id(@platform.id).
|
@repository.repository_statuses.find_by(platform_id: @platform.id).
|
||||||
waiting_for_regeneration?.should be_true
|
waiting_for_regeneration?.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to perform regenerate_metadata action of personal repository' do
|
it 'should be able to perform regenerate_metadata action of personal repository' do
|
||||||
put :regenerate_metadata, id: @personal_repository.id, platform_id: @personal_repository.platform.id, build_for_platform_id: @platform.id
|
put :regenerate_metadata, id: @personal_repository.id, platform_id: @personal_repository.platform.id, build_for_platform_id: @platform.id
|
||||||
response.should redirect_to(platform_repository_path(@personal_repository.platform, @personal_repository))
|
response.should redirect_to(platform_repository_path(@personal_repository.platform, @personal_repository))
|
||||||
@personal_repository.repository_statuses.find_by_platform_id(@platform.id).
|
@personal_repository.repository_statuses.find_by(platform_id: @platform.id).
|
||||||
waiting_for_regeneration?.should be_true
|
waiting_for_regeneration?.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ FactoryGirl.define do
|
||||||
association :save_to_platform, factory: :platform
|
association :save_to_platform, factory: :platform
|
||||||
association :user
|
association :user
|
||||||
projects_list "first"
|
projects_list "first"
|
||||||
arches { [ Arch.find_or_create_by_name('x86_64').id ] }
|
arches { [ Arch.find_or_create_by(name: 'x86_64').id ] }
|
||||||
auto_publish true
|
auto_publish true
|
||||||
stop_build false
|
stop_build false
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,6 @@ FactoryGirl.define do
|
||||||
time_living 150
|
time_living 150
|
||||||
|
|
||||||
# see: before_validation in ProductBuildList model
|
# see: before_validation in ProductBuildList model
|
||||||
before(:create) { Arch.find_or_create_by_name('x86_64') }
|
before(:create) { Arch.find_or_create_by(name: 'x86_64') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe AbfWorker::BuildListsPublishTaskManager do
|
||||||
|
|
||||||
it "ensures that repository_status has status publish" do
|
it "ensures that repository_status has status publish" do
|
||||||
build_list.save_to_repository.repository_statuses.
|
build_list.save_to_repository.repository_statuses.
|
||||||
find_by_platform_id(build_list.build_for_platform_id).publish?.
|
find_by(platform_id: build_list.build_for_platform_id).publish?.
|
||||||
should be_true
|
should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue