Merge branch 'master' into 674-diff_between_commits

Conflicts:
	db/schema.rb  fresh
This commit is contained in:
Alexander Machehin 2012-12-04 00:02:45 +06:00
commit b132a56937
51 changed files with 450 additions and 180 deletions

View File

@ -8,7 +8,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
load_and_authorize_resource :build_list, :only => [:show, :create, :cancel, :publish, :reject_publish]
def index
filter = BuildList::Filter.new(nil, current_user, params[:filter] || {})
filter = BuildList::Filter.new(@project, current_user, params[:filter] || {})
@build_lists = filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch])
@build_lists = @build_lists.recent.paginate(paginate_params)
end
@ -52,11 +52,14 @@ class Api::V1::BuildListsController < Api::V1::BaseController
private
def render_json(action_name)
if @build_list.send(action_name)
render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")}
else
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")}
end
end
res, message = if !@build_list.send "can_#{action_name}?"
[false, "Incorrect action for current build list"]
elsif @build_list.send(action_name)
[true, t("layout.build_lists.#{action_name}_success")]
else
[false, t("layout.build_lists.#{action_name}_fail")]
end
render :json => {:"is_#{action_name}ed" => res, :url => api_v1_build_list_path(@build_list, :format => :json), :message => message}
end
end

View File

@ -0,0 +1,11 @@
class Api::V1::MaintainersController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
def index
@maintainers = BuildList::Package.includes(:project)
.actual.by_platform(@platform)
.like_name(params[:filter].try(:[], :package_name))
.paginate(paginate_params)
end
end

View File

@ -0,0 +1,12 @@
# -*- encoding : utf-8 -*-
class Api::V1::SearchController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
def index
@results = Search.by_term_and_type(
params[:query],
(params[:type] || 'all'),
paginate_params
)
end
end

View File

@ -5,11 +5,9 @@ class Platforms::MaintainersController < ApplicationController
load_and_authorize_resource :platform
def index
@maintainers = BuildList::Package.actual.by_platform(@platform)
.order('lower(name) ASC, length(name) ASC')
.includes(:project)
@maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present?
@maintainers = @maintainers.paginate(:page => params[:page])
@maintainers = BuildList::Package.includes(:project)
.actual.by_platform(@platform)
.like_name(params[:q])
.paginate(:page => params[:page])
end
end

View File

@ -55,12 +55,16 @@ class Projects::BuildListsController < Projects::BaseController
build_for_platforms = Repository.select(:platform_id).
where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
new_core = current_user.admin? && params[:build_list][:new_core] == '1'
params[:build_list][:auto_publish] = false if new_core
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => build_for_platforms).each do |build_for_platform|
@build_list = @project.build_lists.build(params[:build_list])
@build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user
@build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i}
@build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
@build_list.new_core = new_core
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name}
if @build_list.save
notices << t("flash.build_list.saved", flash_options)
@ -104,12 +108,10 @@ class Projects::BuildListsController < Projects::BaseController
end
def log
@log = `tail -n #{params[:load_lines].to_i} #{Rails.root + 'public' + @build_list.fs_log_path}`
@log = t("layout.build_lists.log.not_available") unless $?.success?
respond_to do |format|
format.json { render :json => { :log => @log, :building => @build_list.build_started? } }
end
render :json => {
:log => @build_list.log(params[:load_lines]),
:building => @build_list.build_started?
}
end
def publish_build

View File

@ -4,22 +4,15 @@ class SearchController < ApplicationController
# load_and_authorize_resource
def index
params[:type] ||= 'all'
case params[:type]
when 'all'
find_collection('projects')
find_collection('users')
find_collection('groups')
find_collection('platforms')
when 'projects', 'users', 'groups', 'platforms'
find_collection(params[:type])
@type = params[:type] || 'all'
@query = params[:query]
Search.by_term_and_type(
@query,
@type,
{:page => params[:page]}
).each do |k, v|
var = :"@#{k}"
instance_variable_set var, v unless instance_variable_defined?(var)
end
end
protected
def find_collection(type)
var = :"@#{type}"
instance_variable_set var, type.classify.constantize.opened.search(params[:query]).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var)
end
end

View File

@ -26,6 +26,9 @@ class BuildList < ActiveRecord::Base
validate lambda {
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id
}
validate lambda {
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.platform_type == 'main'
}
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
}
@ -109,6 +112,7 @@ class BuildList < ActiveRecord::Base
serialize :additional_repos
serialize :include_repos
serialize :results, Array
after_commit :place_build
after_destroy :delete_container
@ -233,10 +237,88 @@ class BuildList < ActiveRecord::Base
can_publish? and not save_to_repository.publish_without_qa
end
def add_to_abf_worker_queue
include_repos_hash = {}.tap do |h|
include_repos.each do |r|
repo = Repository.find r
path = repo.platform.public_downloads_url(nil, arch.name, repo.name)
# path = path.gsub(/^http:\/\/0\.0\.0\.0\:3000/, 'https://abf.rosalinux.ru')
# Path looks like:
# http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/
# so, we should append:
# /release
# /updates
h["#{repo.name}_release"] = path + 'release'
h["#{repo.name}_updates"] = path + 'updates'
end
end
# mdv example:
# https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git
# bfe6d68cc607238011a6108014bdcfe86c69456a
# rhel example:
# https://abf.rosalinux.ru/server/gnome-settings-daemon.git
# fbb2549e44d97226fea6748a4f95d1d82ffb8726
options = {
:id => id,
:arch => arch.name,
:time_living => 2880, # 2 days
:distrib_type => build_for_platform.distrib_type,
# :git_project_address => 'https://abf.rosalinux.ru/server/gnome-settings-daemon.git',
:git_project_address => project.git_project_address,
# :commit_hash => 'fbb2549e44d97226fea6748a4f95d1d82ffb8726',
:commit_hash => commit_hash,
:build_requires => build_requires,
:include_repos => include_repos_hash,
:bplname => build_for_platform.name
# :project_version => project_version,
# :plname => save_to_platform.name,
# :bplname => (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name),
# :update_type => update_type,
# :priority => priority,
}
unless @status
Resque.push(
'rpm_worker',
'class' => 'AbfWorker::RpmWorker',
'args' => [options]
)
end
@status ||= BUILD_PENDING
end
def add_to_queue
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address
@status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address
if new_core?
add_to_abf_worker_queue
else
# XML-RPC params:
# - project_name
# - project_version
# - plname
# - arch
# - bplname
# - update_type
# - build_requires
# - id_web
# - include_repos
# - priority
# - git_project_address
@status ||= BuildServer.add_build_list(
project.name,
project_version,
save_to_platform.name,
arch.name,
(save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name),
update_type,
build_requires,
id,
include_repos,
priority,
project.git_project_address
)
end
@status
end
def self.human_status(status)
@ -303,7 +385,17 @@ class BuildList < ActiveRecord::Base
!save_to_repository.publish_without_qa &&
save_to_platform.main? &&
save_to_platform.released &&
status == BUILD_PUBLISHED
build_published?
end
def log(load_lines)
if new_core?
log = Resque.redis.get("abfworker::rpm-worker-#{id}")
else
log = `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}`
log = nil unless $?.success?
end
log || I18n.t('layout.build_lists.log.not_available')
end
protected

View File

@ -12,11 +12,14 @@ class BuildList::Package < ActiveRecord::Base
:presence => true
validates :package_type, :inclusion => PACKAGE_TYPES
default_scope order('lower(name) ASC, length(name) ASC')
# Fetches only actual (last publised) packages.
scope :actual, where(:actual => true)
scope :by_platform, lambda {|platform| where(:platform_id => platform) }
scope :by_name, lambda {|name| where(:name => name) }
scope :by_package_type, lambda {|type| where(:package_type => type) }
scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%") if name.present?}
def assignee
project.maintainer

View File

@ -3,18 +3,27 @@ class ProductBuildList < ActiveRecord::Base
include Modules::Models::CommitAndVersion
delegate :url_helpers, to: 'Rails.application.routes'
BUILD_STARTED = 2
BUILD_COMPLETED = 0
BUILD_FAILED = 1
BUILD_FAILED = 1
BUILD_PENDING = 2
BUILD_STARTED = 3
BUILD_CANCELED = 4
BUILD_CANCELING = 5
STATUSES = [ BUILD_STARTED,
BUILD_COMPLETED,
BUILD_FAILED
BUILD_FAILED,
BUILD_PENDING,
BUILD_CANCELED,
BUILD_CANCELING
]
HUMAN_STATUSES = { BUILD_STARTED => :build_started,
BUILD_COMPLETED => :build_completed,
BUILD_FAILED => :build_failed
BUILD_FAILED => :build_failed,
BUILD_PENDING => :build_pending,
BUILD_CANCELED => :build_canceled,
BUILD_CANCELING => :build_canceling
}
belongs_to :product
@ -28,7 +37,7 @@ class ProductBuildList < ActiveRecord::Base
:main_script,
:time_living,
:arch_id, :presence => true
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
validates :status, :inclusion => { :in => STATUSES }
attr_accessor :base_url
attr_accessible :status,
@ -59,6 +68,10 @@ class ProductBuildList < ActiveRecord::Base
status == BUILD_STARTED
end
def build_canceling?
status == BUILD_CANCELING
end
def container_path
"/downloads/#{product.platform.name}/product/#{id}/"
end
@ -76,7 +89,7 @@ class ProductBuildList < ActiveRecord::Base
end
def can_destroy?
[BUILD_COMPLETED, BUILD_FAILED].include? status
[BUILD_COMPLETED, BUILD_FAILED, BUILD_CANCELED].include? status
end
def log
@ -84,6 +97,7 @@ class ProductBuildList < ActiveRecord::Base
end
def stop
update_attributes({:status => BUILD_CANCELING})
Resque.redis.setex(
"abfworker::iso-worker-#{id}::live-inspector",
120, # Data will be removed from Redis after 120 sec.

26
app/models/search.rb Normal file
View File

@ -0,0 +1,26 @@
# -*- encoding : utf-8 -*-
class Search
TYPES = ['projects', 'users', 'groups', 'platforms']
def self.by_term_and_type(term, type, paginate_params)
results = {}
case type
when 'all'
TYPES.each{ |t| results[t] = find_collection(t, term, paginate_params) }
when *TYPES
results[type] = find_collection(type, term, paginate_params)
end
results
end
class << self
protected
def find_collection(type, term, paginate_params)
type.classify.constantize.opened.
search(term).
search_order.
paginate(paginate_params)
end
end
end

View File

@ -7,15 +7,12 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
def initialize(commit, opts = {})
@commit = commit
@options = opts#[:branch] if opts[:branch]
@options = opts
prepare_message
end
def header
@header ||= if options[:branch].present?
I18n.t("layout.messages.commits.header_with_branch",
:committer => committer_link, :commit => commit_link, :branch => options[:branch].name)
elsif options[:project].present?
@header ||= if options[:project].present?
I18n.t("layout.messages.commits.header",
:committer => committer_link, :commit => commit_link, :project => options[:project].name)
end.html_safe

View File

@ -0,0 +1,2 @@
json.(maintainer, :id, :uname, :name, :email)
json.url api_v1_user_path(maintainer.id)

View File

@ -0,0 +1,3 @@
json.(package, :id, :name, :version, :release)
json.type package.package_type
json.updated_at package.updated_at.to_i

View File

@ -0,0 +1,15 @@
json.maintainers @maintainers do |json, maintainer|
json.project do |json_project|
json_project.partial! 'api/v1/projects/project', :project => maintainer.project, :json => json
end
json.package do |json_package|
json_package.partial! 'package', :package => maintainer, :json => json
end
json.maintainer do |json_maintainer|
if user = maintainer.try(:assignee)
json_maintainer.partial! 'maintainer', :maintainer => user, :json => json
end
end
end

View File

@ -1,3 +1,4 @@
json.(project, :id, :name)
json.fullname project.name_with_owner
json.url api_v1_project_path(project.id, :format => :json)
json.url api_v1_project_path(project.id, :format => :json)
json.git_url git_repo_url(project.git_repo_name)

View File

@ -0,0 +1,3 @@
json.groups results do |group|
json.partial! 'member', :member => group, :json => json
end

View File

@ -0,0 +1,3 @@
json.(member, :id, :uname)
json.(member, :name) if member.is_a?(User)
json.url member_path(member)

View File

@ -0,0 +1,3 @@
json.platforms results do |platform|
json.partial! 'api/v1/platforms/platform', :platform => platform, :json => json
end

View File

@ -0,0 +1,3 @@
json.projects results do |project|
json.partial! 'api/v1/projects/project', :project => project, :json => json
end

View File

@ -0,0 +1,3 @@
json.users results do |user|
json.partial! 'member', :member => user, :json => json
end

View File

@ -0,0 +1,6 @@
json.results do |json|
@results.each do |tag, results|
json.partial! tag.dup, :results => results, :json => json
end
end
json.url api_v1_search_index_path(:format => :json)

View File

@ -0,0 +1,18 @@
%h3= t("layout.product_build_lists.results")
- unless pbl.results.present?
%h4.nomargin= t("layout.product_build_lists.no_results")
- else
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.product_build_list/results.file_name")
%th= t("activerecord.attributes.product_build_list/results.sha1")
%th= t("activerecord.attributes.product_build_list/results.size")
%tbody
- pbl.results.each do |item|
%tr
- sha1 = item['sha1']
%td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
%td= sha1
%td= item['size']
.both

View File

@ -23,30 +23,14 @@
= render 'show_field', :key => :notified_at, :value => l(pbl.updated_at, :format => :long)
- if pbl.build_started?
- if pbl.build_started? || pbl.build_canceling?
- if can? :stop, pbl
.leftlist= t("layout.product_build_lists.action")
.rightlist= link_to t("layout.product_build_lists.stop"), stop_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl)
.both
= render 'shared/log', { :build_started => true, :get_log_path => log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) }
%h3= t("layout.product_build_lists.results")
- unless pbl.results.present?
%h4.nomargin= t("layout.product_build_lists.no_results")
- else
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.product_build_list/results.file_name")
%th= t("activerecord.attributes.product_build_list/results.sha1")
%tbody
- pbl.results.each do |item|
%tr
- sha1 = item['sha1']
%td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
%td= sha1
.both
= render 'results', :pbl => pbl
:javascript
$(function(){

View File

@ -3,7 +3,7 @@
= render 'about_block', :project => @project
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|
- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter|
= render 'shared/feed_message', :presenter => presenter, :item_no => 1
.both

View File

@ -29,6 +29,10 @@
.both
= f.check_box :build_requires
= f.label :build_requires
- if current_user.admin?
.both
= f.check_box :new_core
= f.label :new_core
%br
= f.submit t("layout.projects.build_button")

View File

@ -59,6 +59,9 @@
.leftlist= t("activerecord.attributes.build_list.is_circle")
.rightlist= t("layout.#{@build_list.is_circle?}_")
.both
.leftlist= t("activerecord.attributes.build_list.new_core")
.rightlist= t("layout.#{@build_list.new_core?}_")
.both
- if @build_list.mass_build_id.present?
.leftlist= t("activerecord.attributes.mass_build_id")
@ -125,53 +128,56 @@
});
- if BuildList::HUMAN_STATUSES[@build_list.status].in? [:build_started, :build_error, :success]
= render 'shared/log', { :build_started => @build_list.build_started?, :download_log_url => build_list_log_url(:build), :get_log_path => log_build_list_path(@build_list) }
- log_params = { :build_started => @build_list.build_started?, :get_log_path => log_build_list_path(@build_list) }
= render 'shared/log', ( @build_list.new_core? ? log_params : log_params.merge({:download_log_url => build_list_log_url(:build)}) )
- if (can_publish = @build_list.can_publish? && can?(:publish, @build_list))
- if (can_publish = @build_list.can_publish? && can?(:publish, @build_list) && !@build_list.new_core?)
.hr
= submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' if can_publish
- if @build_list.can_reject_publish? && can?(:reject_publish, @build_list)
= submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish'
.hr
%h3= t("layout.build_lists.items_header")
- if @item_groups.blank?
%h4.nomargin= t("layout.build_lists.no_items_data")
- @item_groups.each_with_index do |group, level|
- group.each do |item|
%h4.nomargin= "#{item.name} ##{level}"
- if @build_list.new_core?
= render 'platforms/product_build_lists/results', :pbl => @build_list
- else
%h3= t("layout.build_lists.items_header")
- if @item_groups.blank?
%h4.nomargin= t("layout.build_lists.no_items_data")
- @item_groups.each_with_index do |group, level|
- group.each do |item|
%h4.nomargin= "#{item.name} ##{level}"
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/item.name")
%th= t("activerecord.attributes.build_list/item.version")
%th= t("activerecord.attributes.build_list/item.status")
%tbody
%tr{:class => build_list_item_status_color(item.status)}
%td= item.name
%td= item.version
%td= item.human_status
.both
- if @build_list.packages.present?
.hr
%h3= t("layout.build_lists.packages_header")
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/item.name")
%th= t("activerecord.attributes.build_list/item.version")
%th= t("activerecord.attributes.build_list/item.status")
%th= t("activerecord.attributes.build_list/package.fullname")
%th= t("activerecord.attributes.build_list/package.name")
%th= t("activerecord.attributes.build_list/package.version")
%th= t("activerecord.attributes.build_list/package.release")
%tbody
%tr{:class => build_list_item_status_color(item.status)}
%td= item.name
%td= item.version
%td= item.human_status
.both
- if @build_list.packages.present?
.hr
%h3= t("layout.build_lists.packages_header")
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= t("activerecord.attributes.build_list/package.fullname")
%th= t("activerecord.attributes.build_list/package.name")
%th= t("activerecord.attributes.build_list/package.version")
%th= t("activerecord.attributes.build_list/package.release")
%tbody
- @build_list.packages.each do |package|
%tr
%td= package.fullname
%td= package.name
%td= package.version
%td= package.release
.both
- @build_list.packages.each do |package|
%tr
%td= package.fullname
%td= package.name
%td= package.version
%td= package.release
.both
:javascript
$('article .all').addClass('bigpadding');

View File

@ -5,7 +5,7 @@
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|
- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter|
= render 'shared/feed_message', :presenter => presenter, :item_no => 1
.both

View File

@ -12,7 +12,7 @@
.date= raw l(commits.first.authored_date, :format => :date_block_format)
.messages
- commits.each_with_index do |commit|
- GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter|
- GitPresenters::CommitAsMessagePresenter.present(commit, :project => @project) do |presenter|
= render 'shared/feed_message', :presenter => presenter, :item_no => counter
- counter += 1
.both

View File

@ -3,7 +3,7 @@
%tbody
- commits.each do |commit|
- item_no = commit.id
- GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter|
- GitPresenters::CommitAsMessagePresenter.present(commit, :project => @project) do |presenter|
%tr
%td
%img{:height => 16, :alt => "avatar", :src => presenter.image}

View File

@ -3,7 +3,7 @@
= render 'about_block', :project => @project
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|
- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter|
= render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1}
.both

View File

@ -1,4 +1,4 @@
.search
= form_tag search_index_path, :method => 'get' do
.pic
.field= text_field_tag 'query', params[:query], :placeholder => t("layout.search.header")
.field= text_field_tag 'query', @query, :placeholder => t("layout.search.header")

View File

@ -1,5 +1,5 @@
= form_tag search_index_path, :method => 'get' do
.leftside= text_field_tag 'query', params[:query], :placeholder => t("layout.search.header"), :class => 'exsearch'
.lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, params[:type]), :class => 'sel80 cusel', :id => 'selSearch'
.leftside= text_field_tag 'query', @query, :placeholder => t("layout.search.header"), :class => 'exsearch'
.lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, @type), :class => 'sel80 cusel', :id => 'selSearch'
.leftside= submit_tag t("layout.search.header"), :class => 'button width100'
.both

View File

@ -7,4 +7,4 @@
- collection.each do |c|
%tr
%td= render type.singularize, type.singularize.to_sym => c
= link_to t('layout.search.all'), search_index_path(:query => params[:query], :type => type) if collection.present?
= link_to t('layout.search.all'), search_index_path(:query => @query, :type => type) if collection.present?

View File

@ -1,6 +1,6 @@
%h3= title t('layout.search.advanced')
= render 'form_advanced'
- if params[:type] == 'all'
- if @type == 'all'
#all
= render 'table', :type => 'projects'
.both
@ -10,8 +10,8 @@
.left.width400
= render 'table', :type => 'platforms'
- else
- collection = instance_variable_get("@#{params[:type]}")
.tmargin10{:id => params[:type]}= render :collection => collection, :partial => params[:type].to_s.underscore.singularize
- collection = instance_variable_get("@#{@type}")
.tmargin10{:id => @type}= render :collection => collection, :partial => @type.to_s.underscore.singularize
%br
= will_paginate collection
.both

View File

@ -13,7 +13,7 @@ url = 'http://file-store.rosalinux.ru/api/v1/file_stores.json'
#url = 'http://localhost:3001/api/v1/file_stores.json'
rclient = RestClient::Resource.new(url, :user => ARGF.argv[0]) # user auth token
Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz}").uniq.sort.each do |file|
Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file|
begin
#next if File.size(file) < MAX_SIZE
@ -26,7 +26,7 @@ Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz}").uniq.s
puts " file \"#{file}\" already exists in the file-store"
elsif resp == []
# try to put file at file-store
resp = JSON(rclient.post :file_store => {:file => File.new(file, 'rb')})
resp = JSON `curl --user #{ARGF.argv[0]}: -POST -F "file_store[file]=@#{file}" http://file-store.rosalinux.ru/api/v1/upload`
unless resp['sha1_hash'].nil?
new_sources << " \"#{file}\": #{sha1}"
FileUtils.rm_rf file

View File

@ -33,12 +33,8 @@ Dir.glob(owners).each do |owner|
system "cd #{path} && git config --bool core.bare false && git checkout -f HEAD"
#--
Dir.chdir(path)
archives_exists = false
%w(tar.bz2 tar.gz bz2 rar gz tar tbz2 tgz zip Z 7z tar.xz).each do |ext|
archives_exists=true and break unless `git log --all --format='%H' -- *.#{ext}`.empty?
end
if archives_exists
unless `git log --all --format='%H' -- *.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}`.empty?
system "git filter-branch -d /dev/shm/git_task --tree-filter \"/home/rosa/git_task/file-store.rb #{token}\" --prune-empty --tag-name-filter cat -- --all"
#####
# This is dangerous !!!

View File

@ -2,5 +2,4 @@ en:
layout:
messages:
commits:
header_with_branch: "%{committer} has added %{commit} into %{branch} branch"
header: "%{committer} has added %{commit}"

View File

@ -2,5 +2,4 @@ ru:
layout:
messages:
commits:
header_with_branch: "%{committer} добавил коммит %{commit} в ветку %{branch}"
header: "%{committer} добавил коммит %{commit}"

View File

@ -13,6 +13,7 @@ en:
project: Project
arch_id: Architecture
arch: Architecture
new_core: New core
is_circle: Recurrent build
updated_at: Notified at
additional_repos: Additional repositories
@ -143,6 +144,7 @@ en:
no_project_version_found: Project version '%{project_version}' not found
no_arch_or_platform_selected: At least one of architecture of platform must selected
wrong_platform: Only the primary platform can be selected for the main repository!
wrong_build_for_platform: Type of platform in "build_for_platform" should be "main"
wrong_repository: Repository to save package to must belongs to platform.
cannot_write: You can't build project to this repository.
can_not_published: Build can only be published with status "Build complete"

View File

@ -13,6 +13,7 @@ ru:
project: Проект
arch_id: Архитектура
arch: Архитектура
new_core: Новое ядро
is_circle: Циклическая сборка
updated_at: Информация получена
additional_repos: Дополнительные репозитории
@ -140,6 +141,7 @@ ru:
no_project_version_found: Выбранная версия '%{project_version}' не найдена
no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу
wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа!
wrong_build_for_platform: Тип платформы "build_for_platform" должен быть "main"
wrong_repository: Репозиторий для сохранения должен принадлежать платформе.
cannot_write: Вы не можете собирать пакет в этот репозиторий.
can_not_published: Опубликовать сборку можно только со статусом "Собран"

View File

@ -15,12 +15,12 @@ en:
main_data: Main data
show: Show
statuses:
'0': 'build'
'1': 'build error'
'2': 'build in progress'
build_completed: Build complete
build_failed: Build failed
build_started: Build in progress
build_completed: Built
build_pending: Build pending
build_started: Build started
build_canceled: Build canceled
build_canceling: Build is canceling
ownership:
header: Build list ownership
@ -46,6 +46,7 @@ en:
product_build_list/results:
file_name: File name
sha1: SHA1
size: Size (MB)
flash:
product_build_list:

View File

@ -15,12 +15,12 @@ ru:
main_data: Основные данные
show: Просмотр
statuses:
'0': 'собран'
'1': 'ошибка сборки'
'2': 'собирается'
build_failed: Ошибка сборки
build_started: Собирается
build_completed: Собран
build_failed: Ошибка сборки
build_pending: Ожидает сборку
build_started: Собирается
build_canceled: Сборка отменена
build_canceling: Сборка отменяется
ownership:
header: Принадлежность заданий
@ -46,6 +46,7 @@ ru:
product_build_list/results:
file_name: Имя файла
sha1: SHA1
size: Размер (МБ)
flash:
product_build_list:

View File

@ -1,7 +1,7 @@
ru:
title_editing:
'Редактирование'
at: at
at: в
users:
settings:
profile:

View File

@ -13,6 +13,7 @@ Rosa::Application.routes.draw do
namespace :api do
namespace :v1 do
resources :advisories, :only => [:index, :show, :create, :update]
resources :search, :only => [:index]
resources :build_lists, :only => [:index, :create, :show] do
member {
get :publish
@ -32,6 +33,7 @@ Rosa::Application.routes.draw do
post :clone
put :clear
}
resources :maintainers, :only => [ :index ]
end
resources :repositories, :only => [:show, :update, :destroy] do
member {
@ -53,6 +55,7 @@ Rosa::Application.routes.draw do
delete :remove_member
put :update_member
}
resources :build_lists, :only => :index
end
resources :users, :only => [:show]
get 'user' => 'users#show_current_user'

View File

@ -0,0 +1,6 @@
class AddResultsToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :results, :text
add_column :build_lists, :new_core, :boolean
end
end

View File

@ -130,6 +130,8 @@ ActiveRecord::Schema.define(:version => 20121203142727) do
t.integer "advisory_id"
t.integer "mass_build_id"
t.integer "save_to_repository_id"
t.text "results"
t.boolean "new_core"
t.string "last_published_commit_hash"
end
@ -252,48 +254,6 @@ ActiveRecord::Schema.define(:version => 20121203142727) do
t.boolean "stop_build", :default => false, :null => false
end
create_table "oauth_access_grants", :force => true do |t|
t.integer "resource_owner_id", :null => false
t.integer "application_id", :null => false
t.string "token", :null => false
t.integer "expires_in", :null => false
t.string "redirect_uri", :null => false
t.datetime "created_at", :null => false
t.datetime "revoked_at"
t.string "scopes"
end
add_index "oauth_access_grants", ["token"], :name => "index_oauth_access_grants_on_token", :unique => true
create_table "oauth_access_tokens", :force => true do |t|
t.integer "resource_owner_id"
t.integer "application_id", :null => false
t.string "token", :null => false
t.string "refresh_token"
t.integer "expires_in"
t.datetime "revoked_at"
t.datetime "created_at", :null => false
t.string "scopes"
end
add_index "oauth_access_tokens", ["refresh_token"], :name => "index_oauth_access_tokens_on_refresh_token", :unique => true
add_index "oauth_access_tokens", ["resource_owner_id"], :name => "index_oauth_access_tokens_on_resource_owner_id"
add_index "oauth_access_tokens", ["token"], :name => "index_oauth_access_tokens_on_token", :unique => true
create_table "oauth_applications", :force => true do |t|
t.string "name", :null => false
t.string "uid", :null => false
t.string "secret", :null => false
t.string "redirect_uri", :null => false
t.integer "owner_id"
t.string "owner_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "oauth_applications", ["owner_id", "owner_type"], :name => "index_oauth_applications_on_owner_id_and_owner_type"
add_index "oauth_applications", ["uid"], :name => "index_oauth_applications_on_uid", :unique => true
create_table "platforms", :force => true do |t|
t.string "description"
t.string "name", :null => false
@ -321,7 +281,7 @@ ActiveRecord::Schema.define(:version => 20121203142727) do
create_table "product_build_lists", :force => true do |t|
t.integer "product_id"
t.integer "status", :default => 2, :null => false
t.integer "status", :default => 3, :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "project_id"

View File

@ -0,0 +1,25 @@
module AbfWorker
class RpmWorkerObserver
@queue = :rpm_worker_observer
def self.perform(options)
bl = BuildList.find options['id']
status = options['status'].to_i
case status
when 0
bl.build_success
when 1
bl.build_error
when 3
bl.bs_id = bl.id
bl.save
bl.start_build
end
if status != 3
bl.results = options['results']
bl.save
end
end
end
end

View File

@ -26,7 +26,7 @@ Capistrano::Configuration.instance(:must_exist).load do
end
def start_workers
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer,rpm_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
end
end
end

View File

@ -0,0 +1,32 @@
require 'spec_helper'
describe Api::V1::MaintainersController do
before do
stub_symlink_methods
end
let(:package) { FactoryGirl.create(:build_list_package) }
context 'for guest' do
it "should be able to perform index action", :anonymous_access => true do
get :index, :platform_id => package.platform_id, :format => :json
should render_template(:index)
end
it 'should be able to perform get_id action', :anonymous_access => false do
get :index, :platform_id => package.platform_id, :format => :json
response.status.should == 401
end
end
context 'for simple user' do
before do
http_login(FactoryGirl.create(:user))
end
it "should be able to perform index action" do
get :index, :platform_id => package.platform_id, :format => :json
should render_template(:index)
end
end
end

View File

@ -0,0 +1,34 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
shared_examples_for 'able search with api' do
it 'should be able to search' do
get :index, :format => :json
response.should be_success
response.should render_template(:index)
end
end
shared_examples_for 'not able search with api' do
it 'should not be able to search' do
get :index, :format => :json
response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path)
end
end
describe Api::V1::SearchController do
before { stub_symlink_methods }
context 'as guest' do
if APP_CONFIG['anonymous_access']
it_should_behave_like 'able search with api'
else
it_should_behave_like 'not able search with api'
end
end
context 'as user' do
before {set_session_for FactoryGirl.create(:user)}
it_should_behave_like 'able search with api'
end
end

View File

@ -94,6 +94,11 @@ describe Projects::ProjectsController do
put :update, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@update_params)
response.should redirect_to(new_user_session_path)
end
it 'should not be able to perform create action' do
post :create, @create_params
response.should redirect_to(new_user_session_path)
end
end
context 'registered user' do