[ref #505] Refactor set_version_and_tag. Rename success and error events

This commit is contained in:
konstantin.grabar 2012-06-14 17:36:40 +04:00
parent 76b261638f
commit 5acc13e9a6
2 changed files with 8 additions and 6 deletions

View File

@ -95,7 +95,6 @@ class Projects::BuildListsController < Projects::BaseController
def publish_build
if params[:status].to_i == 0 # ok
@build_list.published
@build_list.set_version_and_tag params[:version], params[:release]
else
@build_list.failed_publish
end
@ -123,7 +122,7 @@ class Projects::BuildListsController < Projects::BaseController
end
def post_build
params[:status] == BuildServer::SUCCESS ? @build_list.success : @build_list.error
params[:status] == BuildServer::SUCCESS ? @build_list.build_success : @build_list.build_error
@build_list.container_path = params[:container_path]
@build_list.save

View File

@ -105,6 +105,8 @@ class BuildList < ActiveRecord::Base
state_machine :status, :initial => :waiting_for_response do
after_transition :on => :published, :do => :set_version_and_tag
event :place_build do
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
build_list.add_to_queue == BUILD_PENDING
@ -156,11 +158,11 @@ class BuildList < ActiveRecord::Base
transition :success => :rejected_publish, :if => :can_reject_publish?
end
event :success do
event :build_success do
transition [:build_started, :build_canceled] => :success
end
event :error do
event :build_error do
transition [:build_started, :build_canceled] => :build_error
end
@ -185,8 +187,9 @@ class BuildList < ActiveRecord::Base
@status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority
end
def set_version_and_tag(version, release)
self.package_version = "#{version}-#{release}"
def set_version_and_tag
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
self.package_version = "#{pkg.platform.name}-#{pkg.version}-#{pkg.release}"
system("cd #{self.project.git_repository.path} && git tag #{self.package_version} #{self.commit_hash}") # TODO REDO through grit
save
end