#306: Increase release tag for mass builds
This commit is contained in:
parent
fed669d14d
commit
b3c8265593
|
@ -13,11 +13,11 @@ class MassBuild < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessor :arches
|
attr_accessor :arches
|
||||||
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
|
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
|
||||||
:extra_repositories, :extra_build_lists
|
:extra_repositories, :extra_build_lists, :increase_release_tag
|
||||||
|
|
||||||
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, :presence => true
|
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, :presence => true
|
||||||
validates :projects_list, :length => {:maximum => 500_000}, :presence => true
|
validates :projects_list, :length => {:maximum => 500_000}, :presence => true
|
||||||
validates_inclusion_of :auto_publish, :in => [true, false]
|
validates_inclusion_of :auto_publish, :increase_release_tag, :in => [true, false]
|
||||||
|
|
||||||
after_commit :build_all, :on => :create
|
after_commit :build_all, :on => :create
|
||||||
before_validation :set_data, :on => :create
|
before_validation :set_data, :on => :create
|
||||||
|
@ -46,7 +46,7 @@ class MassBuild < ActiveRecord::Base
|
||||||
return if self.reload.stop_build
|
return if self.reload.stop_build
|
||||||
arches_list.each do |arch|
|
arches_list.each do |arch|
|
||||||
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
|
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
|
||||||
project.build_for(build_for_platform, save_to_platform, rep_id, user, arch, auto_publish?, self, 0)
|
project.build_for self, rep_id, arch
|
||||||
end
|
end
|
||||||
rescue RuntimeError, Exception
|
rescue RuntimeError, Exception
|
||||||
end
|
end
|
||||||
|
|
|
@ -151,7 +151,10 @@ class Project < ActiveRecord::Base
|
||||||
#path #share by NFS
|
#path #share by NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_for(build_for_platform, save_to_platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build = nil, priority = 0)
|
def build_for(mass_build, repository_id, arch = Arch.find_by_name('i586'), priority = 0)
|
||||||
|
build_for_platform = mass_build.build_for_platform
|
||||||
|
save_to_platform = mass_build.save_to_platform
|
||||||
|
user = mass_build.user
|
||||||
# Select main and project platform repository(contrib, non-free and etc)
|
# Select main and project platform repository(contrib, non-free and etc)
|
||||||
# If main does not exist, will connect only project platform repository
|
# If main does not exist, will connect only project platform repository
|
||||||
# If project platform repository is main, only main will be connect
|
# If project platform repository is main, only main will be connect
|
||||||
|
@ -166,6 +169,8 @@ class Project < ActiveRecord::Base
|
||||||
default_branch
|
default_branch
|
||||||
end
|
end
|
||||||
|
|
||||||
|
increase_release_tag(project_version, user, "MassBuild##{mass_build.id}: Increase release tag") if mass_build.increase_release_tag?
|
||||||
|
|
||||||
build_list = build_lists.build do |bl|
|
build_list = build_lists.build do |bl|
|
||||||
bl.save_to_platform = save_to_platform
|
bl.save_to_platform = save_to_platform
|
||||||
bl.build_for_platform = build_for_platform
|
bl.build_for_platform = build_for_platform
|
||||||
|
@ -173,7 +178,7 @@ class Project < ActiveRecord::Base
|
||||||
bl.arch = arch
|
bl.arch = arch
|
||||||
bl.project_version = project_version
|
bl.project_version = project_version
|
||||||
bl.user = user
|
bl.user = user
|
||||||
bl.auto_publish = auto_publish
|
bl.auto_publish = mass_build.auto_publish?
|
||||||
bl.include_repos = include_repos
|
bl.include_repos = include_repos
|
||||||
bl.extra_repositories = mass_build.extra_repositories
|
bl.extra_repositories = mass_build.extra_repositories
|
||||||
bl.extra_build_lists = mass_build.extra_build_lists
|
bl.extra_build_lists = mass_build.extra_build_lists
|
||||||
|
@ -248,6 +253,24 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def increase_release_tag(project_version, user, message)
|
||||||
|
blob = repo.tree(project_version).contents.find{ |n| n.is_a?(Grit::Blob) && n.name =~ /.spec$/ }
|
||||||
|
return unless blob
|
||||||
|
|
||||||
|
raw = Grit::GitRuby::Repository.new(repo.path).get_raw_object_by_sha1(blob.id)
|
||||||
|
content = raw.content.clone
|
||||||
|
content.gsub!(/^Release:(\s+)(%mkrel\s+)?(\d+)(mdk)?$/) { |line| "Release:#{$1}#{$3.to_i + 1}#{$4}" }
|
||||||
|
content.gsub!(/^%define\s+release:?(\s+)(%mkrel\s+)?(\d+)(mdk)?$/) { |line| "%define release #{$1}#{$3.to_i + 1}#{$4}" }
|
||||||
|
|
||||||
|
return if content == raw.content
|
||||||
|
|
||||||
|
update_file(blob.name, content.gsub("\r", ''),
|
||||||
|
:message => message,
|
||||||
|
:actor => user,
|
||||||
|
:head => project_version
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def create_archive(treeish, format)
|
def create_archive(treeish, format)
|
||||||
file_name = "#{name}-#{treeish}"
|
file_name = "#{name}-#{treeish}"
|
||||||
fullname = "#{file_name}.#{tag_file_format(format)}"
|
fullname = "#{file_name}.#{tag_file_format(format)}"
|
||||||
|
|
|
@ -46,15 +46,10 @@
|
||||||
-if mass_build.projects_list.present?
|
-if mass_build.projects_list.present?
|
||||||
= link_to_list @platform, mass_build, 'projects_list'
|
= link_to_list @platform, mass_build, 'projects_list'
|
||||||
.both
|
.both
|
||||||
= t('activerecord.attributes.mass_build.arch_names') + ": "
|
|
||||||
= mass_build.arch_names
|
|
||||||
.both
|
|
||||||
= t('activerecord.attributes.mass_build.user') + ": "
|
= t('activerecord.attributes.mass_build.user') + ": "
|
||||||
= link_to mass_build.user.fullname, mass_build.user
|
= link_to mass_build.user.fullname, mass_build.user
|
||||||
.both
|
- [:arch_names, :auto_publish, :increase_release_tag, :created_at].each do |field|
|
||||||
= t('activerecord.attributes.mass_build.auto_publish') + ": "
|
.both
|
||||||
= mass_build.auto_publish
|
= t("activerecord.attributes.mass_build.#{field}") + ": "
|
||||||
.both
|
= mass_build.send field
|
||||||
= t('activerecord.attributes.mass_build.created_at') + ": "
|
|
||||||
= mass_build.created_at
|
|
||||||
= will_paginate @mass_builds
|
= will_paginate @mass_builds
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
:subject => @mass_build,
|
:subject => @mass_build,
|
||||||
:autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
:autocomplete_path => autocomplete_extra_build_list_autocompletes_path
|
||||||
%h3= t("activerecord.attributes.build_list.preferences")
|
%h3= t("activerecord.attributes.build_list.preferences")
|
||||||
.both
|
- [:auto_publish, :increase_release_tag].each do |field|
|
||||||
= f.check_box :auto_publish
|
.both
|
||||||
= f.label :auto_publish
|
= f.check_box field
|
||||||
|
= f.label field
|
||||||
.both
|
.both
|
||||||
|
|
|
@ -24,5 +24,6 @@ en:
|
||||||
arch_names: Architectures
|
arch_names: Architectures
|
||||||
user: User
|
user: User
|
||||||
auto_publish: Automated publishing
|
auto_publish: Automated publishing
|
||||||
|
increase_release_tag: Increase release tag
|
||||||
repositories: Repositories
|
repositories: Repositories
|
||||||
projects_list: Projects list
|
projects_list: Projects list
|
||||||
|
|
|
@ -24,5 +24,6 @@ ru:
|
||||||
arch_names: Архитектуры
|
arch_names: Архитектуры
|
||||||
user: Пользователь
|
user: Пользователь
|
||||||
auto_publish: Автоматическая публикация
|
auto_publish: Автоматическая публикация
|
||||||
|
increase_release_tag: Увеличить release тег
|
||||||
repositories: Репозитории
|
repositories: Репозитории
|
||||||
projects_list: Список проектов
|
projects_list: Список проектов
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddIncreaseReleaseTagToMassBuild < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :mass_builds, :increase_release_tag, :boolean, :default => false, :null => false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130912113545) do
|
ActiveRecord::Schema.define(:version => 20130918164616) do
|
||||||
|
|
||||||
create_table "activity_feeds", :force => true do |t|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -294,6 +294,7 @@ ActiveRecord::Schema.define(:version => 20130912113545) do
|
||||||
t.integer "save_to_platform_id", :null => false
|
t.integer "save_to_platform_id", :null => false
|
||||||
t.text "extra_repositories"
|
t.text "extra_repositories"
|
||||||
t.text "extra_build_lists"
|
t.text "extra_build_lists"
|
||||||
|
t.boolean "increase_release_tag", :default => false, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "platform_arch_settings", :force => true do |t|
|
create_table "platform_arch_settings", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue