2012-03-18 08:20:31 +00:00
|
|
|
module BuildListsHelper
|
2013-08-01 23:24:33 +01:00
|
|
|
|
|
|
|
# See: app/assets/javascripts/angularjs/models/build_list.js.erb
|
2012-03-18 08:20:31 +00:00
|
|
|
def build_list_status_color(status)
|
2013-02-06 09:42:34 +00:00
|
|
|
case status
|
2013-11-05 18:41:46 +00:00
|
|
|
when BuildList::BUILD_PUBLISHED, BuildList::SUCCESS, BuildList::BUILD_PUBLISHED_INTO_TESTING
|
2013-02-06 09:42:34 +00:00
|
|
|
'success'
|
2013-11-05 18:41:46 +00:00
|
|
|
when BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH, BuildList::FAILED_PUBLISH_INTO_TESTING
|
2013-02-06 09:42:34 +00:00
|
|
|
'error'
|
|
|
|
when BuildList::TESTS_FAILED
|
|
|
|
'warning'
|
|
|
|
else
|
|
|
|
'nocolor'
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-04 19:25:07 +01:00
|
|
|
def availables_main_platforms
|
|
|
|
# Main platforms with repositories
|
|
|
|
Platform.main.accessible_by(current_ability, :show)
|
2013-08-06 18:45:33 +01:00
|
|
|
.includes(:repositories).where('repositories.id IS NOT NULL').order('platforms.name').uniq
|
2013-07-04 19:25:07 +01:00
|
|
|
end
|
|
|
|
|
2013-07-25 08:37:16 +01:00
|
|
|
def save_to_repositories(project)
|
|
|
|
project.repositories.collect do |r|
|
|
|
|
[
|
|
|
|
"#{r.platform.name}/#{r.name}",
|
|
|
|
r.id,
|
|
|
|
{
|
|
|
|
:publish_without_qa => r.publish_without_qa? ? 1 : 0,
|
|
|
|
:platform_id => r.platform.id,
|
2013-07-31 20:17:38 +01:00
|
|
|
:default_arches => (r.platform.platform_arch_settings.by_default.pluck(:arch_id).presence || Arch.where(:name => Arch::DEFAULT).pluck(:id)).join(' ')
|
2013-07-25 08:37:16 +01:00
|
|
|
}
|
|
|
|
]
|
2013-08-06 17:53:32 +01:00
|
|
|
end.sort_by { |col| col[0] }
|
2013-07-25 08:37:16 +01:00
|
|
|
end
|
|
|
|
|
2013-10-17 19:00:15 +01:00
|
|
|
def external_nodes
|
|
|
|
BuildList::EXTERNAL_NODES.map do |type|
|
|
|
|
[I18n.t("layout.build_lists.external_nodes.#{type}"), type]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-01 23:38:24 +01:00
|
|
|
def mass_build_options
|
2013-07-04 19:25:07 +01:00
|
|
|
options_from_collection_for_select(
|
|
|
|
MassBuild.recent.limit(15),
|
|
|
|
:id,
|
2013-08-01 23:38:24 +01:00
|
|
|
:name
|
2013-07-04 19:25:07 +01:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-12-10 12:15:22 +00:00
|
|
|
def build_list_options_for_new_core
|
|
|
|
[
|
|
|
|
[I18n.t("layout.true_"), 1],
|
|
|
|
[I18n.t("layout.false_"), 0]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2012-03-18 08:20:31 +00:00
|
|
|
def build_list_item_status_color(status)
|
2013-02-06 09:42:34 +00:00
|
|
|
case status
|
|
|
|
when BuildList::SUCCESS
|
|
|
|
'success'
|
2013-11-05 18:41:46 +00:00
|
|
|
when BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR #, BuildList::DEPENDENCIES_ERROR
|
2013-02-06 09:42:34 +00:00
|
|
|
'error'
|
|
|
|
else
|
|
|
|
''
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|
|
|
|
end
|
2012-07-06 00:05:47 +01:00
|
|
|
|
|
|
|
def build_list_classified_update_types
|
|
|
|
advisoriable = BuildList::RELEASE_UPDATE_TYPES.map do |el|
|
|
|
|
[el, {:class => 'advisoriable'}]
|
|
|
|
end
|
|
|
|
nonadvisoriable = (BuildList::UPDATE_TYPES - BuildList::RELEASE_UPDATE_TYPES).map do |el|
|
|
|
|
[el, {:class => 'nonadvisoriable'}]
|
|
|
|
end
|
|
|
|
|
|
|
|
return advisoriable + nonadvisoriable
|
|
|
|
end
|
2012-07-09 21:43:01 +01:00
|
|
|
|
2012-12-04 16:13:55 +00:00
|
|
|
def build_list_item_version_link(item, str_version = false)
|
|
|
|
hash_size=5
|
|
|
|
if item.version =~ /^[\da-z]+$/ && item.name == item.build_list.project.name
|
|
|
|
bl = item.build_list
|
2013-08-19 20:30:37 +01:00
|
|
|
{
|
|
|
|
:text => str_version ? "#{shortest_hash_id item.version, hash_size}" : shortest_hash_id(item.version, hash_size),
|
|
|
|
:href => commit_path(bl.project.owner, bl.project, item.version)
|
|
|
|
}
|
2012-12-04 16:13:55 +00:00
|
|
|
else
|
2013-08-19 20:30:37 +01:00
|
|
|
{}
|
2012-12-04 16:13:55 +00:00
|
|
|
end
|
2013-02-14 16:59:52 +00:00
|
|
|
end
|
2012-12-04 16:13:55 +00:00
|
|
|
|
2012-11-12 16:23:11 +00:00
|
|
|
def build_list_version_link(bl, str_version = false)
|
2012-12-03 18:09:36 +00:00
|
|
|
hash_size=5
|
2012-11-12 16:23:11 +00:00
|
|
|
if bl.commit_hash.present?
|
2013-11-22 10:03:48 +00:00
|
|
|
if bl.last_published_commit_hash.present? && bl.last_published_commit_hash != bl.commit_hash
|
2012-12-03 18:09:36 +00:00
|
|
|
link_to "#{shortest_hash_id bl.last_published_commit_hash, hash_size}...#{shortest_hash_id bl.commit_hash, hash_size}",
|
2012-12-03 17:43:24 +00:00
|
|
|
diff_path(bl.project.owner, bl.project, bl.last_published_commit_hash) + "...#{bl.commit_hash}"
|
|
|
|
else
|
2012-12-03 18:09:36 +00:00
|
|
|
link_to str_version ? "#{shortest_hash_id bl.commit_hash, hash_size}" : shortest_hash_id(bl.commit_hash, hash_size),
|
2012-12-03 17:43:24 +00:00
|
|
|
commit_path(bl.project.owner, bl.project, bl.commit_hash)
|
|
|
|
end
|
2012-07-09 21:43:01 +01:00
|
|
|
else
|
2012-11-12 16:23:11 +00:00
|
|
|
bl.project_version
|
2012-07-09 21:43:01 +01:00
|
|
|
end
|
|
|
|
end
|
2012-08-13 22:41:15 +01:00
|
|
|
|
2012-12-04 03:07:18 +00:00
|
|
|
def product_build_list_version_link(bl, str_version = false)
|
|
|
|
if bl.commit_hash.present?
|
|
|
|
link_to str_version ? "#{shortest_hash_id bl.commit_hash} ( #{bl.project_version} )" : shortest_hash_id(bl.commit_hash),
|
|
|
|
commit_path(bl.project.owner, bl.project, bl.commit_hash)
|
|
|
|
else
|
|
|
|
bl.project_version
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-07 11:24:13 +01:00
|
|
|
def container_url(build_list = @build_list)
|
2013-07-19 19:20:27 +01:00
|
|
|
url = "#{APP_CONFIG['downloads_url']}/#{build_list.save_to_platform.name}/container/#{build_list.id}/"
|
2013-12-03 10:55:08 +00:00
|
|
|
url << "#{build_list.arch.name}/#{build_list.save_to_repository.name}/release/" if build_list.build_for_platform.try(:distrib_type) == 'mdv'
|
2013-05-07 11:24:13 +01:00
|
|
|
url.html_safe
|
2012-08-13 22:41:15 +01:00
|
|
|
end
|
|
|
|
|
2013-02-22 14:29:22 +00:00
|
|
|
def can_publish_in_future?(bl)
|
2013-11-21 10:57:33 +00:00
|
|
|
[
|
|
|
|
BuildList::SUCCESS,
|
|
|
|
BuildList::FAILED_PUBLISH,
|
|
|
|
BuildList::BUILD_PUBLISHED,
|
|
|
|
BuildList::TESTS_FAILED,
|
|
|
|
BuildList::BUILD_PUBLISHED_INTO_TESTING
|
|
|
|
].include?(bl.status)
|
2013-02-22 14:29:22 +00:00
|
|
|
end
|
|
|
|
|
2012-08-13 22:41:15 +01:00
|
|
|
def log_reload_time_options
|
|
|
|
t = I18n.t("layout.build_lists.log.reload_times").map { |i| i.reverse }
|
|
|
|
|
|
|
|
options_for_select(t, t.first).html_safe
|
|
|
|
end
|
2012-08-17 09:23:49 +01:00
|
|
|
|
|
|
|
def log_reload_lines_options
|
|
|
|
options_for_select([100, 200, 500, 1000, 1500, 2000], 1000).html_safe
|
|
|
|
end
|
2013-02-14 16:59:52 +00:00
|
|
|
|
|
|
|
def get_version_release build_list
|
2013-07-04 19:25:07 +01:00
|
|
|
pkg = build_list.source_packages.first
|
2013-02-14 16:59:52 +00:00
|
|
|
"#{pkg.version}-#{pkg.release}" if pkg.present?
|
|
|
|
end
|
2012-03-18 08:20:31 +00:00
|
|
|
end
|