diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index 7136d9ba0..e5ddd6858 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -128,7 +128,7 @@ class BuildListsController < ApplicationController def find_project_versions @git_repository = @project.git_repository - @project_versions = @project.project_versions + @project_versions = @project.collected_project_versions end def find_build_list_by_bs diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6b13c837c..56f523833 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -64,21 +64,12 @@ class ProjectsController < ApplicationController uname, unixname = params[:git_repo].split('/') owner = User.find_by_uname(uname) || Group.find_by_uname(uname) project = Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_unixname!(unixname) - auto_build_list = AutoBuildList.find_by_project_id(project.id) + project.auto_build # p = params.delete_if{|k,v| k == 'controller' or k == 'action'} # ActiveSupport::Notifications.instrument("event_log.observer", :object => project, :message => p.inspect) logger.info "Git hook recieved from #{params[:git_user]} to #{params[:git_repo]}" - BuildList.create!( - :project => project, - :pl => auto_build_list.pl, - :bpl => auto_build_list.bpl, - :arch => auto_build_list.arch, - :project_version => project.collected_project_versions.last.try(:first), - :build_requires => true, - :update_type => 'bugfix') if auto_build_list - render :nothing => true end diff --git a/app/models/project.rb b/app/models/project.rb index ba0ae7039..28e7712fe 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -42,18 +42,30 @@ class Project < ActiveRecord::Base after_destroy :destroy_git_repo after_rollback lambda { destroy_git_repo rescue true if new_record? } + def auto_build + auto_build_lists.each do |auto_build_list| + build_lists.create( + :pl => auto_build_list.pl, + :bpl => auto_build_list.bpl, + :arch => auto_build_list.arch, + :project_version => collected_project_versions.last, + :build_requires => true, + :update_type => 'bugfix') + end + end + def project_versions - res = tags.select { |tag| tag.name =~ /^v\./ } + res = tags.select{|tag| tag.name =~ /^v\./} return res if res and res.size > 0 tags end - + def collected_project_versions - project_versions.collect { |tag| new_tag = tag.name.gsub(/^\w+\./, ""); [new_tag, new_tag] } + project_versions.collect{|tag| tag.name.gsub(/^\w+\./, "")} end def tags - self.git_repository.tags + self.git_repository.tags.sort_by(&:name) end def members diff --git a/app/views/build_lists/_filter.html.haml b/app/views/build_lists/_filter.html.haml index 65bb3745d..07e8a1b73 100644 --- a/app/views/build_lists/_filter.html.haml +++ b/app/views/build_lists/_filter.html.haml @@ -16,7 +16,7 @@ - if @project_versions .group = f.label :project_version, t("activerecord.attributes.build_list.project_version"), :class => :label - = f.select :project_version, @project_versions.collect{|project_version| [project_version.name, project_version.name]}, :include_blank => true, :selected => @filter.project_version + = f.select :project_version, @project_versions, :include_blank => true, :selected => @filter.project_version .group = f.label :is_circle, t("activerecord.attributes.build_list.is_circle"), :class => :label