From cacd9eb3019384eee51b657d4ead54ac884723ac Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 24 Mar 2012 00:48:15 +0200 Subject: [PATCH] Improve add_branch task. Fix projects list JSON generation. Refs #207, #279 --- app/views/repositories/_proj_ajax.js.erb | 2 +- app/views/repositories/_project.js.erb | 2 +- lib/tasks/add_branch.rake | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/repositories/_proj_ajax.js.erb b/app/views/repositories/_proj_ajax.js.erb index ff7e5ff00..9fd8431d4 100644 --- a/app/views/repositories/_proj_ajax.js.erb +++ b/app/views/repositories/_proj_ajax.js.erb @@ -6,7 +6,7 @@ <% @projects.each do |project| %> [ "<%=j link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project) %>", - "<%= truncate(project.description || '', :length => 60).gsub("\n", ' ') %>", + "<%= truncate(project.description || '', :length => 60).gsub("\n", ' ').gsub("\r", ' ') %>", "<%=j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id) %>" ]<%= project == @projects.last ? '' : ',' %> <% end %> diff --git a/app/views/repositories/_project.js.erb b/app/views/repositories/_project.js.erb index 91050c158..11e30ec45 100644 --- a/app/views/repositories/_project.js.erb +++ b/app/views/repositories/_project.js.erb @@ -13,7 +13,7 @@ j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) + "").html_safe %>", - "<%= truncate(project.description || '', :length => 60).gsub("\n", ' ') %>", + "<%= truncate(project.description || '', :length => 60).gsub("\n", ' ').gsub("\r", ' ') %>", "<%= if can? :remove_project, @repository j(link_to(' '.html_safe, diff --git a/lib/tasks/add_branch.rake b/lib/tasks/add_branch.rake index 1a7b96bd5..c8d7cf48d 100644 --- a/lib/tasks/add_branch.rake +++ b/lib/tasks/add_branch.rake @@ -9,12 +9,12 @@ task :add_branch => :environment do Platform.find_by_name(dst_branch).repositories.each do |r| say "=== Process #{r.name} repo" r.projects.find_each do |p| + next if p.branches.map(&:name).include?(dst_branch) say "===== Process #{p.name} project" tmp_path = Rails.root.join('tmp', p.name) system("git clone #{p.path} #{tmp_path}") - system("cd #{tmp_path} && git checkout remotes/origin/#{src_branch}") or system("cd #{tmp_path} && git checkout master") - system("cd #{tmp_path} && git checkout -b #{dst_branch}") - system("cd #{tmp_path} && git push origin HEAD") + system("cd #{tmp_path} && git checkout remotes/origin/#{src_branch} || git checkout master") + system("cd #{tmp_path} && git checkout -b #{dst_branch} && git push origin HEAD") FileUtils.rm_rf tmp_path end end