From 3a2215d0ee8efe0ad6424b1eb393772bd67be772 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 30 Nov 2011 02:22:26 +0200 Subject: [PATCH] Redo project versions to use tags and branches for build. Refs #2261 --- app/controllers/build_lists_controller.rb | 2 +- app/controllers/projects_controller.rb | 4 ++-- app/models/project.rb | 14 +++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index b0fb4ebe6..147b6abf8 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -126,7 +126,7 @@ class BuildListsController < ApplicationController def find_project_versions @git_repository = @project.git_repository - @project_versions = @project.collected_project_versions + @project_versions = @project.versions end def find_build_list_by_bs diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index aa98dbca9..91e8aca9a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -99,7 +99,7 @@ class ProjectsController < ApplicationController @arches = Arch.recent @bpls = Platform.main @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.name}", rep.platform.id] } - @project_versions = @project.collected_project_versions + @project_versions = @project.versions end def process_build @@ -115,7 +115,7 @@ class ProjectsController < ApplicationController update_type = params[:build][:update_type] build_requires = params[:build][:build_requires] - @project_versions = @project.collected_project_versions + @project_versions = @project.versions if !check_arches || !check_project_versions @arches = Arch.recent diff --git a/app/models/project.rb b/app/models/project.rb index 61228f5c8..6ab460bee 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -48,18 +48,26 @@ class Project < ActiveRecord::Base end end + # TODO deprecate and remove project_versions and collected_project_versions ? def project_versions res = tags.select{|tag| tag.name =~ /^v\./} return res if res and res.size > 0 tags - end - + end def collected_project_versions project_versions.collect{|tag| tag.name.gsub(/^\w+\./, "")} end def tags - self.git_repository.tags.sort_by{|t| t.name.gsub(/[a-zA-Z.]+/, '').to_i} + self.git_repository.tags #.sort_by{|t| t.name.gsub(/[a-zA-Z.]+/, '').to_i} + end + + def branches + self.git_repository.branches + end + + def versions + tags.map(&:name) + branches.map{|b| "latest_#{b.name}"} end def members