Merge branch 'master' into 3.2-master
Conflicts: app/views/wiki/_compare.html.haml app/views/wiki/_diff_data.html.haml db/schema.rb
This commit is contained in:
commit
159ef26b38
|
@ -29,8 +29,8 @@ class Git::BlobsController < Git::BaseController
|
||||||
# @git_repository.after_update_file do |repo, sha|
|
# @git_repository.after_update_file do |repo, sha|
|
||||||
# end
|
# end
|
||||||
|
|
||||||
res = @git_repository.update_file(params[:path], params[:content],
|
res = @git_repository.update_file(params[:path], params[:content].gsub("\r", ''),
|
||||||
:message => params[:message], :actor => current_user, :head => @treeish)
|
:message => params[:message].gsub("\r", ''), :actor => current_user, :head => @treeish)
|
||||||
if res
|
if res
|
||||||
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path].encode_to_default)
|
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path].encode_to_default)
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,7 +12,7 @@ class PersonalRepositoriesController < ApplicationController
|
||||||
else
|
else
|
||||||
@projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
|
@projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
|
||||||
end
|
end
|
||||||
@user = @repository.owner
|
@user = @repository.platform.owner
|
||||||
@urpmi_commands = @repository.platform.urpmi_list(request.host)
|
@urpmi_commands = @repository.platform.urpmi_list(request.host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,7 @@ class PlatformsController < ApplicationController
|
||||||
autocomplete :user, :uname
|
autocomplete :user, :uname
|
||||||
|
|
||||||
def build_all
|
def build_all
|
||||||
@platform.repositories.each do |repository|
|
@platform.delay.build_all(current_user)
|
||||||
repository.projects.each do |project|
|
|
||||||
project.delay.build_for(@platform, current_user)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to(platform_path(@platform), :notice => t("flash.platform.build_all_success"))
|
redirect_to(platform_path(@platform), :notice => t("flash.platform.build_all_success"))
|
||||||
end
|
end
|
||||||
|
@ -109,24 +105,24 @@ class PlatformsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
if request.post?
|
@cloned = Platform.new
|
||||||
@cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'],
|
@cloned.name = @platform.name + "_clone"
|
||||||
:owner_id => current_user.id, :owner_type => current_user.class.to_s)
|
@cloned.description = @platform.description + "_clone"
|
||||||
|
end
|
||||||
|
|
||||||
|
def make_clone
|
||||||
|
@cloned = @platform.full_clone params[:platform].merge(:owner => current_user)
|
||||||
if @cloned.persisted?
|
if @cloned.persisted?
|
||||||
flash[:notice] = I18n.t("flash.platform.clone_success")
|
flash[:notice] = I18n.t("flash.platform.clone_success")
|
||||||
redirect_to @cloned
|
redirect_to @cloned
|
||||||
else
|
else
|
||||||
flash[:error] = @cloned.errors.full_messages.join('. ')
|
flash[:error] = @cloned.errors.full_messages.join('. ')
|
||||||
end
|
render 'clone'
|
||||||
else
|
|
||||||
@cloned = Platform.new
|
|
||||||
@cloned.name = @platform.name + "_clone"
|
|
||||||
@cloned.description = @platform.description + "_clone"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@platform.destroy if @platform
|
@platform.delay.destroy if @platform
|
||||||
|
|
||||||
flash[:notice] = t("flash.platform.destroyed")
|
flash[:notice] = t("flash.platform.destroyed")
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
|
|
|
@ -5,7 +5,7 @@ class RegisterRequestsController < ApplicationController
|
||||||
before_filter :find_register_request, :only => [:approve, :reject]
|
before_filter :find_register_request, :only => [:approve, :reject]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@register_requests = @register_requests.unprocessed.paginate(:page => params[:page])
|
@register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -42,7 +42,6 @@ class RepositoriesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@repository = Repository.new(params[:repository])
|
@repository = Repository.new(params[:repository])
|
||||||
@repository.platform_id = params[:platform_id]
|
@repository.platform_id = params[:platform_id]
|
||||||
@repository.owner = get_owner
|
|
||||||
if @repository.save
|
if @repository.save
|
||||||
flash[:notice] = t('flash.repository.saved')
|
flash[:notice] = t('flash.repository.saved')
|
||||||
redirect_to @repositories_path
|
redirect_to @repositories_path
|
||||||
|
|
|
@ -117,19 +117,25 @@ class WikiController < ApplicationController
|
||||||
def compare_wiki
|
def compare_wiki
|
||||||
if request.post?
|
if request.post?
|
||||||
@versions = params[:versions] || []
|
@versions = params[:versions] || []
|
||||||
if @versions.size < 2
|
versions_string = case @versions.size
|
||||||
redirect_to history_project_wiki_index_path(@project)
|
when 1 then @versions.first
|
||||||
else
|
when 2 then sprintf('%s...%s', @versions.last, @versions.first)
|
||||||
redirect_to compare_versions_project_wiki_index_path(@project,
|
else begin
|
||||||
sprintf('%s...%s', @versions.last, @versions.first))
|
|
||||||
end
|
|
||||||
elsif request.get?
|
|
||||||
@versions = params[:versions].split(/\.{2,3}/)
|
|
||||||
if @versions.size < 2
|
|
||||||
redirect_to history_project_wiki_index_path(@project)
|
redirect_to history_project_wiki_index_path(@project)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@diffs = @wiki.repo.diff(@versions.first, @versions.last)
|
end
|
||||||
|
redirect_to compare_versions_project_wiki_index_path(@project, versions_string)
|
||||||
|
elsif request.get?
|
||||||
|
@versions = params[:versions].split(/\.{2,3}/) || []
|
||||||
|
@diffs = case @versions.size
|
||||||
|
when 1 then @wiki.repo.commit_diff(@versions.first)
|
||||||
|
when 2 then @wiki.repo.diff(@versions.first, @versions.last)
|
||||||
|
else begin
|
||||||
|
redirect_to history_project_wiki_index_path(@project)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
render :compare
|
render :compare
|
||||||
else
|
else
|
||||||
redirect_to project_wiki_path(@project, CGI.escape(@name))
|
redirect_to project_wiki_path(@project, CGI.escape(@name))
|
||||||
|
@ -141,8 +147,9 @@ class WikiController < ApplicationController
|
||||||
@page = @wiki.page(@name)
|
@page = @wiki.page(@name)
|
||||||
sha1 = params[:sha1]
|
sha1 = params[:sha1]
|
||||||
sha2 = params[:sha2]
|
sha2 = params[:sha2]
|
||||||
|
sha2 = nil if params[:sha2] == 'prev'
|
||||||
|
|
||||||
if @wiki.revert_page(@page, sha1, sha2, {:committer => committer}).commit
|
if c = @wiki.revert_page(@page, sha1, sha2, {:committer => committer}) and c.commit
|
||||||
flash[:notice] = t("flash.wiki.revert_success")
|
flash[:notice] = t("flash.wiki.revert_success")
|
||||||
redirect_to project_wiki_path(@project, CGI.escape(@name))
|
redirect_to project_wiki_path(@project, CGI.escape(@name))
|
||||||
else
|
else
|
||||||
|
@ -162,14 +169,14 @@ class WikiController < ApplicationController
|
||||||
def revert_wiki
|
def revert_wiki
|
||||||
sha1 = params[:sha1]
|
sha1 = params[:sha1]
|
||||||
sha2 = params[:sha2]
|
sha2 = params[:sha2]
|
||||||
if @wiki.revert_commit(sha1, sha2, {:committer => committer}).commit
|
sha2 = nil if sha2 == 'prev'
|
||||||
|
if c = @wiki.revert_commit(sha1, sha2, {:committer => committer}) and c.commit
|
||||||
flash[:notice] = t("flash.wiki.revert_success")
|
flash[:notice] = t("flash.wiki.revert_success")
|
||||||
redirect_to project_wiki_index_path(@project)
|
redirect_to project_wiki_index_path(@project)
|
||||||
else
|
else
|
||||||
sha2, sha1 = sha1, "#{sha1}^" if !sha2
|
sha2, sha1 = sha1, "#{sha1}^" if !sha2
|
||||||
@versions = [sha1, sha2]
|
@versions = [sha1, sha2]
|
||||||
diffs = @wiki.repo.diff(@versions.first, @versions.last)
|
@diffs = @wiki.repo.diff(@versions.first, @versions.last)
|
||||||
@diffs = [diffs.first]
|
|
||||||
flash[:error] = t("flash.wiki.patch_does_not_apply")
|
flash[:error] = t("flash.wiki.patch_does_not_apply")
|
||||||
render :compare
|
render :compare
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module DiffHelper
|
||||||
|
|
||||||
res += "<table class='diff inline' cellspacing='0' cellpadding='0'>"
|
res += "<table class='diff inline' cellspacing='0' cellpadding='0'>"
|
||||||
res += "<tbody>"
|
res += "<tbody>"
|
||||||
res += diff_display.render(Git::Diff::InlineCallback.new)
|
res += diff_display.render(Git::Diff::InlineCallback.new).encode_to_default
|
||||||
res += "</tbody>"
|
res += "</tbody>"
|
||||||
res += "</table>"
|
res += "</table>"
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
module ProjectsHelper
|
module ProjectsHelper
|
||||||
def git_repo_url(name)
|
def git_repo_url(name)
|
||||||
if current_user
|
if current_user
|
||||||
"http://#{current_user.uname}@#{request.host_with_port}/#{name}.git"
|
"https://#{current_user.uname}@#{request.host_with_port}/#{name}.git"
|
||||||
else
|
else
|
||||||
"http://#{request.host_with_port}/#{name}.git"
|
"https://#{request.host_with_port}/#{name}.git"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,8 @@ class Ability
|
||||||
cannot :destroy, Subscribe
|
cannot :destroy, Subscribe
|
||||||
cannot :create, Subscribe
|
cannot :create, Subscribe
|
||||||
cannot :create, RegisterRequest
|
cannot :create, RegisterRequest
|
||||||
|
cannot :approve, RegisterRequest, :approved => true
|
||||||
|
cannot :reject, RegisterRequest, :rejected => true
|
||||||
else
|
else
|
||||||
# Shared rights between guests and registered users
|
# Shared rights between guests and registered users
|
||||||
can :forbidden, Platform
|
can :forbidden, Platform
|
||||||
|
@ -64,22 +66,21 @@ class Ability
|
||||||
can :read, Platform, :owner_type => 'User', :owner_id => user.id
|
can :read, Platform, :owner_type => 'User', :owner_id => user.id
|
||||||
can :read, Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
can :read, Platform, :owner_type => 'Group', :owner_id => user.group_ids
|
||||||
can(:read, Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
can(:read, Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
|
||||||
can(:update, Platform) {|platform| local_admin? platform}
|
can([:update, :build_all], Platform) {|platform| local_admin? platform}
|
||||||
can([:freeze, :unfreeze, :destroy], Platform) {|platform| owner? platform}
|
can([:freeze, :unfreeze, :destroy], Platform) {|platform| owner? platform}
|
||||||
can :autocomplete_user_uname, Platform
|
can :autocomplete_user_uname, Platform
|
||||||
|
|
||||||
# TODO delegate to platform?
|
|
||||||
can :read, Repository, :platform => {:visibility => 'open'}
|
can :read, Repository, :platform => {:visibility => 'open'}
|
||||||
can :read, Repository, :owner_type => 'User', :owner_id => user.id
|
can :read, Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||||
can :read, Repository, :owner_type => 'Group', :owner_id => user.group_ids
|
can :read, Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||||
can(:read, Repository, read_relations_for('repositories')) {|repository| local_reader? repository}
|
can(:read, Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
||||||
can(:create, Repository) {|repository| local_admin? repository.platform}
|
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
||||||
can([:update, :add_project, :remove_project], Repository) {|repository| local_admin? repository}
|
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository}
|
|
||||||
|
|
||||||
can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id}
|
can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||||
can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||||
can(:manage, Product, read_relations_for('products', 'platforms')) {|product| local_admin? product.platform}
|
can(:manage, Product, read_relations_for('products', 'platforms')) {|product| local_admin? product.platform}
|
||||||
|
can(:create, ProductBuildList) {|pbl| pbl.product.can_build? and can?(:update, pbl.product)}
|
||||||
|
|
||||||
can [:read, :platforms], Category
|
can [:read, :platforms], Category
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
class Group < ActiveRecord::Base
|
class Group < ActiveRecord::Base
|
||||||
belongs_to :owner, :class_name => 'User'
|
belongs_to :owner, :class_name => 'User'
|
||||||
|
|
||||||
has_many :own_projects, :as => :owner, :class_name => 'Project'
|
has_many :relations, :as => :object, :dependent => :destroy
|
||||||
|
|
||||||
has_many :objects, :as => :target, :class_name => 'Relation'
|
has_many :objects, :as => :target, :class_name => 'Relation'
|
||||||
has_many :targets, :as => :object, :class_name => 'Relation'
|
has_many :targets, :as => :object, :class_name => 'Relation'
|
||||||
|
|
||||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
|
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
|
||||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||||
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true, :dependent => :destroy
|
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
|
||||||
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
|
|
||||||
has_many :relations, :as => :object, :dependent => :destroy
|
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
||||||
|
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
|
||||||
|
|
||||||
validates :name, :owner, :presence => true
|
validates :name, :owner, :presence => true
|
||||||
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
||||||
|
@ -24,11 +24,12 @@ class Group < ActiveRecord::Base
|
||||||
after_create :add_owner_to_members
|
after_create :add_owner_to_members
|
||||||
|
|
||||||
include Modules::Models::PersonalRepository
|
include Modules::Models::PersonalRepository
|
||||||
# include Modules::Models::Owner
|
# include Modules::Models::Owner
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_owner_to_members
|
def add_owner_to_members
|
||||||
Relation.create_with_role(self.owner, self, 'admin')
|
Relation.create_with_role(self.owner, self, 'admin')
|
||||||
# members << self.owner if !members.exists?(:id => self.owner.id)
|
# members << self.owner if !members.exists?(:id => self.owner.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,10 +14,11 @@ class Platform < ActiveRecord::Base
|
||||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
|
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
|
||||||
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
|
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
|
||||||
|
|
||||||
validates :description, :presence => true, :uniqueness => true
|
validates :description, :presence => true
|
||||||
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
|
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
|
||||||
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
|
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
|
||||||
|
|
||||||
|
before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready
|
||||||
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
||||||
before_destroy :xml_rpc_destroy
|
before_destroy :xml_rpc_destroy
|
||||||
# before_update :check_freezing
|
# before_update :check_freezing
|
||||||
|
@ -98,27 +99,23 @@ class Platform < ActiveRecord::Base
|
||||||
platform_type == 'personal'
|
platform_type == 'personal'
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_clone(attrs) # :description, :name, :owner
|
def base_clone(attrs = {}) # :description, :name, :owner
|
||||||
clone.tap do |c|
|
clone.tap do |c|
|
||||||
c.attributes = attrs
|
c.attributes = attrs # attrs.each {|k,v| c.send("#{k}=", v)}
|
||||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||||
c.parent = self
|
c.parent = self
|
||||||
new_attrs = {:platform_id => nil}
|
|
||||||
c.repositories = repositories.map{|r| r.full_clone(new_attrs.merge(:owner_id => attrs[:owner_id], :owner_type => attrs[:owner_type]))}
|
|
||||||
c.products = products.map{|p| p.full_clone(new_attrs)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO * make it Delayed Job *
|
def clone_relations(from = parent)
|
||||||
def make_clone(attrs)
|
self.repositories = from.repositories.map{|r| r.full_clone(:platform_id => id)}
|
||||||
p = full_clone(attrs)
|
self.products = from.products.map(&:full_clone)
|
||||||
begin
|
end
|
||||||
Thread.current[:skip] = true
|
|
||||||
p.save and xml_rpc_clone(attrs[:name])
|
def full_clone(attrs = {})
|
||||||
ensure
|
base_clone(attrs).tap do |c|
|
||||||
Thread.current[:skip] = false
|
with_skip {c.save} and c.clone_relations(self) and c.delay.xml_rpc_clone
|
||||||
end
|
end
|
||||||
p
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
|
@ -135,9 +132,13 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_directory
|
||||||
|
system("sudo mkdir -p -m 0777 #{path}")
|
||||||
|
end
|
||||||
|
|
||||||
def mount_directory_for_rsync
|
def mount_directory_for_rsync
|
||||||
# umount_directory_for_rsync # TODO ignore errors
|
# umount_directory_for_rsync # TODO ignore errors
|
||||||
system("sudo mkdir -p #{mount_path}")
|
system("sudo mkdir -p -m 0777 #{mount_path}")
|
||||||
system("sudo mount --bind #{path} #{mount_path}")
|
system("sudo mount --bind #{path} #{mount_path}")
|
||||||
Arch.all.each do |arch|
|
Arch.all.each do |arch|
|
||||||
str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n"
|
str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n"
|
||||||
|
@ -157,6 +158,23 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_all(user)
|
||||||
|
repositories.find_by_name('main').projects.find_in_batches(:batch_size => 5) do |group|
|
||||||
|
sleep 1
|
||||||
|
group.each do |p|
|
||||||
|
begin
|
||||||
|
p.build_for(self, user)
|
||||||
|
rescue RuntimeError, Exception
|
||||||
|
p.delay.build_for(self, user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
with_skip {super} # avoid cascade XML RPC requests
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def build_path(dir)
|
def build_path(dir)
|
||||||
|
@ -181,12 +199,12 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_rpc_clone(new_name)
|
def xml_rpc_clone(old_name = parent.name, new_name = name)
|
||||||
result = BuildServer.clone_platform new_name, self.name, APP_CONFIG['root_path'] + '/platforms'
|
result = BuildServer.clone_platform new_name, old_name, APP_CONFIG['root_path'] + '/platforms'
|
||||||
if result == BuildServer::SUCCESS
|
if result == BuildServer::SUCCESS
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
raise "Failed to clone platform #{name} with code #{result}. Path: #{build_path(name)} to platform #{new_name}"
|
raise "Failed to clone platform #{old_name} with code #{result}. Path: #{build_path(old_name)} to platform #{new_name}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,10 @@ class Product < ActiveRecord::Base
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_clone(attrs) # owner
|
def full_clone(attrs = {})
|
||||||
clone.tap do |c| # dup
|
clone.tap do |c| # dup
|
||||||
c.attributes = attrs
|
c.platform_id = nil
|
||||||
|
attrs.each {|k,v| c.send("#{k}=", v)}
|
||||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,10 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :xml_rpc_create
|
after_create :xml_rpc_create
|
||||||
|
|
||||||
|
def container_path
|
||||||
|
"/downloads/#{product.platform.name}/product/#{id}/"
|
||||||
|
end
|
||||||
|
|
||||||
def human_status
|
def human_status
|
||||||
I18n.t("layout.product_build_lists.statuses.#{status}")
|
I18n.t("layout.product_build_lists.statuses.#{status}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Project < ActiveRecord::Base
|
||||||
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
|
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
|
||||||
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
||||||
|
|
||||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ }
|
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/}
|
||||||
validates :owner, :presence => true
|
validates :owner, :presence => true
|
||||||
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS }
|
||||||
# validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
|
# validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
|
||||||
|
@ -65,10 +65,9 @@ class Project < ActiveRecord::Base
|
||||||
build_lists.create do |bl|
|
build_lists.create do |bl|
|
||||||
bl.pl = platform
|
bl.pl = platform
|
||||||
bl.bpl = platform
|
bl.bpl = platform
|
||||||
bl.update_type = 'recommended'
|
bl.update_type = 'newpackage'
|
||||||
bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild
|
bl.arch = Arch.find_by_name('x86_64') # Return i586 after mass rebuild
|
||||||
# FIXME: Need to set "latest_#{platform.name}"
|
bl.project_version = "latest_#{platform.name}" # "latest_import_mandriva2011"
|
||||||
bl.project_version = "latest_import_mandriva2011"
|
|
||||||
bl.build_requires = false # already set as db default
|
bl.build_requires = false # already set as db default
|
||||||
bl.user = user
|
bl.user = user
|
||||||
bl.auto_publish = true # already set as db default
|
bl.auto_publish = true # already set as db default
|
||||||
|
@ -212,9 +211,20 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_hook
|
def write_hook
|
||||||
|
is_production = ENV['RAILS_ENV'] == 'production'
|
||||||
|
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook")
|
||||||
|
FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
|
||||||
|
File.open(hook, 'a') do |f|
|
||||||
|
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\""
|
||||||
|
s << " > /dev/null 2>&1" if is_production
|
||||||
|
s << "\ndone\n"
|
||||||
|
f.write(s)
|
||||||
|
end
|
||||||
|
|
||||||
hook_file = File.join(path, 'hooks', 'post-receive')
|
hook_file = File.join(path, 'hooks', 'post-receive')
|
||||||
FileUtils.cp(File.join(::Rails.root.to_s, 'lib', 'post-receive-hook'), hook_file)
|
FileUtils.cp(hook, hook_file)
|
||||||
#File.chmod(0775, hook_file) # need?
|
FileUtils.rm_rf(hook)
|
||||||
|
|
||||||
rescue Exception # FIXME
|
rescue Exception # FIXME
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class ProjectToRepository < ActiveRecord::Base
|
||||||
delegate :path, :to => :project
|
delegate :path, :to => :project
|
||||||
|
|
||||||
after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]}
|
after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]}
|
||||||
after_destroy lambda { project.xml_rpc_destroy(repository) }
|
after_destroy lambda { project.xml_rpc_destroy(repository) }, :unless => lambda {Thread.current[:skip]}
|
||||||
# after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }
|
# after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }
|
||||||
|
|
||||||
validate :one_project_in_platform_repositories
|
validate :one_project_in_platform_repositories
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Relation < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_default_role
|
def add_default_role
|
||||||
self.role = ROLES.first if role.nil? || role.empty?
|
self.role = ROLES.first if role.nil? || role.empty?
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,39 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class Repository < ActiveRecord::Base
|
class Repository < ActiveRecord::Base
|
||||||
belongs_to :platform
|
belongs_to :platform
|
||||||
belongs_to :owner, :polymorphic => true
|
|
||||||
|
|
||||||
has_many :projects, :through => :project_to_repositories #, :dependent => :destroy
|
has_many :project_to_repositories, :dependent => :destroy, :validate => true
|
||||||
has_many :project_to_repositories, :validate => true, :dependent => :destroy
|
has_many :projects, :through => :project_to_repositories
|
||||||
|
|
||||||
has_many :relations, :as => :target, :dependent => :destroy
|
validates :description, :presence => true
|
||||||
has_many :objects, :as => :target, :class_name => 'Relation', :dependent => :destroy
|
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /^[a-z0-9_\-]+$/}
|
||||||
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
|
|
||||||
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
|
|
||||||
|
|
||||||
validates :description, :uniqueness => {:scope => :platform_id}, :presence => true
|
|
||||||
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ }
|
|
||||||
# validates :platform_id, :presence => true # if you uncomment this platform clone will not work
|
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
|
|
||||||
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
|
||||||
before_destroy :xml_rpc_destroy
|
before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]}
|
||||||
after_create :add_admin_relations
|
|
||||||
|
|
||||||
attr_accessible :description, :name #, :platform_id
|
attr_accessible :description, :name
|
||||||
|
|
||||||
def full_clone(attrs) # owner
|
def base_clone(attrs = {})
|
||||||
clone.tap do |c| # dup
|
clone.tap do |c| # dup
|
||||||
c.attributes = attrs
|
c.platform_id = nil
|
||||||
|
attrs.each {|k,v| c.send("#{k}=", v)}
|
||||||
c.updated_at = nil; c.created_at = nil # :id = nil
|
c.updated_at = nil; c.created_at = nil # :id = nil
|
||||||
c.projects = projects
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
include Modules::Models::Owner
|
def clone_relations(from)
|
||||||
|
with_skip do
|
||||||
|
from.projects.find_each {|p| self.projects << p}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def full_clone(attrs = {})
|
||||||
|
base_clone(attrs).tap do |c|
|
||||||
|
with_skip {c.save} and c.delay.clone_relations(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def build_stub(platform)
|
def build_stub(platform)
|
||||||
|
@ -60,14 +62,4 @@ class Repository < ActiveRecord::Base
|
||||||
raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}."
|
raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_admin_relations
|
|
||||||
platform.relations.where(:role => 'admin').each do |rel|
|
|
||||||
if !relations.exists?(:role => 'admin', :object_type => rel.object_type, :object_id => rel.object_id) && rel.object != owner
|
|
||||||
r = relations.build(:role => 'admin', :object_type => rel.object_type)
|
|
||||||
r.object_id = rel.object_id
|
|
||||||
r.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,22 +11,19 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :authentications, :dependent => :destroy
|
has_many :authentications, :dependent => :destroy
|
||||||
has_many :build_lists, :dependent => :destroy
|
has_many :build_lists, :dependent => :destroy
|
||||||
|
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
|
||||||
|
has_many :comments, :dependent => :destroy
|
||||||
|
|
||||||
has_many :relations, :as => :object, :dependent => :destroy
|
has_many :relations, :as => :object, :dependent => :destroy
|
||||||
has_many :targets, :as => :object, :class_name => 'Relation'
|
has_many :targets, :as => :object, :class_name => 'Relation'
|
||||||
|
|
||||||
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
|
||||||
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group'
|
|
||||||
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
|
|
||||||
has_many :own_repositories, :as => :owner, :class_name => 'Repository', :dependent => :destroy
|
|
||||||
|
|
||||||
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
|
||||||
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
|
||||||
|
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
|
||||||
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
|
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
|
||||||
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
|
|
||||||
has_many :subscribes, :foreign_key => :user_id, :dependent => :destroy
|
|
||||||
|
|
||||||
has_many :comments, :dependent => :destroy
|
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
|
||||||
|
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
|
||||||
|
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
|
||||||
|
|
||||||
include Modules::Models::PersonalRepository
|
include Modules::Models::PersonalRepository
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
- edit_path = edit_project_commit_comment_path(project, commentable, comment)
|
- edit_path = edit_project_commit_comment_path(project, commentable, comment)
|
||||||
- delete_path = project_commit_comment_path(project, commentable, comment)
|
- delete_path = project_commit_comment_path(project, commentable, comment)
|
||||||
= link_to t("layout.edit"), edit_path if can? :update, comment
|
= link_to t("layout.edit"), edit_path if can? :update, comment
|
||||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
|
=# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
|
||||||
|
= link_to t("layout.delete"), delete_path, :method => "delete", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
|
||||||
|
|
||||||
.block
|
.block
|
||||||
.content
|
.content
|
||||||
|
|
|
@ -20,21 +20,11 @@
|
||||||
= t("activerecord.attributes.repository.platform")
|
= t("activerecord.attributes.repository.platform")
|
||||||
\:
|
\:
|
||||||
= link_to @repository.platform.name, url_for(@repository.platform)
|
= link_to @repository.platform.name, url_for(@repository.platform)
|
||||||
%p
|
|
||||||
%b
|
|
||||||
= t("activerecord.attributes.repository.owner")
|
|
||||||
\:
|
|
||||||
= link_to @repository.owner.name, url_for(@repository.owner)
|
|
||||||
%p
|
%p
|
||||||
%b
|
%b
|
||||||
= t("activerecord.attributes.platform.visibility")
|
= t("activerecord.attributes.platform.visibility")
|
||||||
\:
|
\:
|
||||||
= @repository.platform.visibility
|
= @repository.platform.visibility
|
||||||
%p
|
|
||||||
%b
|
|
||||||
= t("activerecord.attributes.repository.platform")
|
|
||||||
\:
|
|
||||||
= link_to @repository.platform.name, platform_path(@platform)
|
|
||||||
.wat-cf
|
.wat-cf
|
||||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,6 @@
|
||||||
%li= link_to t("layout.personal_repositories.private_users"), platform_private_users_path(@repository.platform) if @repository.platform.hidden?
|
%li= link_to t("layout.personal_repositories.private_users"), platform_private_users_path(@repository.platform) if @repository.platform.hidden?
|
||||||
.content
|
.content
|
||||||
.inner
|
.inner
|
||||||
%p
|
|
||||||
%b
|
|
||||||
= t("activerecord.attributes.repository.owner")
|
|
||||||
\:
|
|
||||||
= link_to @repository.owner.name, url_for(@repository.owner)
|
|
||||||
|
|
||||||
= render 'shared/urpmi_list', :urpmi_commands => @urpmi_commands
|
= render 'shared/urpmi_list', :urpmi_commands => @urpmi_commands
|
||||||
.wat-cf
|
.wat-cf
|
||||||
=# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
=# link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%h2.title
|
%h2.title
|
||||||
= t("layout.platforms.clone_header")
|
= t("layout.platforms.clone_header")
|
||||||
.inner
|
.inner
|
||||||
= form_for @cloned, :url => clone_platform_path(@platform), :html => { :class => :form } do |f|
|
= form_for @cloned, :url => make_clone_platform_path(@platform), :html => { :class => :form } do |f|
|
||||||
.group
|
.group
|
||||||
= f.label :name, :class => :label
|
= f.label :name, :class => :label
|
||||||
= f.text_field :name, :class => 'text_field'
|
= f.text_field :name, :class => 'text_field'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
%tr{:class => cycle("odd", "even")}
|
%tr{:class => cycle("odd", "even")}
|
||||||
%td= product_build_list.id
|
%td= product_build_list.id
|
||||||
%td= link_to product_build_list.product.name, [product_build_list.product.platform, product_build_list.product]
|
%td= link_to product_build_list.product.name, [product_build_list.product.platform, product_build_list.product]
|
||||||
|
%td= link_to nil, product_build_list.container_path
|
||||||
%td= product_build_list.human_status
|
%td= product_build_list.human_status
|
||||||
%td= product_build_list.notified_at
|
%td= product_build_list.notified_at
|
|
@ -26,11 +26,13 @@
|
||||||
= t("layout.#{@product.system_wide?}_")
|
= t("layout.#{@product.system_wide?}_")
|
||||||
|
|
||||||
.wat-cf
|
.wat-cf
|
||||||
|
- if can? :update, @product
|
||||||
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_platform_product_path(@platform, @product), :class => "button"
|
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_platform_product_path(@platform, @product), :class => "button"
|
||||||
|
- if can? :destroy, @product
|
||||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_product_path(@platform, @product), :method => "delete", :class => "button", :confirm => t("layout.products.confirm_delete")
|
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_product_path(@platform, @product), :method => "delete", :class => "button", :confirm => t("layout.products.confirm_delete")
|
||||||
- if @product.can_clone?
|
- if @product.can_clone?
|
||||||
= link_to t("layout.products.clone"), clone_platform_product_path(@platform, @product), :class => "button"
|
= link_to t("layout.products.clone"), clone_platform_product_path(@platform, @product), :class => "button"
|
||||||
- if @product.can_build?
|
- if can?(:create, @product => ProductBuildList)
|
||||||
= link_to t("layout.products.build"), platform_product_product_build_lists_path(@platform, @product), :class => "button", :method => 'post', :confirm => t("layout.confirm")
|
= link_to t("layout.products.build"), platform_product_product_build_lists_path(@platform, @product), :class => "button", :method => 'post', :confirm => t("layout.confirm")
|
||||||
|
|
||||||
.block
|
.block
|
||||||
|
@ -40,6 +42,7 @@
|
||||||
%tr
|
%tr
|
||||||
%th.first= t("activerecord.attributes.product_build_list.id")
|
%th.first= t("activerecord.attributes.product_build_list.id")
|
||||||
%th= t("activerecord.attributes.product_build_list.product")
|
%th= t("activerecord.attributes.product_build_list.product")
|
||||||
|
%th= t("activerecord.attributes.product_build_list.container_path")
|
||||||
%th= t("activerecord.attributes.product_build_list.status")
|
%th= t("activerecord.attributes.product_build_list.status")
|
||||||
%th.last= t("activerecord.attributes.product_build_list.notified_at")
|
%th.last= t("activerecord.attributes.product_build_list.notified_at")
|
||||||
= render @product.product_build_lists.default_order
|
= render @product.product_build_lists.default_order
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
%li= link_to t("layout.users.new"), new_user_path
|
%li= link_to t("layout.users.new"), new_user_path
|
||||||
%li.active= link_to t("layout.users.register_requests"), register_requests_path
|
%li.active= link_to t("layout.users.register_requests"), register_requests_path
|
||||||
.content
|
.content
|
||||||
|
%div{:style => 'float: right; margin: 20px'}
|
||||||
|
= link_to t("layout.register_request.approved"), register_requests_path(:scope => :approved)
|
||||||
|
\|
|
||||||
|
= link_to t("layout.register_request.rejected"), register_requests_path(:scope => :rejected)
|
||||||
%h2.title
|
%h2.title
|
||||||
= t("layout.register_request.list_header")
|
= t("layout.register_request.list_header")
|
||||||
.inner
|
.inner
|
||||||
|
@ -23,7 +27,8 @@
|
||||||
%tr{:class => cycle("odd", "even")}
|
%tr{:class => cycle("odd", "even")}
|
||||||
%td= check_box_tag 'request_ids[]', request.id
|
%td= check_box_tag 'request_ids[]', request.id
|
||||||
%td= request.name
|
%td= request.name
|
||||||
%td= request.email
|
- @user = User.find_by_email(request.email) if request.approved
|
||||||
|
%td= link_to_if @user, request.email, @user
|
||||||
%td= request.interest
|
%td= request.interest
|
||||||
%td= request.more
|
%td= request.more
|
||||||
%td= request.created_at
|
%td= request.created_at
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
= t("activerecord.attributes.repository.platform")
|
= t("activerecord.attributes.repository.platform")
|
||||||
\:
|
\:
|
||||||
= link_to @repository.platform.description, url_for(@repository.platform)
|
= link_to @repository.platform.description, url_for(@repository.platform)
|
||||||
%p
|
|
||||||
%b
|
|
||||||
= t("activerecord.attributes.repository.owner")
|
|
||||||
\:
|
|
||||||
= link_to @repository.owner.uname, url_for(@repository.owner)
|
|
||||||
.wat-cf
|
.wat-cf
|
||||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete")
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
= t("activerecord.attributes.repository.platform")
|
= t("activerecord.attributes.repository.platform")
|
||||||
\:
|
\:
|
||||||
= link_to @repository.platform.description, url_for(@repository.platform)
|
= link_to @repository.platform.description, url_for(@repository.platform)
|
||||||
%p
|
|
||||||
%b
|
|
||||||
= t("activerecord.attributes.repository.owner")
|
|
||||||
\:
|
|
||||||
= link_to @repository.owner.try(:name), url_for(@repository.owner)
|
|
||||||
.wat-cf
|
.wat-cf
|
||||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") if can? :destroy, @repository
|
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") if can? :destroy, @repository
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%p== Hello, #{@user.name}.
|
%p== Hello, #{@user.name}.
|
||||||
|
|
||||||
|
|
||||||
%p You have been assigned to issue #{ link_to @issue.title, [@issue.project, @issue] }
|
%p You have been assigned to issue #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
|
||||||
|
|
||||||
|
|
||||||
%p== Support team «ROSA Build System»
|
%p== Support team «ROSA Build System»
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%p== Здравствуйте, #{@user.name}.
|
%p== Здравствуйте, #{@user.name}.
|
||||||
|
|
||||||
|
|
||||||
%p Вам была назначена задача #{ link_to @issue.title, [@issue.project, @issue] }
|
%p Вам была назначена задача #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
|
||||||
|
|
||||||
|
|
||||||
%p== Команда поддержки «ROSA Build System»
|
%p== Команда поддержки «ROSA Build System»
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
%p== Hello, #{@user.name}.
|
%p== Hello, #{@user.name}.
|
||||||
|
|
||||||
- if @comment.commentable.class == Issue
|
- if @comment.commentable.class == Issue
|
||||||
- link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable]
|
- link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable)
|
||||||
- object = 'issue'
|
- object = 'issue'
|
||||||
- elsif @comment.commentable.class == Grit::Commit
|
- elsif @comment.commentable.class == Grit::Commit
|
||||||
- link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id)
|
- link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id)
|
||||||
- object = 'commit'
|
- object = 'commit'
|
||||||
%p #{ link_to @comment.user.uname, user_path(@comment.user)} added new comment to #{object} #{link}.
|
%p #{ link_to @comment.user.uname, user_url(@comment.user)} added new comment to #{object} #{link}.
|
||||||
|
|
||||||
%p "#{ @comment.body }"
|
%p "#{ @comment.body }"
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
%p== Здравствуйте, #{@user.name}.
|
%p== Здравствуйте, #{@user.name}.
|
||||||
|
|
||||||
- if @comment.commentable.class == Issue
|
- if @comment.commentable.class == Issue
|
||||||
- link = link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable]
|
- link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable)
|
||||||
- object = 'задаче'
|
- object = 'задаче'
|
||||||
- elsif @comment.commentable.class == Grit::Commit
|
- elsif @comment.commentable.class == Grit::Commit
|
||||||
- link = link_to @comment.commentable.message, commit_path(@comment.project, @comment.commentable_id)
|
- link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id)
|
||||||
- object = 'коммиту'
|
- object = 'коммиту'
|
||||||
%p #{ link_to @comment.user.uname, user_path(@comment.user)} добавил комментарий к #{object} #{link}.
|
%p #{ link_to @comment.user.uname, user_url(@comment.user)} добавил комментарий к #{object} #{link}.
|
||||||
|
|
||||||
%p "#{ @comment.body }"
|
%p "#{ @comment.body }"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%p== Hello, #{@user.name}.
|
%p== Hello, #{@user.name}.
|
||||||
|
|
||||||
|
- #TODO hmm... this need to be refactored.
|
||||||
%p Your comment into issue #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } has been answered.
|
%p Your comment into issue #{ link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable) } has been answered.
|
||||||
|
|
||||||
%p "#{ @comment.body }"
|
%p "#{ @comment.body }"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%p== Hello, #{@user.name}.
|
%p== Hello, #{@user.name}.
|
||||||
|
|
||||||
|
|
||||||
%p To project #{ link_to @issue.project.name, project_path(@issue.project) } has been added an issue #{ link_to @issue.title, [@issue.project, @issue] }
|
%p To project #{ link_to @issue.project.name, project_url(@issue.project) } has been added an issue #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
|
||||||
|
|
||||||
|
|
||||||
%p== Support team «ROSA Build System»
|
%p== Support team «ROSA Build System»
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%p== Здравствуйте, #{@user.name}.
|
%p== Здравствуйте, #{@user.name}.
|
||||||
|
|
||||||
|
|
||||||
%p К проекту #{ link_to @issue.project.name, project_path(@issue.project) } была добавлена задача #{ link_to @issue.title, [@issue.project, @issue] }
|
%p К проекту #{ link_to @issue.project.name, project_url(@issue.project) } была добавлена задача #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
|
||||||
|
|
||||||
|
|
||||||
%p== Команда поддержки «ROSA Build System»
|
%p== Команда поддержки «ROSA Build System»
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
= link_to t("wiki.revert_page#{action_name == 'revert' ? '' : 's'}"), '#', :class => "gollum-revert-button button width100"
|
= link_to t("wiki.revert_page#{action_name == 'revert' ? '' : 's'}"), '#', :class => "gollum-revert-button button width100"
|
||||||
|
|
||||||
- if action_name != 'revert'
|
- if action_name != 'revert'
|
||||||
= form_tag revert_path(@project, @versions[0][0..6], @versions[1][0..6], @name), :name => "gollum-revert", :id => "gollum-revert-form" do
|
= form_tag revert_path(@project, @versions.first[0..6], (@versions.size == 1) ? 'prev' : @versions.last[0..6], @name), :name => "gollum-revert", :id => "gollum-revert-form" do
|
||||||
= revert_button if can? :write, @project
|
= revert_button if can? :write, @project
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.blob_header
|
.blob_header
|
||||||
.size= h(diff.deleted_file ? diff.a_path : diff.b_path)
|
.size= h(diff.deleted_file ? diff.a_path : diff.b_path).encode_to_default
|
||||||
.clear
|
.clear
|
||||||
.diff_data.highlight= render_diff(diff)
|
.diff_data.highlight= render_diff(diff)
|
|
@ -10,6 +10,3 @@ while read oldrev newrev ref
|
||||||
do
|
do
|
||||||
newrev_type=$(git cat-file -t $newrev 2> /dev/null)
|
newrev_type=$(git cat-file -t $newrev 2> /dev/null)
|
||||||
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
|
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
|
||||||
|
|
||||||
/bin/bash -l -c "cd /srv/rosa_build/current && bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'"
|
|
||||||
done
|
|
|
@ -63,8 +63,9 @@ namespace :deploy do
|
||||||
end
|
end
|
||||||
|
|
||||||
after "deploy:update_code", "deploy:symlink_all", "deploy:migrate"
|
after "deploy:update_code", "deploy:symlink_all", "deploy:migrate"
|
||||||
after "deploy:restart","bluepill:stop", "delayed_job:restart", "deploy:cleanup", "bluepill:start"
|
|
||||||
after "deploy:setup", "deploy:symlink_pids"
|
after "deploy:setup", "deploy:symlink_pids"
|
||||||
|
after "deploy:restart", "bluepill:start" # "bluepill:processes:restart_dj" # "bluepill:restart"
|
||||||
|
after "deploy:restart", "deploy:cleanup"
|
||||||
|
|
||||||
require 'cape'
|
require 'cape'
|
||||||
namespace :rake_tasks do
|
namespace :rake_tasks do
|
||||||
|
|
|
@ -37,7 +37,7 @@ Rosa::Application.configure do
|
||||||
|
|
||||||
# Disable delivery errors, bad email addresses will be ignored
|
# Disable delivery errors, bad email addresses will be ignored
|
||||||
# config.action_mailer.raise_delivery_errors = false
|
# config.action_mailer.raise_delivery_errors = false
|
||||||
config.action_mailer.default_url_options = { :host => 'rosa-build.rosalab.ru' }
|
config.action_mailer.default_url_options = { :host => 'abf.rosalinux.ru' }
|
||||||
|
|
||||||
# Enable threaded mode
|
# Enable threaded mode
|
||||||
# config.threadsafe!
|
# config.threadsafe!
|
||||||
|
|
|
@ -61,7 +61,7 @@ en:
|
||||||
|
|
||||||
downloads:
|
downloads:
|
||||||
title: Downloads statistic
|
title: Downloads statistic
|
||||||
message: Automatically updated every 5 minutes
|
message: Automatically updated every 24 hours
|
||||||
refresh_btn: Refresh
|
refresh_btn: Refresh
|
||||||
|
|
||||||
auto_build_lists:
|
auto_build_lists:
|
||||||
|
@ -422,7 +422,7 @@ en:
|
||||||
list_header: Event log
|
list_header: Event log
|
||||||
|
|
||||||
repositories:
|
repositories:
|
||||||
empty: Empty repository
|
empty: "Repository is empty. You need to wait some time if you have forked project or imported package"
|
||||||
source: Source
|
source: Source
|
||||||
commits: Commits
|
commits: Commits
|
||||||
commit_diff_too_big: Sorry, commit too big!
|
commit_diff_too_big: Sorry, commit too big!
|
||||||
|
@ -813,6 +813,7 @@ en:
|
||||||
product_build_list:
|
product_build_list:
|
||||||
id: Id
|
id: Id
|
||||||
product: Product
|
product: Product
|
||||||
|
container_path: Container
|
||||||
status: Status
|
status: Status
|
||||||
notified_at: Notified at
|
notified_at: Notified at
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ ru:
|
||||||
|
|
||||||
downloads:
|
downloads:
|
||||||
title: Статистика закачек пакетов
|
title: Статистика закачек пакетов
|
||||||
message: Обновляется автоматически каждые 5 минут
|
message: Обновляется автоматически каждые 24 часа
|
||||||
refresh_btn: Обновить
|
refresh_btn: Обновить
|
||||||
|
|
||||||
auto_build_lists:
|
auto_build_lists:
|
||||||
|
@ -289,7 +289,7 @@ ru:
|
||||||
|
|
||||||
git:
|
git:
|
||||||
repositories:
|
repositories:
|
||||||
empty: Пустой репозиторий
|
empty: "Репозиторий пуст. Если вы клонировали(Fork) проект или импортировали пакет, данные скоро появятся"
|
||||||
source: Source
|
source: Source
|
||||||
commits: Commits
|
commits: Commits
|
||||||
commit_diff_too_big: Извините, коммит слишком большой!
|
commit_diff_too_big: Извините, коммит слишком большой!
|
||||||
|
@ -675,6 +675,7 @@ ru:
|
||||||
product_build_list:
|
product_build_list:
|
||||||
id: Id
|
id: Id
|
||||||
product: Продукт
|
product: Продукт
|
||||||
|
container_path: Контейнер
|
||||||
status: Статус
|
status: Статус
|
||||||
notified_at: Информация получена
|
notified_at: Информация получена
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ Bluepill.application(app_name) do |app|
|
||||||
|
|
||||||
process.start_command = "/usr/bin/env RAILS_ENV=production script/delayed_job start"
|
process.start_command = "/usr/bin/env RAILS_ENV=production script/delayed_job start"
|
||||||
process.stop_command = "/usr/bin/env RAILS_ENV=production script/delayed_job stop"
|
process.stop_command = "/usr/bin/env RAILS_ENV=production script/delayed_job stop"
|
||||||
|
process.restart_command = "/usr/bin/env RAILS_ENV=production script/delayed_job restart"
|
||||||
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'delayed_job.pid')
|
process.pid_file = File.join(app.working_dir, 'tmp', 'pids', 'delayed_job.pid')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ Rosa::Application.routes.draw do
|
||||||
post 'freeze'
|
post 'freeze'
|
||||||
post 'unfreeze'
|
post 'unfreeze'
|
||||||
get 'clone'
|
get 'clone'
|
||||||
post 'clone'
|
post 'make_clone'
|
||||||
post 'build_all'
|
post 'build_all'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# runner "Download.parse_and_remove_nginx_log"
|
# runner "Download.parse_and_remove_nginx_log"
|
||||||
#end
|
#end
|
||||||
|
|
||||||
every 5.minutes do
|
every 1.day, :at => '5:00' do
|
||||||
#rake "sudo_test:projects"
|
#rake "sudo_test:projects"
|
||||||
runner "Download.rotate_nginx_log"
|
runner "Download.rotate_nginx_log"
|
||||||
runner "Download.parse_and_remove_nginx_log"
|
runner "Download.parse_and_remove_nginx_log"
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
class WriteGitHookToProjects < ActiveRecord::Migration
|
|
||||||
def self.up
|
|
||||||
origin_hook = File.join(::Rails.root.to_s, 'lib', 'post-receive-hook')
|
|
||||||
Project.all.each do |project|
|
|
||||||
hook_file = File.join(project.path, 'hooks', 'post-receive')
|
|
||||||
FileUtils.cp(origin_hook, hook_file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.down
|
|
||||||
Project.all.each { |project| FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive')}
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
class RemoveOrphanPlatforms < ActiveRecord::Migration
|
|
||||||
def self.up
|
|
||||||
Platform.all.each {|x| x.destroy unless x.owner.present?}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.down
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class RemoveRepositoriesOwner < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
remove_column :repositories, :owner_id
|
||||||
|
remove_column :repositories, :owner_type
|
||||||
|
Relation.delete_all(:target_type => 'Repository')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
add_column :repositories, :owner_id, :integer
|
||||||
|
add_column :repositories, :owner_type, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,11 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
ActiveRecord::Schema.define(:version => 20120214021626) do
|
ActiveRecord::Schema.define(:version => 20120214021626) do
|
||||||
|
=======
|
||||||
|
ActiveRecord::Schema.define(:version => 20120220185458) do
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
@ -295,8 +299,6 @@ ActiveRecord::Schema.define(:version => 20120214021626) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.integer "owner_id"
|
|
||||||
t.string "owner_type"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "rpms", :force => true do |t|
|
create_table "rpms", :force => true do |t|
|
||||||
|
|
|
@ -28,28 +28,32 @@ class BuildServer
|
||||||
self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type)
|
self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.delete_platform name
|
def self.delete_platform name
|
||||||
self.client.call('delete_platform', name)
|
self.client.call('delete_platform', name)
|
||||||
|
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||||
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.clone_platform new_name, old_name, new_root_folder
|
def self.clone_platform new_name, old_name, new_root_folder
|
||||||
self.client.call('clone_platform', new_name, old_name, new_root_folder)
|
self.client.call('clone_platform', new_name, old_name, new_root_folder)
|
||||||
|
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||||
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.create_repo name, platform_name
|
def self.create_repo name, platform_name
|
||||||
self.client.call('create_repository', name, platform_name)
|
self.client.call('create_repository', name, platform_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.delete_repo name, platform_name
|
def self.delete_repo name, platform_name
|
||||||
self.client.call('delete_repository', name, platform_name)
|
self.client.call('delete_repository', name, platform_name)
|
||||||
|
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||||
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.clone_repo new_name, old_name, new_platform_name
|
def self.clone_repo new_name, old_name, new_platform_name
|
||||||
self.client.call('clone_repo', new_name, old_name, new_platform_name)
|
self.client.call('clone_repo', new_name, old_name, new_platform_name)
|
||||||
|
rescue Timeout::Error => e # TODO remove this when core will be ready
|
||||||
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class Object
|
||||||
|
def with_skip
|
||||||
|
begin
|
||||||
|
Thread.current[:skip] = true
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
Thread.current[:skip] = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -87,6 +87,11 @@ module Gollum
|
||||||
end
|
end
|
||||||
alias_method_chain :revert_page, :committer
|
alias_method_chain :revert_page, :committer
|
||||||
|
|
||||||
|
def revert_commit_with_committer(sha1, sha2 = nil, commit = {})
|
||||||
|
revert_page_with_committer(nil, sha1, sha2, commit)
|
||||||
|
end
|
||||||
|
alias_method_chain :revert_commit, :committer
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def force_grit_encoding(str)
|
def force_grit_encoding(str)
|
||||||
|
|
|
@ -16,11 +16,10 @@ module Modules
|
||||||
pl.description = "#{self.uname}_personal"
|
pl.description = "#{self.uname}_personal"
|
||||||
pl.platform_type = 'personal'
|
pl.platform_type = 'personal'
|
||||||
pl.distrib_type = APP_CONFIG['distr_types'].first
|
pl.distrib_type = APP_CONFIG['distr_types'].first
|
||||||
pl.visibility = 'hidden'
|
pl.visibility = 'open'
|
||||||
pl.save!
|
pl.save!
|
||||||
|
|
||||||
rep = pl.repositories.build
|
rep = pl.repositories.build
|
||||||
rep.owner = pl.owner
|
|
||||||
rep.name = 'main'
|
rep.name = 'main'
|
||||||
rep.description = 'main'
|
rep.description = 'main'
|
||||||
rep.save!
|
rep.save!
|
||||||
|
|
|
@ -5,6 +5,10 @@ module Modules
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
|
def create_directory
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def mount_directory_for_rsync
|
def mount_directory_for_rsync
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,9 +3,10 @@ Capistrano::Configuration.instance(:must_exist).load do
|
||||||
namespace :bluepill do
|
namespace :bluepill do
|
||||||
set(:bluepill_binary) {"bundle exec bluepill --no-privileged"}
|
set(:bluepill_binary) {"bundle exec bluepill --no-privileged"}
|
||||||
|
|
||||||
desc "Load bluepill configuration and start it"
|
namespace :processes do
|
||||||
|
desc "Start processes that bluepill is monitoring"
|
||||||
task :start, :roles => [:app] do
|
task :start, :roles => [:app] do
|
||||||
run "cd #{fetch :current_path} && #{try_sudo} APP_NAME=#{fetch :application} #{bluepill_binary} load config/production.pill"
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} start"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Stop processes that bluepill is monitoring"
|
desc "Stop processes that bluepill is monitoring"
|
||||||
|
@ -13,19 +14,35 @@ Capistrano::Configuration.instance(:must_exist).load do
|
||||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop"
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} stop"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Restart processes that bluepill is monitoring"
|
||||||
task :restart, :roles => [:app] do
|
task :restart, :roles => [:app] do
|
||||||
# run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart"
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart"
|
||||||
stop; quit; start
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Stop processes that bluepill is monitoring and quit bluepill"
|
|
||||||
task :quit, :roles => [:app] do
|
|
||||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} quit"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Prints bluepills monitored processes statuses"
|
desc "Prints bluepills monitored processes statuses"
|
||||||
task :status, :roles => [:app] do
|
task :status, :roles => [:app] do
|
||||||
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} status"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Restart DJ process"
|
||||||
|
task :restart_dj, :roles => [:app] do
|
||||||
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} restart delayed_job"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Start a bluepill process and load a config"
|
||||||
|
task :start, :roles => [:app] do
|
||||||
|
run "cd #{fetch :current_path} && #{try_sudo} APP_NAME=#{fetch :application} #{bluepill_binary} load config/production.pill"
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Quit bluepill"
|
||||||
|
task :stop, :roles => [:app] do
|
||||||
|
run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} #{fetch :application} quit"
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Completely restart bluepill and monitored services"
|
||||||
|
task :restart, :roles => [:app] do
|
||||||
|
processes.stop; stop; start
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
require 'highline/import'
|
||||||
|
|
||||||
|
desc "Add branch for platform projects"
|
||||||
|
task :add_branch => :environment do
|
||||||
|
src_branch = ENV['SRC_BRANCH'] || 'import_mandriva2011'
|
||||||
|
dst_branch = ENV['DST_BRANCH'] || 'rosa2012lts'
|
||||||
|
|
||||||
|
say "START add branch #{dst_branch} from #{src_branch}"
|
||||||
|
Platform.find_by_name(dst_branch).repositories.each do |r|
|
||||||
|
say "=== Process #{r.name} repo"
|
||||||
|
r.projects.find_each do |p|
|
||||||
|
say "===== Process #{p.name} project"
|
||||||
|
tmp_path = Rails.root.join('tmp', p.name)
|
||||||
|
system("git clone #{p.path} #{tmp_path}")
|
||||||
|
system("cd #{tmp_path} && git checkout remotes/origin/#{src_branch}") or system("cd #{tmp_path} && git checkout master")
|
||||||
|
system("cd #{tmp_path} && git checkout -b #{dst_branch}")
|
||||||
|
system("cd #{tmp_path} && git push origin HEAD")
|
||||||
|
FileUtils.rm_rf tmp_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
say 'DONE'
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
namespace :hook do
|
||||||
|
desc "Inserting hook to all repos"
|
||||||
|
task :install => :environment do
|
||||||
|
is_production = ENV['RAILS_ENV'] == 'production'
|
||||||
|
say "Generate temporary file..."
|
||||||
|
hook = File.join(::Rails.root.to_s, 'tmp', "post-receive-hook")
|
||||||
|
FileUtils.cp(File.join(::Rails.root.to_s, 'bin', "post-receive-hook.partial"), hook)
|
||||||
|
File.open(hook, 'a') do |f|
|
||||||
|
s = "\n /bin/bash -l -c \"cd #{is_production ? '/srv/rosa_build/current' : Rails.root.to_s} && #{is_production ? 'RAILS_ENV=production' : ''} bundle exec rails runner 'Project.delay.process_hook(\"$owner\", \"$reponame\", \"$newrev\", \"$oldrev\", \"$ref\", \"$newrev_type\", \"$oldrev_type\")'\""
|
||||||
|
s << " > /dev/null 2>&1" if is_production
|
||||||
|
s << "\ndone\n"
|
||||||
|
f.write(s)
|
||||||
|
end
|
||||||
|
|
||||||
|
say "Install process.."
|
||||||
|
count = 0
|
||||||
|
projects = ENV['project_id'] ? Project.where(:id => eval(ENV['project_id'])) : Project
|
||||||
|
projects.where('created_at >= ?', Time.now.ago(ENV['period'] ? eval(ENV['period']) : 100.years)).each do |project|
|
||||||
|
hook_file = File.join(project.path, 'hooks', 'post-receive')
|
||||||
|
FileUtils.cp(hook, hook_file)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
say "Writing to #{count.to_s} repo(s)"
|
||||||
|
say "Removing temporary file"
|
||||||
|
FileUtils.rm_rf(hook)
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "remove git hook from all repos"
|
||||||
|
task :remove => :environment do
|
||||||
|
say "process.."
|
||||||
|
count = 0
|
||||||
|
projects = ENV['project_id'] ? Project.where(:id => eval(ENV['project_id'])) : Project
|
||||||
|
projects.where('created_at >= ?', Time.now.ago(ENV['period'] ? eval(ENV['period']) : 100.years)).each do |project|
|
||||||
|
FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive')
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
say "Done! Removing from #{count.to_s} repo(s)"
|
||||||
|
end
|
||||||
|
end
|
|
@ -47,7 +47,7 @@ namespace :import do
|
||||||
source = "rsync://mirror.yandex.ru/mandriva/#{release}/SRPMS/#{repository}/"
|
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)
|
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}'"
|
say "START rsync projects (*.src.rpm) from '#{source}' to '#{destination}'"
|
||||||
if system "rsync -rtv --delete --exclude='backports/*' --exclude='testing/*' #{source} #{destination}" # --include='*.src.rpm'
|
if system "rsync -rtv --exclude='backports/*' --exclude='testing/*' #{source} #{destination}" # --delete --include='*.src.rpm'
|
||||||
say 'Rsync ok!'
|
say 'Rsync ok!'
|
||||||
else
|
else
|
||||||
say 'Rsync failed!'
|
say 'Rsync failed!'
|
||||||
|
|
|
@ -37,6 +37,7 @@ end
|
||||||
|
|
||||||
describe CollaboratorsController do
|
describe CollaboratorsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
stub_rsync_methods
|
||||||
@project = Factory(:project)
|
@project = Factory(:project)
|
||||||
@another_user = Factory(:user)
|
@another_user = Factory(:user)
|
||||||
@update_params = {:user => {:read => {@another_user.id => '1'}}}
|
@update_params = {:user => {:read => {@another_user.id => '1'}}}
|
||||||
|
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe GroupsController do
|
describe GroupsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
stub_rsync_methods
|
||||||
@group = Factory(:group)
|
@group = Factory(:group)
|
||||||
@another_user = Factory(:user)
|
@another_user = Factory(:user)
|
||||||
@create_params = {:group => {:name => 'grp1', :uname => 'un_grp1'}}
|
@create_params = {:group => {:name => 'grp1', :uname => 'un_grp1'}}
|
||||||
|
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe MembersController do
|
describe MembersController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
stub_rsync_methods
|
||||||
@group = Factory(:group)
|
@group = Factory(:group)
|
||||||
@user = @group.owner
|
@user = @group.owner
|
||||||
set_session_for @user
|
set_session_for @user
|
||||||
|
|
|
@ -92,9 +92,6 @@ describe PersonalRepositoriesController do
|
||||||
|
|
||||||
@project.update_attribute(:owner, @user)
|
@project.update_attribute(:owner, @user)
|
||||||
|
|
||||||
@repository.update_attribute(:owner, @user)
|
|
||||||
@repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
|
||||||
|
|
||||||
@repository.platform.update_attribute(:owner, @user)
|
@repository.platform.update_attribute(:owner, @user)
|
||||||
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
@ -108,7 +105,7 @@ describe PersonalRepositoriesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = Factory(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'personal repository viewer'
|
it_should_behave_like 'personal repository viewer'
|
||||||
|
|
|
@ -79,8 +79,8 @@ describe RepositoriesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = Factory(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.update_attribute(:owner, @user)
|
@repository.platform.update_attribute(:owner, @user)
|
||||||
@repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'repository user with owner rights'
|
it_should_behave_like 'repository user with owner rights'
|
||||||
|
@ -90,7 +90,7 @@ describe RepositoriesController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:user)
|
@user = Factory(:user)
|
||||||
set_session_for(@user)
|
set_session_for(@user)
|
||||||
@repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
@repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'repository user with reader rights'
|
it_should_behave_like 'repository user with reader rights'
|
||||||
|
|
|
@ -3,18 +3,12 @@ Factory.define(:repository) do |p|
|
||||||
p.description { Factory.next(:string) }
|
p.description { Factory.next(:string) }
|
||||||
p.name { Factory.next(:unixname) }
|
p.name { Factory.next(:unixname) }
|
||||||
p.association :platform, :factory => :platform
|
p.association :platform, :factory => :platform
|
||||||
p.association :owner, :factory => :user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define(:personal_repository, :class => Repository) do |p|
|
Factory.define(:personal_repository, :parent => :repository) do |p|
|
||||||
p.description { Factory.next(:string) }
|
p.after_create {|r|
|
||||||
p.name { Factory.next(:unixname) }
|
r.platform.platform_type = 'personal'
|
||||||
p.association :platform, :factory => :platform
|
r.platform.visibility = 'hidden'
|
||||||
p.association :owner, :factory => :user
|
r.platform.save!
|
||||||
|
|
||||||
p.after_create { |rep|
|
|
||||||
rep.platform.platform_type = 'personal'
|
|
||||||
rep.platform.visibility = 'hidden'
|
|
||||||
rep.platform.save!
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -278,24 +278,19 @@ describe CanCan do
|
||||||
|
|
||||||
context 'with owner rights' do
|
context 'with owner rights' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@repository.update_attribute(:owner, @user)
|
@repository.platform.update_attribute(:owner, @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
[:read, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action|
|
[:read, :create, :update, :destroy, :add_project, :remove_project, :change_visibility, :settings].each do |action|
|
||||||
it "should be able to #{action} repository" do
|
it "should be able to #{action} repository" do
|
||||||
@ability.should be_able_to(action, @repository)
|
@ability.should be_able_to(action, @repository)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
|
||||||
@repository.platform.update_attribute(:owner, @user)
|
|
||||||
@ability.should be_able_to(:create, @repository)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with read rights' do
|
context 'with read rights' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@repository.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
@repository.platform.relations.create!(:object_id => @user.id, :object_type => 'User', :role => 'reader')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to read repository" do
|
it "should be able to read repository" do
|
||||||
|
|
|
@ -21,6 +21,7 @@ def set_comments_data_for_commit
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Comment do
|
describe Comment do
|
||||||
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = Factory(:admin)
|
||||||
|
|
|
@ -15,6 +15,7 @@ def set_commentable_data
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Comment do
|
describe Comment do
|
||||||
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = Factory(:admin)
|
||||||
|
|
|
@ -10,14 +10,9 @@ describe Repository do
|
||||||
@params = {:name => 'tst_platform', :description => 'test platform'}
|
@params = {:name => 'tst_platform', :description => 'test platform'}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'it should increase Relations.count by 1' do
|
it 'it should increase Repository.count by 1' do
|
||||||
rep = Repository.new(@params)
|
rep = Repository.create(@params) {|r| r.platform = @platform}
|
||||||
rep.platform = @platform
|
@platform.repositories.count.should eql(1)
|
||||||
rep.owner = @platform.owner
|
|
||||||
rep.save!
|
|
||||||
Relation.by_object(rep.owner).by_target(rep).count.should eql(1)
|
|
||||||
# (@platform.owner.repositories.where(:platform_id => @platform.id).count == 1).should be_true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,7 @@ def set_testable_data
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Subscribe do
|
describe Subscribe do
|
||||||
|
before { stub_rsync_methods }
|
||||||
context 'for global admin user' do
|
context 'for global admin user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@user = Factory(:admin)
|
@user = Factory(:admin)
|
||||||
|
|
Loading…
Reference in New Issue