[refs #374] Merge master into 374-rest_api_for_builds

This commit is contained in:
konstantin.grabar 2012-08-08 18:21:56 +04:00
commit 0c9f3540f9
89 changed files with 1275 additions and 229 deletions

View File

@ -1,6 +1,6 @@
source 'http://rubygems.org'
gem 'rails', '3.2.6' #, :git => 'git://github.com/rails/rails.git'
gem 'rails', '3.2.7' #, :git => 'git://github.com/rails/rails.git'
gem 'pg', '~> 0.14.0'
# gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1'
@ -31,7 +31,7 @@ gem 'github-linguist', '~> 2.1.2', :require => 'linguist'
gem 'diff-display', '~> 0.0.1'
# Wiki
gem "gollum", "1.3.1"
gem "gollum", :git => 'git://github.com/github/gollum.git'
gem "redcarpet", "1.17.2"
gem 'creole'
gem 'rdiscount'
@ -41,7 +41,7 @@ gem 'wikicloth'
gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
gem 'newrelic_rpm', '~> 3.4.0.1', :platforms => [:mri, :rbx]
gem 'newrelic_rpm', '~> 3.4.1', :platforms => [:mri, :rbx]
gem 'whenever', '~> 0.7.3', :require => false
gem 'jbuilder', '~> 0.4.0'
@ -81,7 +81,7 @@ end
group :test do
gem 'rspec-rails', '~> 2.11.0', :group => 'development'
gem 'factory_girl_rails', '~> 3.5.0'
gem 'factory_girl_rails', '~> 3.6.0'
gem 'rr', '~> 1.0.4'
gem 'shoulda'
end

View File

@ -6,6 +6,23 @@ GIT
redhillonrails_core (2.0.0.pre)
activerecord (>= 3.1.0.rc)
GIT
remote: git://github.com/github/gollum.git
revision: 8422b712048656c8ea391c2d7ef27fb29f66746b
specs:
gollum (2.1.0)
github-markdown
github-markup (>= 0.7.0, < 1.0.0)
grit (~> 2.5.0)
mustache (>= 0.11.2, < 1.0.0)
nokogiri (~> 1.4)
posix-spawn (~> 0.3.0)
pygments.rb (~> 0.2.0)
sanitize (~> 2.0.0)
sinatra (~> 1.0)
stringex (~> 1.4.0)
useragent (~> 0.4.9)
GIT
remote: git://github.com/rdblue/grack.git
revision: 020be3fef3fb308b9d214252522aa5945bf6584a
@ -14,9 +31,9 @@ GIT
GIT
remote: git://github.com/warpc/grit.git
revision: 696b0967cb7e6bac044569d898e5acef431d4f97
revision: f04f779fb052725b964ba259f8073a34e493c0c7
specs:
grit (2.4.1)
grit (2.5.0)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
@ -25,38 +42,36 @@ GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.9)
actionmailer (3.2.6)
actionpack (= 3.2.6)
actionmailer (3.2.7)
actionpack (= 3.2.7)
mail (~> 2.4.4)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
actionpack (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
activemodel (3.2.7)
activesupport (= 3.2.7)
builder (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activerecord (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activesupport (3.2.6)
activeresource (3.2.7)
activemodel (= 3.2.7)
activesupport (= 3.2.7)
activesupport (3.2.7)
i18n (~> 0.6)
multi_json (~> 1.0)
airbrake (3.1.2)
activesupport
builder
albino (1.3.3)
posix-spawn (>= 0.3.6)
ancestry (1.3.0)
activerecord (>= 2.3.14)
arel (3.0.2)
@ -110,10 +125,10 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
expression_parser (0.9.0)
factory_girl (3.5.0)
factory_girl (3.6.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.5.0)
factory_girl (~> 3.5.0)
factory_girl_rails (3.6.0)
factory_girl (~> 3.6.0)
railties (>= 3.0.0)
ffi (1.0.11)
fssm (0.2.9)
@ -122,16 +137,8 @@ GEM
escape_utils (~> 0.2.3)
mime-types (~> 1.18)
pygments.rb (>= 0.2.13)
github-markdown (0.5.0)
github-markup (0.7.4)
gollum (1.3.1)
albino (~> 1.3.2)
github-markup (>= 0.4.0, < 1.0.0)
grit (~> 2.4.1)
mustache (>= 0.11.2, < 1.0.0)
nokogiri (~> 1.4)
redcarpet
sanitize (~> 2.0.0)
sinatra (~> 1.0)
haml (3.1.6)
haml-rails (0.3.4)
actionpack (~> 3.0)
@ -180,7 +187,7 @@ GEM
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
newrelic_rpm (3.4.0.1)
newrelic_rpm (3.4.1)
nokogiri (1.5.5)
omniauth (1.1.0)
hashie (~> 1.2)
@ -216,14 +223,14 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.6)
actionmailer (= 3.2.6)
actionpack (= 3.2.6)
activerecord (= 3.2.6)
activeresource (= 3.2.6)
activesupport (= 3.2.6)
rails (3.2.7)
actionmailer (= 3.2.7)
actionpack (= 3.2.7)
activerecord (= 3.2.7)
activeresource (= 3.2.7)
activesupport (= 3.2.7)
bundler (~> 1.0)
railties (= 3.2.6)
railties (= 3.2.7)
rails-backbone (0.7.2)
coffee-script (~> 2.2.0)
ejs (~> 1.0.0)
@ -232,9 +239,9 @@ GEM
railties (>= 3.0.0)
rails3-jquery-autocomplete (1.0.7)
rails (~> 3.0)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
railties (3.2.7)
actionpack (= 3.2.7)
activesupport (= 3.2.7)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@ -315,6 +322,7 @@ GEM
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
state_machine (1.1.2)
stringex (1.4.0)
systemu (2.5.2)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
@ -335,6 +343,7 @@ GEM
kgio (~> 2.6)
rack
raindrops (~> 0.7)
useragent (0.4.10)
uuid (2.3.5)
macaddr (~> 1.0)
vegas (0.1.11)
@ -367,9 +376,9 @@ DEPENDENCIES
creole
devise (~> 2.1.2)
diff-display (~> 0.0.1)
factory_girl_rails (~> 3.5.0)
factory_girl_rails (~> 3.6.0)
github-linguist (~> 2.1.2)
gollum (= 1.3.1)
gollum!
grack!
grit!
haml-rails (~> 0.3.4)
@ -379,13 +388,13 @@ DEPENDENCIES
jquery-rails (~> 2.0.2)
mailcatcher
meta-tags (~> 1.2.5)
newrelic_rpm (~> 3.4.0.1)
newrelic_rpm (~> 3.4.1)
omniauth (~> 1.1.0)
omniauth-openid (~> 1.0.1)
paperclip (~> 3.1.4)
perform_later (~> 1.3.0)
pg (~> 0.14.0)
rails (= 3.2.6)
rails (= 3.2.7)
rails-backbone (~> 0.7.2)
rails3-generators
rails3-jquery-autocomplete (~> 1.0.7)

BIN
app/assets/images/check.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -1173,6 +1173,144 @@ table.tablesorter tr td.no_results {
}
/* end */
article div.all {
width: 860px;
}
div.inner-columns {
width: 100%;
height: auto;
display: block;
}
div.inner-columns:after {
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
div.inner-columns.equal section {
width: 430px;
float: left;
}
section.first div {
width: 415px;
}
form.inline_errors span.error {
display: inline-block;
color: #FF5050;
}
div.form-actions {
text-align: right;
padding-bottom: 5px;
}
div.form-actions .button {
margin-right: 50px;
}
dl.form, div.form-actions {
margin: 15px 0;
}
dl.form > dt {
margin: 0 0 6px;
}
dl.form > dt label {
color: #333333;
font-size: 14px;
font-weight: bold;
position: relative;
}
dl.form > dd {
margin: 0;
padding: 0;
border: 0, none;
}
dl.form > dd > input[type="text"],
dl.form > dd > input[type="password"],
dl.form > dd > textarea {
width: 350px;
border: 1px solid #A0A0A0;
border-radius: 4px;
padding: 5px;
font-family: Tahoma, Geneva, Helvetica, sans-serif;
font-size: 12px;
}
dl.form > dd > input.error[type="text"],
dl.form > dd > input.error[type="password"],
dl.form > dd > textarea.error {
border-color: #FF8080;
}
dl.form > dd > input[type="text"],
dl.form > dd > input[type="password"] {
height: 16px;
}
dl.form > dd > textarea {
height: 110px;
}
ul.checklist {
font-size: 12px;
font-weight: bold;
margin: 20px 0;
padding: 0;
}
ul.checklist li {
background: image-url("check.png") no-repeat scroll 0 2px transparent;
list-style-type: none;
margin: 15px 0;
padding-left: 25px;
}
div.all.feedback_sended {
background: image-url("feedback.png") no-repeat scroll 49% 0 transparent;
height: 500px;
text-align: center;
}
article div.all.feedback_sended h1 {
font-size: 48px;
font-weight: normal;
margin: 165px 0 0;
padding: 0;
}
article div.all.feedback_sended h2 {
font-size: 18px;
font-weight: normal;
margin: 5px 0 0;
padding: 0;
}
article div.all.feedback_sended p.pages {
margin-top: 70px;
width: 280px;
}
article div.all.feedback_sended p.search {
margin-top: 80px;
width: 230px;
}
article div.all.feedback_sended p {
font-size: 14px;
margin: 0 auto;
padding: 0;
text-align: center;
}
hr.bootstrap {
border: 0;
border-top: 1px solid #eeeeee;

View File

@ -0,0 +1,22 @@
# -*- encoding : utf-8 -*-
class ContactsController < ApplicationController
def new
@form = Feedback.new(current_user)
end
def create
@form = Feedback.new(params[:feedback])
if @form.perform_send
flash[:notice] = I18n.t("flash.contact.success")
redirect_to sended_contact_path
else
flash[:error] = I18n.t("flash.contact.error")
render :new and return
end
end
def sended
end
end

View File

@ -24,4 +24,5 @@ class PagesController < ApplicationController
def tos
end
end

View File

@ -0,0 +1,29 @@
class Platforms::KeyPairsController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :platform, :only => [:index]
load_and_authorize_resource :only => [:create, :destroy]
def create
@key_pair.user_id = current_user.id
if @key_pair.save
flash[:notice] = t('flash.key_pairs.saved')
else
flash[:error] = t('flash.key_pairs.save_error')
flash[:warning] = @key_pair.errors.full_messages.join('. ') unless @key_pair.errors.blank?
end
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
end
def destroy
if @key_pair.destroy
flash[:notice] = t('flash.key_pairs.destroyed')
else
flash[:error] = t('flash.key_pairs.destroy_error')
end
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
end
end

View File

@ -23,8 +23,11 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
end
def destroy
@product_build_list.destroy
flash[:notice] = t('flash.product.build_list_delete')
if @product_build_list.destroy
flash[:notice] = t('flash.product_build_list.delete')
else
flash[:error] = t('flash.product_build_list.delete_error')
end
redirect_to [@platform, @product]
end

View File

@ -41,8 +41,14 @@ class Projects::BuildListsController < Projects::BaseController
def create
notices, errors = [], []
@platform = Platform.find params[:build_list][:save_to_platform_id]
@platform = Platform.includes(:repositories).find params[:build_list][:save_to_platform_id]
@repository = @project.repositories.where(:id => @platform.repository_ids).first
params[:build_list][:save_to_repository_id] = @repository.id
params[:build_list][:auto_publish] = false if @platform.released
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform|
@build_list = @project.build_lists.build(params[:build_list])

View File

@ -14,6 +14,8 @@ module ApplicationHelper
'right bigpadding'
when controller_name == 'platforms' && action_name == 'clone'
'right middlepadding'
when controller_name == 'contacts' && action_name == 'sended'
'all feedback_sended'
else
content_for?(:sidebar) ? 'right' : 'all'
end

View File

@ -54,7 +54,9 @@ module GitHelper
current = url_for(p).split('?', 2).first
res = []
res << [I18n.t('layout.git.repositories.commits'), [params[:treeish].truncate(20)]] unless project.repo.branches_and_tags.map(&:name).include?(params[:treeish] || project.default_branch)
if params[:treeish].present? && !project.repo.branches_and_tags.map(&:name).include?(params[:treeish])
res << [I18n.t('layout.git.repositories.commits'), [params[:treeish].truncate(20)]]
end
linking = Proc.new {|t| [t.name.truncate(20), url_for(p.merge :treeish => t.name).split('?', 2).first]}
res << [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&linking)]
res << [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&linking)]

View File

@ -0,0 +1,34 @@
class FeedbackMailer < ActionMailer::Base
FBM_CONFIG = APP_CONFIG['feedback']
default :to => FBM_CONFIG['email'],
:cc => FBM_CONFIG['cc'],
:bcc => FBM_CONFIG['bcc']
include Resque::Mailer # send email async
def feedback_form_send(form_data)
@data = Feedback.new(form_data)
from = "#{@data.name} <#{@data.email}>"
subj = prepare_subject(@data.subject)
mail :from => from, :subject => subj
end
protected
def prepare_subject(subject)
res = ''
res << affix(FBM_CONFIG['subject_prefixes'])
res << subject
res << affix(FBM_CONFIG['subject_postfixes'])
res = res.strip.gsub(/\s+/, ' ')
res
end
def affix(affixes)
' %s ' % Array(affixes).map{|e| "[#{e}]"}.join
end
end

View File

@ -17,7 +17,7 @@ class Ability
can :archive, Project, :visibility => 'open'
can :read, Issue, :project => {:visibility => 'open'}
can :search, BuildList
can :read, BuildList, :project => {:visibility => 'open'}
can [:read, :everything], BuildList, :project => {:visibility => 'open'}
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
can :read, Advisory
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
@ -62,13 +62,11 @@ class Ability
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
can :remove_user, Project
can [:read, :owned], BuildList, :user_id => user.id
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
can([:create, :update], BuildList) {|build_list|
build_list.project.is_package && can?(:write, build_list.project)
}
can [:read, :owned, :everything], BuildList, :user_id => user.id
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
can [:read, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids}
can([:read, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)}
can(:publish, BuildList) do |build_list|
build_list.save_to_platform.released ? local_admin?(build_list.save_to_platform) : can?(:write, build_list.project)
@ -99,6 +97,8 @@ class Ability
can(:clear, Platform) {|platform| local_admin?(platform) && platform.personal?}
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
can([:create, :destroy], KeyPair) {|key_pair| owner?(key_pair.repository.platform) || local_admin?(key_pair.repository.platform)}
can :read, Product, :platform => {:visibility => 'open'}
can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id, :platform_type => 'main'}
can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids, :platform_type => 'main'}

View File

@ -3,6 +3,7 @@ class BuildList < ActiveRecord::Base
belongs_to :project
belongs_to :arch
belongs_to :save_to_platform, :class_name => 'Platform'
belongs_to :save_to_repository, :class_name => 'Repository'
belongs_to :build_for_platform, :class_name => 'Platform'
belongs_to :user
belongs_to :advisory
@ -13,7 +14,8 @@ class BuildList < ActiveRecord::Base
UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage]
RELEASE_UPDATE_TYPES = %w[security bugfix]
validates :project_id, :project_version, :arch, :include_repos, :presence => true
validates :project_id, :project_version, :arch, :include_repos,
:build_for_platform_id, :save_to_platform_id, :save_to_repository_id, :presence => true
validates_numericality_of :priority, :greater_than_or_equal_to => 0
validates :update_type, :inclusion => UPDATE_TYPES,
:unless => Proc.new { |b| b.advisory.present? }
@ -22,8 +24,12 @@ 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(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
}
LIVE_TIME = 3.week
LIVE_TIME = 4.week # for unpublished
MAX_LIVE_TIME = 3.month # for published
# The kernel does not send these statuses directly
BUILD_CANCELED = 5000
@ -92,7 +98,7 @@ class BuildList < ActiveRecord::Base
s
}
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
scope :outdated, where('updated_at < ? AND status <> ?', Time.now - LIVE_TIME, BUILD_PUBLISHED)
scope :outdated, where('created_at < ? AND status <> ? OR created_at < ?', Time.now - LIVE_TIME, BUILD_PUBLISHED, Time.now - MAX_LIVE_TIME)
serialize :additional_repos
serialize :include_repos
@ -106,14 +112,16 @@ class BuildList < ActiveRecord::Base
# WTF? around_transition -> infinite loop
before_transition do |build_list, transition|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
status = BuildList::HUMAN_STATUSES[build_list.status]
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
end
end
after_transition do |build_list, transition|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status)
MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id
status = BuildList::HUMAN_STATUSES[build_list.status]
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
end
end

View File

@ -52,8 +52,10 @@ class BuildList::Filter
:mass_build_id => nil
}))
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned')
@options[:status] = @options[:status].try(:to_i)
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned')
@options[:status] = @options[:status].present? ? @options[:status].to_i : nil
@options[:created_at_start] = build_date_from_params(:created_at_start, @options)
@options[:created_at_end] = build_date_from_params(:created_at_end, @options)
@options[:updated_at_start] = build_date_from_params(:updated_at_start, @options)
@options[:updated_at_end] = build_date_from_params(:updated_at_end, @options)
@options[:project_version] = @options[:project_version].presence

104
app/models/feedback.rb Normal file
View File

@ -0,0 +1,104 @@
# This class is based on
# https://github.com/rails/rails/blob/4da6e1cce2833474034fda0cbb67b2cc35e828da/activerecord/lib/active_record/validations.rb
class Feedback
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
include ActiveModel::MassAssignmentSecurity
extend ActiveModel::Naming
attr_accessor :name, :email, :subject, :message
attr_accessible :name, :email, :subject, :message
validates :name, :subject, :message, :presence => true
validates :email, :presence => true,
:format => { :with => /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/,
:allow_blank => false }
def initialize(args = {}, options = {})
return args.dup if args.is_a? Feedback
if args.respond_to? :name and args.respond_to? :email
self.name, self.email = args.name, args.email
elsif args.respond_to? :each_pair
sanitize_for_mass_assignment(args, options[:as]).each_pair do |k, v|
send("#{k}=", v)
end
else
return false
end
end
# FIXME: Maybe rename to `save`?
def perform_send(options = {})
perform_validations(options) ? real_send : false
end
def perform_send!(options={})
perform_validations(options) ? real_send : raise(ActiveRecord::RecordInvalid.new(self))
end
def new_record?
true
end
def persisted?
false
end
def message_with_links
message.to_s.dup.auto_link
end
def attributes
%w{ name email subject message }.inject({}) do |h, e|
h.merge(e => send(e))
end
end
def to_s
str = %w{ name email subject message }.map do |e|
"#{e}: #{ send(e).inspect }"
end.join(', ')
return "#<#{self.class} #{str}>"
end
class << self
def create(attributes = nil, options = {}, &block)
do_create(attributes, options, false, &block)
end
def create!(attributes = nil, options = {}, &block)
do_create(attributes, options, true, &block)
end
protected
def do_create(attributes = nil, options = {}, bang = false, &block)
if attributes.is_a?(Array)
attributes.collect { |attr| do_create(attr, options, bang, &block) }
else
object = new(attributes, options)
yield(object) if block_given?
bang ? object.perform_send! : object.perform_send
object
end
end
end
protected
def real_send
FeedbackMailer.feedback_form_send(self).deliver
end
def perform_validations(options={})
perform_validation = options[:validate] != false
perform_validation ? valid?(options[:context]) : true
end
end
Feedback.include_root_in_json = false

35
app/models/key_pair.rb Normal file
View File

@ -0,0 +1,35 @@
class KeyPair < ActiveRecord::Base
belongs_to :repository
belongs_to :user
attr_accessor :secret
attr_accessible :public, :secret, :repository_id
validates :repository_id, :public, :user_id, :presence => true
validates :secret, :presence => true, :on => :create
validates :repository_id, :uniqueness => {:message => I18n.t("activerecord.errors.key_pair.repo_key_exists")}
before_create :key_create_call
before_destroy :rm_key_call
protected
def key_create_call
result, self.key_id = BuildServer.import_gpg_key_pair(public, secret)
raise "Failed to create key_pairs for repository #{repository_id} with code #{result}." if result == 4
if result != 0 || self.key_id.nil?
errors.add(:public, I18n.t("activerecord.errors.key_pair.rpc_error_#{result}"))
return false
end
result = BuildServer.set_repository_key(repository.platform.name, repository.name, self.key_id)
raise "Failed to sign repository #{repository.name} in platform #{repository.platform.name}
using key_id #{self.key_id} with code #{result}." unless result.zero?
end
def rm_key_call
result = BuildServer.rm_repository_key(repository.platform.name, repository.name)
raise "Failed to desroy repository key #{repository.name} in platform
#{repository.platform.name} with code #{result}." unless result.zero?
end
end

View File

@ -4,6 +4,7 @@ class MassBuild < ActiveRecord::Base
has_many :build_lists, :dependent => :destroy
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
attr_accessor :repositories, :arches
attr_accessible :repositories, :arches, :auto_publish

View File

@ -180,7 +180,7 @@ class Platform < ActiveRecord::Base
arches.map(&:name).each do |arch|
begin
return if mass_build.reload.stop_build
p.build_for(self, user, arch, auto_publish, mass_build_id)
p.build_for(self, rep.id, user, arch, auto_publish, mass_build_id)
rescue RuntimeError, Exception
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
end

View File

@ -31,6 +31,7 @@ class ProductBuildList < ActiveRecord::Base
scope :recent, order("#{table_name}.updated_at DESC")
after_create :xml_rpc_create
before_destroy :can_destroy?
after_destroy :xml_delete_iso_container
def container_path
@ -49,6 +50,10 @@ class ProductBuildList < ActiveRecord::Base
self.class.human_status(status)
end
def can_destroy?
[BUILD_COMPLETED, BUILD_FAILED].include? status
end
protected
def xml_rpc_create

View File

@ -23,10 +23,11 @@ class Project < ActiveRecord::Base
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/, :message => I18n.t("activerecord.errors.project.uname")}
validates :owner, :presence => true
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki
attr_readonly :name
attr_readonly :name, :owner_id, :owner_type
scope :recent, order("name ASC")
scope :search_order, order("CHAR_LENGTH(name) ASC")
@ -83,13 +84,13 @@ class Project < ActiveRecord::Base
owner == user
end
def build_for(platform, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0)
def build_for(platform, repository_id, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0)
# Select main and project platform repository(contrib, non-free and etc)
# If main does not exist, will connect only project platform repository
# If project platform repository is main, only main will be connect
build_reps = [platform.repositories.find_by_name('main')]
build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id}
build_reps_ids = build_reps.compact.map(&:id).uniq
main_rep_id = platform.repositories.find_by_name('main').id
build_reps_ids = [main_rep_id, repository_id].compact.uniq
arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
build_lists.create do |bl|
bl.save_to_platform = platform
@ -103,6 +104,7 @@ class Project < ActiveRecord::Base
bl.include_repos = build_reps_ids
bl.priority = priority
bl.mass_build_id = mass_build_id
bl.save_to_repository_id = repository_id
end
end

View File

@ -4,6 +4,7 @@ class Repository < ActiveRecord::Base
has_many :project_to_repositories, :dependent => :destroy, :validate => true
has_many :projects, :through => :project_to_repositories
has_one :key_pair, :dependent => :destroy
validates :description, :presence => true
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /^[a-z0-9_\-]+$/}

View File

@ -35,6 +35,8 @@ class User < ActiveRecord::Base
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
has_many :key_pairs
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true
validate { errors.add(:uname, :taken) if Group.by_uname(uname).present? }
validates :role, :inclusion => {:in => ROLES}, :allow_blank => true

View File

@ -0,0 +1,48 @@
- set_meta_tags :title => t('layout.contact.page_header')
%h1= t("layout.contact.header")
%p= t("layout.contact.subheader")
%hr.bootstrap
.inner-columns.equal
%section.first
%div
= form_for @form, :url => contact_path, :html => {:class => 'inline_errors'} do |f|
%dl.form
%dt= f.label :name, t("activerecord.attributes.user.name")
%dd
= f.text_field :name, :placeholder => t("layout.contact.placeholders.name"),
:class => @form.errors.messages[:name].present? ? 'error' : ''
%dl.form
%dt= f.label :email, t("activerecord.attributes.user.email")
%dd
= f.text_field :email, :placeholder => t("layout.contact.placeholders.email"),
:class => @form.errors.messages[:email].present? ? 'error' : ''
%dl.form
%dt= f.label :subject, t("layout.contact.subject")
%dd
= f.text_field :subject, :placeholder => t("layout.contact.placeholders.subject"),
:class => @form.errors.messages[:subject].present? ? 'error' : ''
%dl.form
%dt= f.label :message, t("layout.contact.message")
%dd
= f.text_area :message, :placeholder => t("layout.contact.placeholders.message"),
:class => @form.errors.messages[:message].present? ? 'error' : ''
.form-actions
= f.submit t("layout.contact.send_request"), :class => 'button'
%section.last
%div
%h3= t("layout.contact.info.header")
%ul.checklist
- t("layout.contact.info.items").try(:each) do |item|
%li= item
%hr.bootstrap
%p= t("layout.contact.questions_info")

View File

@ -0,0 +1,8 @@
%h1= t("layout.contact.thanks")
%h2= t("layout.contact.thanks_2")
%p.pages
= t("layout.contact.open_pages")
%p.search
= t("layout.contact.use_search")
.both

View File

@ -0,0 +1,7 @@
!!!
%html
%head
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
%body
= simple_format @data.message_with_links

View File

@ -0,0 +1 @@
<%= @data.message.chomp %>

View File

@ -14,3 +14,6 @@
%li
= image_tag 'square.png'
= link_to t('bottom_menu.tos'), tos_url #t('bottom_menu.tos_url')
%li
= image_tag 'square.png'
= link_to t('bottom_menu.support'), contact_url

View File

@ -25,6 +25,9 @@
- if can? :members, @platform
%li{:class => (act == :members && contr == :platforms) ? 'active' : nil}
= link_to t("layout.platforms.members"), members_platform_path(@platform)
- if can? :edit, @platform
%li{:class => (act == :index && contr == :key_pairs) ? 'active' : ''}
= link_to t("layout.key_pairs.header"), platform_key_pairs_path(@platform)
-#- if current_user.owner_of? @platform or current_user.admin?
%li{:class => (act == :index && contr == :private_users) ? 'active' : ''}
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform)

View File

@ -0,0 +1,18 @@
%table#myTable.tablesorter.platform-repos{:cellspacing => "0", :cellpadding => "0"}
%thead
%tr
%th.th1= t("activerecord.attributes.key_pair.repository_id")
%th.th2= t("activerecord.attributes.key_pair.key_id")
%th.th3= t("activerecord.attributes.key_pair.user_id")
%th= t("layout.delete")
%tbody
- @platform.repositories.each do |repository|
- if repository.key_pair
%tr{:class => cycle("odd", "even")}
%td= repository.name
%td= repository.key_pair.key_id
%td= link_to repository.key_pair.user.fullname, user_path(repository.key_pair.user)
%td.buttons
- if can? :destroy, repository.key_pair
= link_to platform_key_pair_path(@platform, repository.key_pair), :method => :delete, :confirm => t("layout.key_pairs.confirm_delete") do
%span.delete &nbsp;

View File

@ -0,0 +1,17 @@
= render 'platforms/base/sidebar'
%h3= t("layout.key_pairs.header")
= form_for :key_pair, :url => platform_key_pairs_path(@platform), :method => :post, :html => { :class => :form } do |f|
.leftlist= f.label :public, t("activerecord.attributes.key_pair.public"), :class => :label
.rightlist= f.text_area :public, :class => 'text_field resizable', :cols => 80
.both
.leftlist= f.label :secret, t("activerecord.attributes.key_pair.secret"), :class => :label
.rightlist= f.text_area :secret, :class => 'text_field resizable', :cols => 80
.both
.leftlist= f.label :repository_id, t("activerecord.attributes.key_pair.repository_id"), :class => :label
.rightlist= f.select :repository_id, options_from_collection_for_select(@platform.repositories, 'id', 'name')
.both
.button_block
= submit_tag t("layout.save")

View File

@ -0,0 +1,2 @@
= render 'new' if can? :edit, @platform
= render 'list'

View File

@ -37,13 +37,13 @@
- @mass_builds.each do |mass_build|
%tr
%td= mass_build.id
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'})
%td.min_width_120
- MassBuild::COUNT_STATUSES.each do |status|
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
= mass_build.read_attribute "#{status}_count"
.both
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build)
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build)
%td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build)
%td
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")

View File

@ -3,5 +3,6 @@
%td= product_build_list.human_status
%td= link_to nil, product_build_list.container_path
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => :delete, :confirm => t("layout.confirm") if can? :destroy, product_build_list
- pbl = product_build_list
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
%td= l(product_build_list.updated_at, :format => :long)

View File

@ -0,0 +1,6 @@
- if project.description.present?
.description
%h3= t("layout.projects.about_subheader")
%p
= project.description
-# link_to t('layout.read_more'), '#'

View File

@ -1,11 +1,6 @@
= render 'submenu'
= render 'repo_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
= render 'about_block', :project => @project
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -13,6 +13,6 @@
%li= link_to t("project_menu.tracker"), project_issues_path(@project), :class => (contr == :issues ? 'active' : nil)
- if @project.has_wiki
%li= link_to t("project_menu.wiki"), project_wiki_index_path(@project), :class => (contr == :wiki ? 'active' : nil)
%li= link_to t("project_menu.readme"), "#" #pending
%li=# link_to t("project_menu.readme"), "#" #pending
- if can? :update, @project
%li= link_to t("project_menu.settings"), edit_project_path(@project), :class => (act == :edit && contr == :projects ? 'active' : nil)

View File

@ -3,6 +3,6 @@
%td= build_list.human_status
%td= link_to build_list.project.name_with_owner, build_list.project
%td= build_list_version_link(build_list)
%td= link_to build_list.save_to_platform.name, build_list.save_to_platform
%td= link_to "#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}", [build_list.save_to_platform, build_list.save_to_repository]
%td= build_list.arch.name
%td= link_to build_list.user.try(:fullname), build_list.user

View File

@ -31,8 +31,8 @@
.lefter= t("layout.build_lists.ownership.related")
.both
.table
.lefter= f.radio_button :ownership, 'index', :class => 'niceRadio', :id => 'myradio3'
.lefter= t("layout.build_lists.ownership.index")
.lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3'
.lefter= t("layout.build_lists.ownership.everything")
.both
%br
= f.submit t("layout.search.header")

View File

@ -7,7 +7,7 @@
%th.lpadding16= t("activerecord.attributes.build_list.status")
%th.lpadding16= t("activerecord.attributes.build_list.project")
%th.lpadding16= t("activerecord.attributes.build_list.project_version")
%th.lpadding16= t("activerecord.attributes.build_list.save_to_platform")
%th.lpadding16= t("activerecord.attributes.build_list.save_to_repository")
%th.lpadding16= t("activerecord.attributes.build_list.arch")
%th.lpadding16= t("activerecord.attributes.build_list.user")
%tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists

View File

@ -9,7 +9,9 @@
.leftlist= t("activerecord.attributes.build_list.container_path")
.rightlist
- if @build_list.status == BuildList::BUILD_PUBLISHED
= t("layout.build_lists.container_published")
= raw "%s %s" % [t("layout.build_lists.container_published"),
link_to("#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}",
[@build_list.save_to_platform, @build_list.save_to_repository])]
- elsif @build_list.container_path.present?
- container_url = "http://#{request.host_with_port}/downloads#{@build_list.container_path}"
= link_to container_url, container_url
@ -26,9 +28,9 @@
.rightlist
= link_to @build_list.build_for_platform.name, @build_list.build_for_platform
.both
.leftlist= t("activerecord.attributes.build_list.save_to_platform")
.leftlist= t("activerecord.attributes.build_list.save_to_repository")
.rightlist
= link_to @build_list.save_to_platform.name, @build_list.save_to_platform
= link_to "#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}", [@build_list.save_to_platform, @build_list.save_to_repository]
.both
.leftlist= t("activerecord.attributes.build_list.include_repos")
.rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ')

View File

@ -4,5 +4,5 @@
%td.blob
:plain
<br/>
<pre>#{link_to @blob.basename, raw_path(@project, @treeish, @path)}</pre>
<pre>#{link_to_unless @blob.huge?, @blob.basename, raw_path(@project, @treeish, @path)}</pre>
<br/>

View File

@ -12,8 +12,9 @@
- if @blob.render_as == :text && params[:action] != 'show'
= link_to "Normal", blob_path(@project, @treeish, @path)
\|
= link_to "Raw", raw_path(@project, @treeish, @path)
\|
- unless @blob.huge?
= link_to "Raw", raw_path(@project, @treeish, @path)
\|
- if @blob.render_as == :text && params[:action] != 'blame'
= link_to "Blame", blame_path(@project, @treeish, @path)
\|

View File

@ -1,12 +1,8 @@
-set_meta_tags :title => "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}"
= render 'submenu'
= render 'repo_block', :project => @project
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -1,11 +1,7 @@
-set_meta_tags :title => [title_object(@project), shortest_hash_id(@commit.id), @commit.message]
= render 'submenu'
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -1,29 +1,64 @@
-set_meta_tags :title => title_object(@project)
= render 'submenu'
= render 'repo_block', :project => @project
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
.both
#repo-wrapper
- if @project.parent_id.present? || @project.srpm.exists?
.both
#repo-wrapper
%h3= t("layout.projects.files_in_project")
.files
.l= render 'whereami'
.both
%table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.th1= t("layout.projects.filename")
%th.th2= t("layout.projects.age")
%th.th3= t("layout.projects.message")
%th.th4= t("layout.projects.author")
%tbody
%tr
%td.centered{:colspan => 4}
%h3= I18n.t("layout.git.repositories.empty")
- else
- if current_user
%h3= t("layout.projects.git_global_setup")
%p
%code
= "git config --global user.name #{current_user.fullname}"
%br/
= "git config --global user.email #{current_user.email}"
%br/
git config --global http.postBuffer 524288000
%h3= t("layout.projects.create_repository")
%p
%code
= "git clone #{git_repo_url(@project.git_repo_name)}"
%br/
= "cd #{@project.name}"
%br/
%br/
%p= t("layout.projects.move_files_to_folder")
%br/
%code
git add .
%br/
git commit -m 'description message'
%br/
git push -u origin master
%h3= t("layout.projects.existing_git_repo")
%p
%code
cd existing_git_repo
%br/
= "git remote add origin #{git_repo_url(@project.git_repo_name)}"
%br/
git push -u origin master
%table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.th1= t("layout.projects.filename")
%th.th2= t("layout.projects.age")
%th.th3= t("layout.projects.message")
%th.th4= t("layout.projects.author")
%tbody
%tr
%td.centered{:colspan => 4}
%h3= I18n.t("layout.git.repositories.empty")

View File

@ -6,7 +6,7 @@ srpm_path=$1
git_path=$2
git_branch=$3
name=$(rpm -q --qf '[%{Name}]' -p $srpm_path)
version=$(rpm -q --qf '[%{Version}]' -p $srpm_path)
version=$(rpm -q --qf '[%{Version}-%{Release}]' -p $srpm_path)
tmp_dir=/tmp/$name-$version-$RANDOM
# Clone destination repo

View File

@ -48,7 +48,7 @@ module Rosa
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
config.filter_parameters += [:password, :secret]
# Enable the asset pipeline
config.assets.enabled = true

View File

@ -62,7 +62,7 @@ Rosa::Application.configure do
config.assets.digest = true
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js)
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js)
end
# require 'stub_xml_rpc'

View File

@ -17,6 +17,7 @@ en:
contacts_url: http://www.rosalab.com/about/contacts
tos: Terms Of Service
tos_url: http://www.rosalab.com/about
support: Support
project_menu:
project: Project
commits: Commits

View File

@ -17,6 +17,7 @@ ru:
contacts_url: http://www.rosalab.ru/about/contacts
tos: Условия использования
tos_url: http://www.rosalab.ru/about
support: Служба поддержки
project_menu:
project: Проект
commits: Коммиты

View File

@ -19,6 +19,7 @@ en:
include_repos: Included repositories
created_at: Created on
save_to_platform: Platform
save_to_repository: Repository
build_for_platform: Build for platform
update_type: Update type
build_requires: Build with all the required packages
@ -82,7 +83,7 @@ en:
header: Build list ownership
owned: My
related: Related
index: All
everything: All
build_server_status:
header: Build server status
@ -127,5 +128,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_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"
frozen_platform: In case of a repository for package storage with frozen platform allowed only bugfix and security updates

View File

@ -19,6 +19,7 @@ ru:
include_repos: Подключаемые репозитории
created_at: Создан
save_to_platform: Платформа
save_to_repository: Репозиторий
build_for_platform: Собрано для платформы
update_type: Критичность обновления
build_requires: Пересборка с зависимостями
@ -79,7 +80,7 @@ ru:
header: Принадлежность заданий
owned: Мне
related: Связанные со мной
index: Все
everything: Все
build_server_status:
header: Статус сборочного сервера
@ -124,5 +125,7 @@ ru:
no_project_version_found: Выбранная версия '%{project_version}' не найдена
no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу
wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа!
wrong_repository: Репозиторий для сохранения должен принадлежать платформе.
cannot_write: Вы не можете собирать пакет в этот репозиторий.
can_not_published: Опубликовать сборку можно только со статусом "Собран"
frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления

View File

@ -0,0 +1,34 @@
en:
layout:
contact:
page_header: Contact us
header: Contact us
subheader: Were here to help with any questions or comments.
send_request: Send Request
thanks: Thanks for feedback!
thanks_2: Your request in progress.
open_pages: Please, continue your work
use_search: Try to find something cool?
placeholders:
name: Your name
email: user@example.com
subject: I want to say about ...
message: Problem description
subject: Subject
message: Message
questions_info: If you need help with a project hosted on ABF, please contact the project's owner.
info:
header: What's in a great support request?
items:
- "Be succinct, we'll ask if we need more info"
- "The name of the user, repository, build list etc youre having troubles with"
flash:
contact:
success: Request successfully sended
error: Sending request failed

View File

@ -0,0 +1,34 @@
ru:
layout:
contact:
page_header: Обратная связь
header: Свяжитесь с нами
subheader: Мы готовы помочь вам с любыми вопросами и комментариями.
send_request: Отправить запрос
thanks: Спасибо за сообщение!
thanks_2: Мы уже начали работу.
open_pages: Продолжайте работу с системой
use_search: Воспользуйтесь поиском
placeholders:
name: Ваше имя
email: user@example.com
subject: Я хочу сказать о...
message: Описание проблемы
subject: Тема сообщения
message: Сообщение
questions_info: Если вам нужна помощь с проектом, размещенным на ABF, пожалуйста, свяжитесь с владельцем проекта.
info:
header: Каким должен быть хороший запрос?
items:
- "Будьте кратки. Если нам понадобится дополнительная информация, мы ее запросим."
- "Укажите, с чем у вас возникла проблема: имя пользователя, репозиторий, сборочный лист и т.д."
flash:
contact:
success: Запрос успешно отправлен
error: Не удалось отправить запрос

View File

@ -0,0 +1,35 @@
en:
layout:
key_pairs:
repository_id: Repository
user_id: User
public: Public key
secret: Secret key
confirm_delete: Are you sure you want to delete this signature?
header: Signatures
flash:
key_pairs:
saved: Repository successfully signed
save_error: Signature save error
destroyed: Signature succefully destroyed
destroy_error: Signature destroy error
activerecord:
errors:
key_pair:
repo_key_exists: Repository has been signed already! Please remove old signature and try again
rpc_error_0: an unexpected error
rpc_error_1: could not import public key
rpc_error_2: could not import secret key
rpc_error_3: keys are imported, but it is not a key pair (ids differ)
models:
key_pair: Key Pair
attributes:
key_pair:
id: Id
created_at: Created
updated_at: Updated
user_id: User
repository_id: Repository
public: Public key
secret: Secret key
key_id: Signature

View File

@ -0,0 +1,35 @@
ru:
layout:
key_pairs:
repository_id: Репозиторий
user_id: Пользователь
public: Публичный ключ
secret: Секретный ключ
confirm_delete: Вы уверены, что хотите удалить подпись?
header: Подписи
flash:
key_pairs:
saved: Репозиторий успешно подписан
save_error: Ошибка создания подписи
destroyed: Подпись успешно удалена
destroy_error: Ошибка удаления подписи
activerecord:
errors:
key_pair:
repo_key_exists: Репозиторий уже подписан! Пожалуйста, удалите старую подпись и попробуйте снова
rpc_error_0: Неизвестная ошибка
rpc_error_1: Проблемы с импортром публичного ключа
rpc_error_2: Проблемы с импортром секретного ключа
rpc_error_3: Ключи импортированы, но не являются парой (идентификаторы не совпадают)
models:
key_pair: Подпись
attributes:
key_pair:
id: Id
created_at: Создано
updated_at: Обновлено
user_id: Пользователь
repository_id: Репозиторий
public: Публичный ключ
secret: Секретный ключ
key_id: Подпись

View File

@ -33,7 +33,6 @@ en:
save_error: Unable to save product
build_started: Product build started
destroyed: Product deleted
build_list_delete: Product build list deleted
activerecord:
models:

View File

@ -33,7 +33,6 @@ ru:
save_error: Не удалось сохранить изменения
build_started: Запущена сборка продукта
destroyed: Продукт удален
build_list_delete: Сборочный лист продукта удален
activerecord:
models:

View File

@ -25,6 +25,10 @@ en:
product: Product
container_path: Container
status: Status
notified_at: Notified at
user: User
notified_at: Notified at
flash:
product_build_list:
delete: Product build list deleted
delete_error: Unable to delete product build list

View File

@ -28,3 +28,8 @@ ru:
user: Пользователь
notified_at: Информация получена
flash:
product_build_list:
delete: Сборочный лист продукта удален
delete_error: Не удалось удалить cборочный лист продукта

View File

@ -34,6 +34,10 @@ en:
has_issue_description: Tracker adds a lightweight issue management system tightly integrated with your repository.
has_wiki_description: Wikis are the simplest way to allow other users to contribute content. Any user can create and edit pages for documentation, examples, support or anything you wish.
human_average_build_time: Expected time is %{hours} h. %{minutes} min.
git_global_setup: Git global setup
create_repository: Create Repository
move_files_to_folder: Move files you need to the project or create them.
existing_git_repo: Git repo already exist?
git_help:
cloning: Cloning the repository

View File

@ -34,6 +34,10 @@ ru:
has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта.
has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость.
human_average_build_time: 'Ожидаемое время: %{hours} ч. %{minutes} мин.'
git_global_setup: Общие настройки Git
create_repository: Создание репозитория
move_files_to_folder: Переместите нужные файлы в проект или создайте их.
existing_git_repo: Git репозиторий уже существует?
diff_show_header: "%{files} с %{additions} и %{deletions}."
about_subheader: "О проекте"

View File

@ -1,5 +1,10 @@
# -*- encoding : utf-8 -*-
Rosa::Application.routes.draw do
resource :contact, :only => [:new, :create, :sended] do
get '/' => 'contacts#new'
get :sended
end
devise_scope :users do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
@ -19,9 +24,9 @@ Rosa::Application.routes.draw do
resources :search, :only => [:index]
get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
get '/terms-of-service' => 'pages#tos', :as => 'tos'
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
get '/terms-of-service' => 'pages#tos', :as => 'tos'
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/
if APP_CONFIG['anonymous_access']
@ -84,6 +89,7 @@ Rosa::Application.routes.draw do
get :projects_list
end
end
resources :key_pairs, :only => [:create, :index, :destroy]
resources :products do
resources :product_build_lists, :only => [:create, :destroy]
end

View File

@ -4,7 +4,7 @@ base_path = "/srv/rosa_build"
rails_env = ENV['RAILS_ENV'] || 'production'
worker_processes 4
worker_processes 8
working_directory File.join(base_path, 'current') # available in 0.94.0+
# listen File.join(base_path, 'tmp', 'pids', 'unicorn.sock')

View File

@ -0,0 +1,11 @@
class CreateKeyPairs < ActiveRecord::Migration
def change
create_table :key_pairs do |t|
t.integer :repository_id
t.integer :user_id
t.integer :key_id
t.string :public
t.timestamps
end
end
end

View File

@ -0,0 +1,26 @@
class AddSaveToRepositoryToBuildLists < ActiveRecord::Migration
def self.up
add_column :build_lists, :save_to_repository_id, :integer
BuildList.scoped.includes(:project => :repositories, :save_to_platform => :repositories).find_in_batches do |batch|
batch.each do |bl|
begin
project = bl.project
platform = bl.save_to_platform
rep = (project.repositories.map(&:id) & platform.repositories.map(&:id)).first
bl.save_to_repository_id = rep
bl.save!
rescue Exception => e
puts e.inspect
false
end
end
end
end
def self.down
remove_column :build_lists, :save_to_repository_id
end
end

View File

@ -0,0 +1,9 @@
class SetTextTypeForKeyPairsPublic < ActiveRecord::Migration
def up
change_column :key_pairs, :public, :text
end
def down
change_column :key_pairs, :public, :string
end
end

View File

@ -0,0 +1,9 @@
class SetStringTypeForKeyPairsKeyid < ActiveRecord::Migration
def up
change_column :key_pairs, :key_id, :string
end
def down
change_column :key_pairs, :key_id, :integer
end
end

View File

@ -0,0 +1,17 @@
class DisableNullValueForKeyPairs < ActiveRecord::Migration
def up
change_column_null :key_pairs, :repository_id, false
change_column_null :key_pairs, :user_id, false
change_column_null :key_pairs, :key_id, false
change_column_null :key_pairs, :public, false
add_index :key_pairs, :repository_id, :unique => true
end
def down
change_column_null :key_pairs, :repository_id, true
change_column_null :key_pairs, :user_id, true
change_column_null :key_pairs, :key_id, true
change_column_null :key_pairs, :public, true
remove_index :key_pairs, :repository_id
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120719045806) do
ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -107,8 +107,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.integer "project_id"
t.integer "arch_id"
t.datetime "notified_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "is_circle", :default => false
t.text "additional_repos"
t.string "name"
@ -126,6 +126,7 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.integer "duration"
t.integer "advisory_id"
t.integer "mass_build_id"
t.integer "save_to_repository_id"
end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"
@ -137,8 +138,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "commentable_type"
t.integer "user_id"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id"
end
@ -155,8 +156,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "controller"
t.string "action"
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "flash_notifies", :force => true do |t|
@ -168,10 +169,12 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.datetime "updated_at", :null => false
end
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
create_table "groups", :force => true do |t|
t.integer "owner_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "uname"
t.integer "own_projects_count", :default => 0, :null => false
t.text "description"
@ -184,8 +187,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "title"
t.text "body"
t.string "status", :default => "open"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
t.datetime "closed_at"
t.integer "closed_by"
@ -193,6 +196,17 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true
create_table "key_pairs", :force => true do |t|
t.integer "repository_id", :null => false
t.integer "user_id", :null => false
t.string "key_id", :null => false
t.text "public", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "key_pairs", ["repository_id"], :name => "index_key_pairs_on_repository_id", :unique => true
create_table "labelings", :force => true do |t|
t.integer "label_id", :null => false
t.integer "issue_id"
@ -234,8 +248,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "description"
t.string "name", :null => false
t.integer "parent_platform_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "released", :default => false, :null => false
t.integer "owner_id"
t.string "owner_type"
@ -250,16 +264,16 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.integer "platform_id"
t.string "login"
t.string "password"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
end
create_table "product_build_lists", :force => true do |t|
t.integer "product_id"
t.integer "status", :default => 2, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
@ -267,8 +281,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
create_table "products", :force => true do |t|
t.string "name", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "build_script"
t.text "counter"
t.text "ks"
@ -287,8 +301,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "name"
t.string "version"
t.datetime "file_mtime"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "platform_id"
end
@ -297,25 +311,25 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
create_table "project_to_repositories", :force => true do |t|
t.integer "project_id"
t.integer "repository_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "projects", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
t.text "description"
t.string "ancestry"
t.boolean "has_issues", :default => true
t.boolean "has_wiki", :default => false
t.string "srpm_file_name"
t.string "srpm_content_type"
t.integer "srpm_file_size"
t.datetime "srpm_updated_at"
t.boolean "has_wiki", :default => false
t.string "default_branch", :default => "master"
t.boolean "is_package", :default => true, :null => false
t.integer "average_build_time", :default => 0, :null => false
@ -330,8 +344,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "token"
t.boolean "approved", :default => false
t.boolean "rejected", :default => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "interest"
t.text "more"
end
@ -344,16 +358,16 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "actor_type"
t.integer "target_id"
t.string "target_type"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "role"
end
create_table "repositories", :force => true do |t|
t.string "description", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name", :null => false
end
@ -364,8 +378,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.boolean "new_comment_reply", :default => true
t.boolean "new_issue", :default => true
t.boolean "issue_assign", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "new_comment_commit_owner", :default => true
t.boolean "new_comment_commit_repo_owner", :default => true
t.boolean "new_comment_commit_commentor", :default => true
@ -374,8 +388,8 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
create_table "subscribes", :force => true do |t|
t.string "subscribeable_type"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "status", :default => true
t.integer "project_id"
t.decimal "subscribeable_id", :precision => 50, :scale => 0
@ -383,16 +397,16 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
create_table "users", :force => true do |t|
t.string "name"
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "uname"
t.string "role"
t.string "language", :default => "en"
t.datetime "reset_password_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.text "professional_experience"
t.string "site"
@ -402,14 +416,14 @@ ActiveRecord::Schema.define(:version => 20120719045806) do
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.integer "failed_attempts", :default => 0
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "authentication_token"
t.integer "build_priority", :default => 50
t.integer "build_priority", :default => 50
end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token"

View File

@ -25,4 +25,6 @@ sudo urpmi lib64magic-devel # mandriva
brew install libmagic; brew link libmagic # brew
gem install ruby-filemagic
sudo urpmi python-devel
git config --global core.quotepath false

View File

@ -87,11 +87,11 @@ class BuildServer
# raise include_repos_hash.inspect
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos_hash, priority)
end
def self.delete_build_list idlist
self.client.call('delete_build_list', idlist)
end
def self.get_status
self.client.call('get_status')
end
@ -99,4 +99,17 @@ class BuildServer
def self.freeze platform_name
self.client.call('freeze_platform', platform_name)
end
# Repository key pair calls
def self.import_gpg_key_pair key_pub, key_secret
self.client.call('import_gpg_key_pair', key_pub, key_secret)
end
def self.set_repository_key platform, repository, key_id
self.client.call('set_repository_key', platform, repository, key_id)
end
def self.rm_repository_key platform, repository
self.client.call('rm_repository_key', platform, repository)
end
end

View File

@ -15,9 +15,10 @@ class String
encode!(Encoding::UTF_16, default_encoding, options).encode!(default_encoding, Encoding::UTF_16)
raise unless valid_encoding? # check result
end
self
rescue
replace "--broken encoding: #{detect_encoding[:encoding] || 'unknown'}"
ensure
self
# ensure
# return self
end
end

View File

@ -7,7 +7,7 @@ module Grit
MAX_DATA_SIZE = 50.megabytes
def data_with_limit
size <= MAX_DATA_SIZE ? data_without_limit : nil # 'Error: blob is too big'
!huge? ? data_without_limit : nil # 'Error: blob is too big'
end
alias_method_chain :data, :limit
@ -15,6 +15,10 @@ module Grit
size.to_i > MAX_VIEW_SIZE
end
def huge?
size.to_i > MAX_DATA_SIZE
end
def render_as
@render_as ||= case
when large?; :binary

View File

@ -21,11 +21,10 @@ module Rosa
class Treeish
def self.matches?(request)
params = request.path_parameters
if params[:treeish] # parse existing branch (tag) and path
if (params = request.path_parameters) && params[:treeish] # parse existing branch (tag) and path
branch_or_tag = begin
(p = Project.find_by_owner_and_name params[:owner_name], params[:project_name]) &&
p.repo.branches_and_tags.detect{|t| params[:treeish].start_with?(t.name)}.try(:name) ||
p.repo.branches_and_tags.map(&:name).sort{|a,b| b.length <=> a.length}.detect{|b| params[:treeish].start_with?(b)} ||
params[:treeish].split('/').first
end
if path = params[:treeish].sub(branch_or_tag, '')[1..-1] and path.present?

View File

@ -5,7 +5,7 @@ module Modules
extend ActiveSupport::Concern
included do
after_create :create_wiki
after_save :create_wiki
after_destroy :destroy_wiki
end

View File

@ -2,15 +2,19 @@
namespace :buildlist do
namespace :clear do
desc 'Remove outdated unpublished BuildLists'
desc 'Remove outdated BuildLists and MassBuilds'
task :outdated => :environment do
say "Removing outdated BuildLists"
outdated = BuildList.outdated
say "There are #{outdated.count} outdated BuildLists at #{Time.now}"
BuildList.outdated.destroy_all
say "Outdated BuildLists was successfully removed"
say "Removing outdated MassBuilds"
outdated = MassBuild.outdated
say "There are #{outdated.count} outdated MassBuilds at #{Time.now}"
MassBuild.outdated.destroy_all
say "Outdated BuildLists and MassBuilds was successfully removed"
end
end
end

View File

@ -27,7 +27,7 @@ namespace :import do
say 'DONE'
end
# bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main > log/srpm_naulinux.log
# bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main CLEAR=true > log/srpm_naulinux.log &
desc 'Import SRPMs as projects'
task :srpm => :environment do
base = ENV['BASE'] || '/share/alt_repos/rsync'
@ -36,17 +36,39 @@ namespace :import do
owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'altlinux')
platform = Platform.find_by_name!(ENV['PLATFORM'] || 'altlinux5')
repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main')
clear = ENV['CLEAR'] == 'true' ? true : false
say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'."
repo.project_to_repositories.clear if agree "Clear destination repo #{platform.name}/#{repo.name}?"
(list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |path|
print "Processing '#{path}'..."
if name = `rpm -q --qf '[%{Name}]' -p #{path}` and $?.success? and name.present?
p = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
p.import_srpm(path, platform.name)
repo.projects << p
print "Ok! - #{p.name}"
repo.project_to_repositories.clear if clear
(list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |srpm_file|
print "Processing '#{srpm_file}'... "
if name = `rpm -q --qf '[%{Name}]' -p #{srpm_file}` and $?.success? and name.present?
if clear # simply add
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
repo.projects << project
else # check if project already added
if project = repo.projects.find_by_name(name) || repo.projects.by_name(name).first # fallback to speedup
print "Found project '#{project.owner.uname}/#{project.name}' in '#{platform.name}/#{repo.name}'."
elsif scoped = Project.where(:owner_id => owner.id, :owner_type => owner.class) and
project = scoped.find_by_name(name) || scoped.by_name(name).first
begin
repo.projects << project
rescue Exception => e
print "Add project '#{project.owner.uname}/#{project.name}' to '#{platform.name}/#{repo.name}' FAILED: #{e.message}."
else
print "Add project '#{project.owner.uname}/#{project.name}' to '#{platform.name}/#{repo.name}' OK."
end
else
description = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', `rpm -q --qf '[%{Description}]' -p #{srpm_file}`)
project = Project.create!(:name => name, :description => description) {|p| p.owner = owner}
repo.projects << project
print "Create project #{project.owner.uname}/#{project.name} in #{platform.name}/#{repo.name} OK."
end
end
project.import_srpm(srpm_file, platform.name)
print " Code import complete!"
else
print 'Fail!'
print 'RPM Error!'
end
puts
end
@ -72,13 +94,13 @@ namespace :import do
repository = ENV['REPOSITORY'] || 'main'
source = "rsync://mirror.yandex.ru/mandriva/#{release}/SRPMS/#{repository}/"
destination = ENV['DESTINATION'] || File.join(APP_CONFIG['root_path'], 'mirror.yandex.ru', 'mandriva', release, 'SRPMS', repository)
say "START rsync projects (*.src.rpm) from '#{source}' to '#{destination}'"
if system "rsync -rtv --exclude='backports/*' --exclude='testing/*' #{source} #{destination}" # --delete --include='*.src.rpm'
say "START rsync projects (*.src.rpm) from '#{source}' to '#{destination}' (#{Time.now.utc})"
if system "rsync -rtv --delete --exclude='backports/*' --exclude='testing/*' #{source} #{destination}" # --include='*.src.rpm'
say 'Rsync ok!'
else
say 'Rsync failed!'
end
say 'DONE'
say "DONE (#{Time.now.utc})"
end
desc "Parse repository for changes"
@ -90,29 +112,29 @@ namespace :import do
owner = Group.find_or_create_by_uname(ENV['OWNER'] || 'import') {|g| g.name = g.uname; g.owner = User.first}
branch = "import_#{platform.name}"
say 'START'
say "START (#{Time.now.utc})"
Dir[File.join source, '{release,updates}', '*.src.rpm'].each do |srpm_file|
say "=== Processing '#{srpm_file}'..."
print "Processing '#{srpm_file}'... "
if name = `rpm -q --qf '[%{Name}]' -p #{srpm_file}` and $?.success? and name.present? and
version = `rpm -q --qf '[%{Version}]' -p #{srpm_file}` and $?.success? and version.present?
version = `rpm -q --qf '[%{Version}-%{Release}]' -p #{srpm_file}` and $?.success? and version.present?
project_import = ProjectImport.find_by_name_and_platform_id(name, platform.id) || ProjectImport.by_name(name).where(:platform_id => platform.id).first || ProjectImport.new(:name => name, :platform_id => platform.id)
if version != project_import.version.to_s and File.mtime(srpm_file) > project_import.file_mtime
unless project = project_import.project
if project = repository.projects.find_by_name(name) || repository.projects.by_name(name).first # fallback to speedup
say "Found project '#{project.owner.uname}/#{project.name}'"
print "Found project #{project.owner.uname}/#{project.name} in #{platform.name}/#{repository.name}. "
elsif scoped = Project.where(:owner_id => owner.id, :owner_type => owner.class) and
project = scoped.find_by_name(name) || scoped.by_name(name).first
repository.projects << project
say "Add project '#{project.owner.uname}/#{project.name}' to '#{platform.name}/#{repository.name}'"
print "Add project #{project.owner.uname}/#{project.name} to #{platform.name}/#{repository.name}. "
else
description = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', `rpm -q --qf '[%{Description}]' -p #{srpm_file}`)
project = Project.create!(:name => name, :description => description) {|p| p.owner = owner}
repository.projects << project
say "Create project #{project.owner.uname}/#{project.name} in #{platform.name}/#{repository.name}"
print "Create project #{project.owner.uname}/#{project.name} at #{platform.name}/#{repository.name}. "
end
end
project.import_srpm(srpm_file, branch)
say "New version (#{version}) for '#{project.owner.uname}/#{project.name}' successfully imported to branch '#{branch}'!"
print "New version (#{version}) for #{project.owner.uname}/#{project.name} successfully imported to branch #{branch}! "
project_import.project = project
# project_import.platform = platform
@ -122,15 +144,16 @@ namespace :import do
# TODO notify import.members
say '=== Success!'
print 'Ok!'
else
say '=== Not changed!'
print 'Not updated!'
end
else
say '=== Fail!'
print 'RPM Error!'
end
puts
end
say 'DONE'
say "DONE (#{Time.now.utc})"
end
end
end

View File

@ -87,7 +87,10 @@
<a href="#">Confidentiality</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>

View File

@ -89,7 +89,10 @@
<a href="#">Confidentiality</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>

View File

@ -49,7 +49,10 @@ We apologize for any inconvenience.</h2>
<a href="#">Confidentiality</a> <img src="/assets/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>

View File

@ -0,0 +1,155 @@
require 'spec_helper'
def create_key_pair(repository, user)
@key_pair = FactoryGirl.create(:key_pair, :repository => repository, :user => user)
end
shared_examples_for 'key_pair platform owner' do
it 'should be able to perform index action' do
get :index, :platform_id => @platform
response.should render_template(:index)
end
it 'should be able to perform create action' do
post :create, @create_params
response.should redirect_to(platform_key_pairs_path(@platform))
end
it 'should create key pair into db on create action' do
lambda { post :create, @create_params }.should change{KeyPair.count}.by(1)
end
context "on destroy" do
before(:each) do
create_key_pair @repository, @user
end
it 'should be able to perform action' do
delete :destroy, :platform_id => @platform, :id => @key_pair
response.should redirect_to(platform_key_pairs_path(@platform))
end
it 'should delete key pair into db' do
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(-1)
end
end
end
shared_examples_for 'key_pair platform reader' do
it 'should be able to perform index action' do
get :index, :platform_id => @platform
response.should render_template(:index)
end
it 'should not be able to perform create action' do
post :create, @create_params
response.should redirect_to(forbidden_path)
end
it 'should not change objects count on create success' do
lambda { post :create, @create_params }.should change{ KeyPair.count }.by(0)
end
context "on destroy" do
before(:each) do
create_key_pair @repository, @user
end
it 'should not be able to perform action' do
delete :destroy, :platform_id => @platform, :id => @key_pair
response.should redirect_to(forbidden_path)
end
it 'should not change objects count on destroy success' do
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(0)
end
end
end
describe Platforms::KeyPairsController do
before(:each) do
stub_symlink_methods
stub_key_pairs_calls
@platform = FactoryGirl.create(:platform)
@repository = FactoryGirl.create(:repository, :platform => @platform)
@user = FactoryGirl.create(:user)
@create_params = {
:platform_id => @platform,
:key_pair => {
:repository_id => @repository,
:public => "iampublic",
:secret => "iamsecret"
}
}
end
context 'for guest' do
[:index, :create].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform
response.should redirect_to(new_user_session_path)
end
end
it 'should not change objects count on create success' do
lambda { post :create, @create_params }.should change{ KeyPair.count }.by(0)
end
context 'on destroy' do
before(:each) do
create_key_pair @repository, @user
end
it 'should not change objects count on destroy success' do
lambda { delete :destroy, :platform_id => @platform, :id => @key_pair }.should change{KeyPair.count}.by(0)
end
it "should not be able to perform destroy action" do
delete :destroy, :platform_id => @platform, :id => @key_pair
response.should redirect_to(new_user_session_path)
end
end
end
context 'for global admin' do
before(:each) do
@admin = FactoryGirl.create(:admin)
@user = FactoryGirl.create(:user)
set_session_for(@admin)
end
it_should_behave_like 'key_pair platform owner'
end
context 'for owner user' do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.update_attribute(:owner, @user)
end
it_should_behave_like 'key_pair platform owner'
end
context 'for admin user' do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin')
end
it_should_behave_like 'key_pair platform owner'
end
context 'for reader user' do
before(:each) do
@user = FactoryGirl.create(:user)
set_session_for(@user)
@platform.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'reader')
end
it_should_behave_like 'key_pair platform reader'
end
end

View File

@ -125,7 +125,7 @@ describe Projects::BuildListsController do
end
it 'should show only accessible build_lists' do
get :index, :filter => {:ownership => 'index'}
get :index, :filter => {:ownership => 'everything'}
assigns(:build_lists).should include(@build_list1)
assigns(:build_lists).should_not include(@build_list2)
assigns(:build_lists).should include(@build_list3)
@ -210,7 +210,7 @@ describe Projects::BuildListsController do
end
it 'should show only accessible build_lists' do
get :index, :filter => {:ownership => 'index'}
get :index, :filter => {:ownership => 'everything'}
assigns(:build_lists).should include(@build_list1)
assigns(:build_lists).should_not include(@build_list2)
assigns(:build_lists).should include(@build_list3)
@ -297,17 +297,17 @@ describe Projects::BuildListsController do
it 'should filter by project_name' do
# Project.where(:id => build_list2.project.id).update_all(:name => 'project_name')
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'index'}
get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'}
assigns[:build_lists].should_not include(@build_list1)
assigns[:build_lists].should include(@build_list2)
assigns[:build_lists].should_not include(@build_list3)
end
it 'should filter by project_name and start_date' do
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'index',
:"updated_at_start(1i)" => @build_list3.updated_at.year.to_s,
:"updated_at_start(2i)" => @build_list3.updated_at.month.to_s,
:"updated_at_start(3i)" => @build_list3.updated_at.day.to_s}
it 'should filter by project_name and update_date' do
get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything',
"updated_at_start(1i)" => @build_list3.updated_at.year.to_s,
"updated_at_start(2i)" => @build_list3.updated_at.month.to_s,
"updated_at_start(3i)" => @build_list3.updated_at.day.to_s}
assigns[:build_lists].should_not include(@build_list1)
assigns[:build_lists].should_not include(@build_list2)
assigns[:build_lists].should include(@build_list3)

View File

@ -0,0 +1,10 @@
# -*- encoding : utf-8 -*-
FactoryGirl.define do
factory :key_pair do
association :repository
association :user
public FactoryGirl.generate(:string)
secret FactoryGirl.generate(:string)
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe KeyPair do
before(:all) do
stub_symlink_methods
stub_key_pairs_calls
FactoryGirl.create(:key_pair)
end
it { should belong_to(:repository) }
it { should belong_to(:user)}
it { should_not allow_mass_assignment_of(:user) }
it { should_not allow_mass_assignment_of(:key_id) }
after(:all) do
Platform.delete_all
User.delete_all
Product.delete_all
FileUtils.rm_rf(APP_CONFIG['root_path'])
end
end

View File

@ -38,6 +38,12 @@ def stub_symlink_methods
any_instance_of(Platform, :remove_symlink_directory => true)
end
def stub_key_pairs_calls
stub(BuildServer).import_gpg_key_pair { [0,"1a2b3c"] }
stub(BuildServer).set_repository_key { 0 }
stub(BuildServer).rm_repository_key { 0 }
end
def test_git_commit(project)
project.repo.index.add('test', 'TEST')
project.repo.index.commit('Test commit')

View File

@ -241,7 +241,7 @@
}
// attempt to load the definition for this language
var script_uri = '/javascripts/gollum/editor/langs/' + markup_name + '.js';
var script_uri = '/assets/gollum/editor/langs/' + markup_name + '.js';
$.ajax({
url: script_uri,
dataType: 'script',