From 4553affa5607ab76f8540b688c3316bbd87ef43a Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 22 Mar 2012 19:11:12 +0200 Subject: [PATCH] Add missing magic_encodings. Fix blame commit select, hide blank blame. Fix git repo hooks - redo branch parse to support non-ascii branches. Refs #190, #134 --- Gemfile | 2 +- app/controllers/activity_feeds_controller.rb | 1 + app/controllers/admin/users_controller.rb | 2 +- app/controllers/git/blobs_controller.rb | 4 ++-- app/helpers/activity_feeds_helper.rb | 1 + app/helpers/build_lists_helper.rb | 1 + app/models/activity_feed.rb | 1 + app/models/activity_feed_observer.rb | 3 ++- app/models/label.rb | 1 + app/models/labeling.rb | 1 + app/views/git/blobs/blame.html.haml | 2 +- db/migrate/20120124065207_create_activity_feeds.rb | 1 + db/migrate/20120219161749_add_creator_to_issue.rb | 1 + db/migrate/20120220175615_create_labels.rb | 1 + db/migrate/20120220185458_remove_repositories_owner.rb | 1 + db/migrate/20120228094721_add_closed_at_to_issue.rb | 1 + db/migrate/20120228100121_add_closed_by_to_issue.rb | 1 + db/migrate/20120229163054_add_description_to_groups.rb | 1 + ...0120229182356_add_default_values_to_is_rpm_for_projects.rb | 1 + db/migrate/20120302102734_remove_name_from_groups.rb | 1 + .../20120302114735_add_professional_experience_to_users.rb | 1 + .../20120303062601_add_site_company_and_location_to_users.rb | 1 + db/migrate/20120303171802_add_avatar_to_users.rb | 1 + db/migrate/20120306212914_add_project_to_comment.rb | 1 + db/migrate/20120313130930_delete_dublicate_subscribes.rb | 1 + db/migrate/20120314151558_truncate_activity_feed.rb | 1 + db/migrate/20120314162313_add_description_to_products.rb | 1 + db/migrate/20120314223151_remove_is_template_from_products.rb | 1 + db/migrate/20120320102912_add_build_list_priority.rb | 3 ++- db/migrate/20120321130436_add_devise_lockable.rb | 1 + db/schema.rb | 2 +- lib/ext/core/object.rb | 1 + lib/ext/gollum.rb | 1 + lib/ext/grit.rb | 1 + spec/controllers/activity_feeds_controller_spec.rb | 1 + spec/factories/activity_feeds.rb | 3 ++- spec/helpers/activity_feeds_helper_spec.rb | 1 + spec/helpers/build_lists_helper_spec.rb | 1 + spec/models/activity_feed_observer_spec.rb | 1 + spec/models/activity_feed_spec.rb | 1 + spec/models/labels_spec.rb | 1 + 41 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index f47bdcef5..c497001b2 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ gem 'rails-xmlrpc', '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc. # gem 'rugged', '~> 0.16.0' gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http' -gem "grit", :git => 'git://github.com/chipiga/grit.git' +gem "grit", :git => 'git://github.com/chipiga/grit.git' #, :path => '~/Sites/code/grit' gem 'charlock_holmes', '~> 0.6.8' #, :git => 'git://github.com/brianmario/charlock_holmes.git', :branch => 'bundle-icu' # Wiki diff --git a/app/controllers/activity_feeds_controller.rb b/app/controllers/activity_feeds_controller.rb index ccdf38127..24ab280ab 100644 --- a/app/controllers/activity_feeds_controller.rb +++ b/app/controllers/activity_feeds_controller.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ActivityFeedsController < ApplicationController before_filter :authenticate_user! diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 1b8de596d..7e06a298c 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -67,4 +67,4 @@ class Admin::UsersController < ApplicationController render :partial =>'users_ajax', :layout => false end -end \ No newline at end of file +end diff --git a/app/controllers/git/blobs_controller.rb b/app/controllers/git/blobs_controller.rb index 0ad168508..4be95c11c 100644 --- a/app/controllers/git/blobs_controller.rb +++ b/app/controllers/git/blobs_controller.rb @@ -37,7 +37,7 @@ class Git::BlobsController < Git::BaseController end def blame - @blame = Grit::Blob.blame(@git_repository.repo, @commit.try(:id), @path) + @blame = Grit::Blob.blame(@git_repository.repo, @commit.id, @path) end def raw @@ -55,10 +55,10 @@ class Git::BlobsController < Git::BaseController def set_path_blob @path = params[:path] @blob = @tree / @path + @commit = @git_repository.log(@treeish, @path, :max_count => 1).first end def find_tree @tree = @git_repository.tree(@treeish) - @commit = @git_repository.log(@treeish, @path, :max_count => 1).first # TODO WTF nil ? end end diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb index 8880830d7..8680fcbac 100644 --- a/app/helpers/activity_feeds_helper.rb +++ b/app/helpers/activity_feeds_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module ActivityFeedsHelper def render_activity_feed(activity_feed) render :partial => activity_feed.partial, :locals => activity_feed.data.merge(:activity_feed => activity_feed) diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index ec670a549..fc2a5e9cd 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module BuildListsHelper def build_list_status_color(status) if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS].include? status diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb index 3bd57217c..3b2b74e3e 100644 --- a/app/models/activity_feed.rb +++ b/app/models/activity_feed.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ActivityFeed < ActiveRecord::Base CODE = ['git_delete_branch_notification', 'git_new_push_notification', 'new_comment_commit_notification'] diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index b97d90450..dbbe8a189 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class ActivityFeedObserver < ActiveRecord::Observer observe :issue, :comment, :user, :build_list @@ -70,7 +71,7 @@ class ActivityFeedObserver < ActiveRecord::Observer when 'GitHook' change_type = record.change_type - branch_name = record.refname.match(/\/([\w\d]+)$/)[1] + branch_name = record.refname.split('/').last last_commits = record.project.git_repository.repo.log(branch_name, nil).first(3) first_commiter = User.find_by_email(last_commits[0].author.email) unless last_commits.blank? diff --git a/app/models/label.rb b/app/models/label.rb index cc031d15a..e5fe686f2 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Label < ActiveRecord::Base has_many :labelings, :dependent => :destroy has_many :issues, :through => :labelings diff --git a/app/models/labeling.rb b/app/models/labeling.rb index d03b0c6b3..acc688f68 100644 --- a/app/models/labeling.rb +++ b/app/models/labeling.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Labeling < ActiveRecord::Base belongs_to :issue belongs_to :label diff --git a/app/views/git/blobs/blame.html.haml b/app/views/git/blobs/blame.html.haml index 1eb9109f4..27e748ee4 100644 --- a/app/views/git/blobs/blame.html.haml +++ b/app/views/git/blobs/blame.html.haml @@ -22,4 +22,4 @@ - render_way = choose_render_way(@blob) .file .top= render 'top', :render_way => render_way - .blame_data= render 'blame_table' + .blame_data= render 'blame_table' if @blame.first.first.present? diff --git a/db/migrate/20120124065207_create_activity_feeds.rb b/db/migrate/20120124065207_create_activity_feeds.rb index d5b13fc3a..6037a0d14 100644 --- a/db/migrate/20120124065207_create_activity_feeds.rb +++ b/db/migrate/20120124065207_create_activity_feeds.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class CreateActivityFeeds < ActiveRecord::Migration def self.up create_table :activity_feeds do |t| diff --git a/db/migrate/20120219161749_add_creator_to_issue.rb b/db/migrate/20120219161749_add_creator_to_issue.rb index 54a3ba492..ccf0a1ef8 100644 --- a/db/migrate/20120219161749_add_creator_to_issue.rb +++ b/db/migrate/20120219161749_add_creator_to_issue.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddCreatorToIssue < ActiveRecord::Migration def change add_column :issues, :creator_id, :integer diff --git a/db/migrate/20120220175615_create_labels.rb b/db/migrate/20120220175615_create_labels.rb index b10b80ea7..ea91650c6 100644 --- a/db/migrate/20120220175615_create_labels.rb +++ b/db/migrate/20120220175615_create_labels.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class CreateLabels < ActiveRecord::Migration def change create_table :labels do |t| diff --git a/db/migrate/20120220185458_remove_repositories_owner.rb b/db/migrate/20120220185458_remove_repositories_owner.rb index 88c85a855..79d0d3e58 100644 --- a/db/migrate/20120220185458_remove_repositories_owner.rb +++ b/db/migrate/20120220185458_remove_repositories_owner.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class RemoveRepositoriesOwner < ActiveRecord::Migration def self.up remove_column :repositories, :owner_id diff --git a/db/migrate/20120228094721_add_closed_at_to_issue.rb b/db/migrate/20120228094721_add_closed_at_to_issue.rb index 91948e2af..e0fe478a4 100644 --- a/db/migrate/20120228094721_add_closed_at_to_issue.rb +++ b/db/migrate/20120228094721_add_closed_at_to_issue.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddClosedAtToIssue < ActiveRecord::Migration def change add_column :issues, :closed_at, :datetime diff --git a/db/migrate/20120228100121_add_closed_by_to_issue.rb b/db/migrate/20120228100121_add_closed_by_to_issue.rb index 9da79b29b..d0f815d70 100644 --- a/db/migrate/20120228100121_add_closed_by_to_issue.rb +++ b/db/migrate/20120228100121_add_closed_by_to_issue.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddClosedByToIssue < ActiveRecord::Migration def change add_column :issues, :closed_by, :integer diff --git a/db/migrate/20120229163054_add_description_to_groups.rb b/db/migrate/20120229163054_add_description_to_groups.rb index 16662758f..481c855c5 100644 --- a/db/migrate/20120229163054_add_description_to_groups.rb +++ b/db/migrate/20120229163054_add_description_to_groups.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddDescriptionToGroups < ActiveRecord::Migration def change add_column :groups, :description, :text diff --git a/db/migrate/20120229182356_add_default_values_to_is_rpm_for_projects.rb b/db/migrate/20120229182356_add_default_values_to_is_rpm_for_projects.rb index 4c223d2db..46fc6a7f4 100644 --- a/db/migrate/20120229182356_add_default_values_to_is_rpm_for_projects.rb +++ b/db/migrate/20120229182356_add_default_values_to_is_rpm_for_projects.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddDefaultValuesToIsRpmForProjects < ActiveRecord::Migration def change Project.update_all(:is_rpm => true) diff --git a/db/migrate/20120302102734_remove_name_from_groups.rb b/db/migrate/20120302102734_remove_name_from_groups.rb index f7f33ae48..2740878a9 100644 --- a/db/migrate/20120302102734_remove_name_from_groups.rb +++ b/db/migrate/20120302102734_remove_name_from_groups.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class RemoveNameFromGroups < ActiveRecord::Migration def up remove_column :groups, :name diff --git a/db/migrate/20120302114735_add_professional_experience_to_users.rb b/db/migrate/20120302114735_add_professional_experience_to_users.rb index 69ba2d342..1c3828533 100644 --- a/db/migrate/20120302114735_add_professional_experience_to_users.rb +++ b/db/migrate/20120302114735_add_professional_experience_to_users.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddProfessionalExperienceToUsers < ActiveRecord::Migration def change add_column :users, :professional_experience, :text diff --git a/db/migrate/20120303062601_add_site_company_and_location_to_users.rb b/db/migrate/20120303062601_add_site_company_and_location_to_users.rb index cb8f608db..8fc2939fe 100644 --- a/db/migrate/20120303062601_add_site_company_and_location_to_users.rb +++ b/db/migrate/20120303062601_add_site_company_and_location_to_users.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddSiteCompanyAndLocationToUsers < ActiveRecord::Migration def change add_column :users, :site, :string diff --git a/db/migrate/20120303171802_add_avatar_to_users.rb b/db/migrate/20120303171802_add_avatar_to_users.rb index 19ba567c7..a237076b3 100644 --- a/db/migrate/20120303171802_add_avatar_to_users.rb +++ b/db/migrate/20120303171802_add_avatar_to_users.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddAvatarToUsers < ActiveRecord::Migration def change change_table :users do |t| diff --git a/db/migrate/20120306212914_add_project_to_comment.rb b/db/migrate/20120306212914_add_project_to_comment.rb index 4ae6f4b64..94b6f8361 100644 --- a/db/migrate/20120306212914_add_project_to_comment.rb +++ b/db/migrate/20120306212914_add_project_to_comment.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddProjectToComment < ActiveRecord::Migration def up add_column :comments, :project_id, :integer diff --git a/db/migrate/20120313130930_delete_dublicate_subscribes.rb b/db/migrate/20120313130930_delete_dublicate_subscribes.rb index 7f1fcc6b9..2ec50ad80 100644 --- a/db/migrate/20120313130930_delete_dublicate_subscribes.rb +++ b/db/migrate/20120313130930_delete_dublicate_subscribes.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class DeleteDublicateSubscribes < ActiveRecord::Migration def up execute <<-SQL diff --git a/db/migrate/20120314151558_truncate_activity_feed.rb b/db/migrate/20120314151558_truncate_activity_feed.rb index aea3a87fd..5484c71bf 100644 --- a/db/migrate/20120314151558_truncate_activity_feed.rb +++ b/db/migrate/20120314151558_truncate_activity_feed.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class TruncateActivityFeed < ActiveRecord::Migration def up ActivityFeed.destroy_all diff --git a/db/migrate/20120314162313_add_description_to_products.rb b/db/migrate/20120314162313_add_description_to_products.rb index 3a54c661a..68d22d552 100644 --- a/db/migrate/20120314162313_add_description_to_products.rb +++ b/db/migrate/20120314162313_add_description_to_products.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddDescriptionToProducts < ActiveRecord::Migration def self.up add_column :products, :description, :text diff --git a/db/migrate/20120314223151_remove_is_template_from_products.rb b/db/migrate/20120314223151_remove_is_template_from_products.rb index b130c4f1a..c29ba1d01 100644 --- a/db/migrate/20120314223151_remove_is_template_from_products.rb +++ b/db/migrate/20120314223151_remove_is_template_from_products.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class RemoveIsTemplateFromProducts < ActiveRecord::Migration def up remove_column :products, :is_template diff --git a/db/migrate/20120320102912_add_build_list_priority.rb b/db/migrate/20120320102912_add_build_list_priority.rb index a1b08d66d..55e5fd81a 100644 --- a/db/migrate/20120320102912_add_build_list_priority.rb +++ b/db/migrate/20120320102912_add_build_list_priority.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddBuildListPriority < ActiveRecord::Migration def self.up add_column :build_lists, :priority, :integer, :null => false, :default => 0 @@ -6,4 +7,4 @@ class AddBuildListPriority < ActiveRecord::Migration def self.down remove_column :build_lists, :priority end -end \ No newline at end of file +end diff --git a/db/migrate/20120321130436_add_devise_lockable.rb b/db/migrate/20120321130436_add_devise_lockable.rb index 0d242536d..2a82c94a6 100644 --- a/db/migrate/20120321130436_add_devise_lockable.rb +++ b/db/migrate/20120321130436_add_devise_lockable.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class AddDeviseLockable < ActiveRecord::Migration def change add_column :users, :failed_attempts, :integer, :default => 0 # Only if lock strategy is :failed_attempts diff --git a/db/schema.rb b/db/schema.rb index e5df6d422..d0380d139 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,4 @@ -# encoding: UTF-8 +# -*- encoding : utf-8 -*- # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. diff --git a/lib/ext/core/object.rb b/lib/ext/core/object.rb index d2856a51c..cdd331d93 100644 --- a/lib/ext/core/object.rb +++ b/lib/ext/core/object.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- class Object def with_skip begin diff --git a/lib/ext/gollum.rb b/lib/ext/gollum.rb index 8109242e9..817aa5f30 100644 --- a/lib/ext/gollum.rb +++ b/lib/ext/gollum.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # # -*- encoding : utf-8 -*- module Gollum class Wiki diff --git a/lib/ext/grit.rb b/lib/ext/grit.rb index 043553435..d0cf5590f 100644 --- a/lib/ext/grit.rb +++ b/lib/ext/grit.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # -*- ruby encoding: utf-8 -*- module Grit diff --git a/spec/controllers/activity_feeds_controller_spec.rb b/spec/controllers/activity_feeds_controller_spec.rb index 54ce3026a..8c9773ab7 100644 --- a/spec/controllers/activity_feeds_controller_spec.rb +++ b/spec/controllers/activity_feeds_controller_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' describe ActivityFeedsController do diff --git a/spec/factories/activity_feeds.rb b/spec/factories/activity_feeds.rb index d0e1984cc..a1d3273a1 100644 --- a/spec/factories/activity_feeds.rb +++ b/spec/factories/activity_feeds.rb @@ -1,6 +1,7 @@ +# -*- encoding : utf-8 -*- # Read about factories at http://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :activity_feed do end -end \ No newline at end of file +end diff --git a/spec/helpers/activity_feeds_helper_spec.rb b/spec/helpers/activity_feeds_helper_spec.rb index 623c526ec..ce14e82ce 100644 --- a/spec/helpers/activity_feeds_helper_spec.rb +++ b/spec/helpers/activity_feeds_helper_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/helpers/build_lists_helper_spec.rb b/spec/helpers/build_lists_helper_spec.rb index bda7a8ffb..ceea3a40f 100644 --- a/spec/helpers/build_lists_helper_spec.rb +++ b/spec/helpers/build_lists_helper_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' # Specs in this file have access to a helper object that includes diff --git a/spec/models/activity_feed_observer_spec.rb b/spec/models/activity_feed_observer_spec.rb index 378ee2377..f008468e9 100644 --- a/spec/models/activity_feed_observer_spec.rb +++ b/spec/models/activity_feed_observer_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' describe ActivityFeedObserver do diff --git a/spec/models/activity_feed_spec.rb b/spec/models/activity_feed_spec.rb index c77e1d83a..cc55d6c65 100644 --- a/spec/models/activity_feed_spec.rb +++ b/spec/models/activity_feed_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' describe ActivityFeed do diff --git a/spec/models/labels_spec.rb b/spec/models/labels_spec.rb index dd72c1f9f..8bfa08304 100644 --- a/spec/models/labels_spec.rb +++ b/spec/models/labels_spec.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'spec_helper' describe Label do