diff options
author | Marius Mathiesen <marius.mathiesen@gmail.com> | 2009-02-11 15:54:02 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-04-22 14:05:17 +0200 |
commit | 42ff498a6f1b9e7397f2dbe890e266e76b8eac39 (patch) | |
tree | 6a03cf97a74083ed3cdf81f99d6987b7d5a1b964 | |
parent | b8e59ed2db39b5e4a0abc8016da338c6740b3759 (diff) | |
download | gitorious-mainline-outdated-42ff498a6f1b9e7397f2dbe890e266e76b8eac39.zip gitorious-mainline-outdated-42ff498a6f1b9e7397f2dbe890e266e76b8eac39.tar.gz gitorious-mainline-outdated-42ff498a6f1b9e7397f2dbe890e266e76b8eac39.tar.bz2 |
Adding missing template for MergeRequests#edit
-rw-r--r-- | app/helpers/application_helper.rb | 7 | ||||
-rw-r--r-- | app/models/action.rb | 3 | ||||
-rw-r--r-- | app/processors/push_event_processor.rb | 13 | ||||
-rw-r--r-- | config/locales/en.rb | 2 | ||||
-rwxr-xr-x | data/hooks/post-receive | 3 | ||||
-rwxr-xr-x | script/gitorious | 1 | ||||
-rw-r--r-- | spec/processors/push_event_processor_spec.rb | 18 |
7 files changed, 33 insertions, 14 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0d1a246..86ec735 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -183,7 +183,7 @@ module ApplicationHelper project = event.project case target.kind when Repository::KIND_PROJECT_REPO - action = "<strong>#{I18n.t("application_helper.event_status_pushed")}</strong> #{link_to event.data[0,8], project_repository_commit_path(project, target, event.data)} to #{link_to h(project.slug), project_path(project)}/#{link_to h(target.name), project_repository_url(project, target)}" + action = "<strong>#{I18n.t("application_helper.event_status_committed")}</strong> #{link_to event.data[0,8], project_repository_commit_path(project, target, event.data)} to #{link_to h(project.slug), project_path(project)}/#{link_to h(target.name), project_repository_url(project, target)}" body = link_to(h(truncate(event.body, :length => 150)), project_repository_commit_path(project, target, event.data)) category = "commit" when Repository::KIND_WIKI @@ -264,6 +264,11 @@ module ApplicationHelper project = event.target action = "<strong>#{I18n.t("application_helper.event_updated_wiki_page")}</strong> #{link_to h(project.slug), project_path(project)}/#{link_to(h(event.data), project_page_path(project, event.data))}" category = "wiki" + when Action::PUSH + project = target.project + action = "<strong>#{I18n.t("application_helper.event_status_pushed")}</strong> to #{link_to h(project.slug), project_path(project)}/#{link_to h(target.name), project_repository_url(project, target)}" + body = event.body + category = 'push' end [action, body, category] diff --git a/app/models/action.rb b/app/models/action.rb index 58eae0c..541e10b 100644 --- a/app/models/action.rb +++ b/app/models/action.rb @@ -35,6 +35,7 @@ class Action UPDATE_MERGE_REQUEST = 15 DELETE_MERGE_REQUEST = 16 UPDATE_WIKI_PAGE = 17 + PUSH = 18 def self.name(action_id) case action_id @@ -72,6 +73,8 @@ class Action "update merge request" when DELETE_MERGE_REQUEST "delete merge request" + when PUSH + 'push' end end end diff --git a/app/processors/push_event_processor.rb b/app/processors/push_event_processor.rb index 095fa7d..69ca3ed 100644 --- a/app/processors/push_event_processor.rb +++ b/app/processors/push_event_processor.rb @@ -19,7 +19,7 @@ class PushEventProcessor < ApplicationProcessor subscribes_to :push_event - attr_reader :oldrev, :newrev, :action + attr_reader :oldrev, :newrev, :action, :user attr_writer :repository GIT_OUTPUT_SEPARATOR = ";;" @@ -28,6 +28,7 @@ class PushEventProcessor < ApplicationProcessor hash = ActiveSupport::JSON.decode(message) logger.debug("Processor on message #{hash.inspect}") if @repository = Repository.find_by_hashed_path(hash['gitdir']) + @user = User.find_by_login(hash['username']) self.commit_summary = hash['message'] log_events else @@ -107,7 +108,7 @@ class PushEventProcessor < ApplicationProcessor e.event_type = Action::CREATE_BRANCH e.message = "New branch" e.identifier = @identifier - e.email = @repository.user.email + e.email = user.email result = [e] result = result + events_from_git_log(@newrev) return result @@ -118,7 +119,13 @@ class PushEventProcessor < ApplicationProcessor fetch_commit_details(e, @oldrev) return [e] else - events_from_git_log("#{@oldrev}..#{@newrev}") + e = EventForLogging.new + e.event_type = Action::PUSH + e.message = "Pushed some changes" + e.identifier = @identifier + e.email = user.email + result = [e] + result = result + events_from_git_log("#{@oldrev}..#{@newrev}") end end diff --git a/config/locales/en.rb b/config/locales/en.rb index 406a2db..b433ce9 100644 --- a/config/locales/en.rb +++ b/config/locales/en.rb @@ -102,6 +102,8 @@ :event_deleted_merge_request => "deleted merge request", :event_status_push_wiki => "pushed wiki content", :event_updated_wiki_page => "edited wiki page", + :event_status_pushed => 'pushed some commits', + :event_status_committed => 'committed', :more_info => "More info…", }, :project => { diff --git a/data/hooks/post-receive b/data/hooks/post-receive index 06f8a82..c25dc1f 100755 --- a/data/hooks/post-receive +++ b/data/hooks/post-receive @@ -23,13 +23,14 @@ $: << incpath require 'messaging' require 'json' + @publisher = Publisher.new gitdir = File.expand_path(File.join(incpath, "..")) hashed_dir = gitdir.split('/')[-3,3].join('').split('.').first # Equivalent to the hash in the model while line = gets - message = JSON.unparse({:gitdir => hashed_dir, :message => line.chomp}) + message = JSON.unparse({:gitdir => hashed_dir, :message => line.chomp, :username => ENV['GITORIOUS_USER']}) @publisher.post_message(message) end diff --git a/script/gitorious b/script/gitorious index c2b3676..cae17a3 100755 --- a/script/gitorious +++ b/script/gitorious @@ -50,6 +50,7 @@ begin if client.assure_user_can_write! args = client.to_git_shell_argument $stderr.puts "git-shell -c #{args.inspect}" if $DEBUG + ENV['GITORIOUS_USER'] = user exec("git-shell", "-c", args) end diff --git a/spec/processors/push_event_processor_spec.rb b/spec/processors/push_event_processor_spec.rb index cb92d3e..ddd22b5 100644 --- a/spec/processors/push_event_processor_spec.rb +++ b/spec/processors/push_event_processor_spec.rb @@ -36,7 +36,7 @@ describe PushEventProcessor do end it 'returns the correct type and identifier for a new branch' do - stub_git_log + stub_git_log_and_user @processor.commit_summary = '0000000000000000000000000000000000000000 a9934c1d3a56edfa8f45e5f157869874c8dc2c34 refs/heads/foo_branch' @processor.repository = Repository.first @processor.action.should == :create @@ -50,21 +50,20 @@ describe PushEventProcessor do end it 'returns the correct type and a set of events for a commit' do - stub_git_log + stub_git_log_and_user @processor.commit_summary = "a9934c1d3a56edfa8f45e5f157869874c8dc2c34 33f746e21ef5122511a5a69f381bfdf017f4d66c refs/heads/foo_branch" @processor.action.should == :update @processor.should be_head - @processor.events.size.should == 3 + @processor.events.size.should == 4 first_event = @processor.events.first - first_event.event_type.should == Action::COMMIT - first_event.identifier.should == '33f746e21ef5122511a5a69f381bfdf017f4d66c' - first_event.email.should == 'john@nowhere.com' - @processor.expects(:log_event).times(3) + first_event.event_type.should == Action::PUSH + first_event.email.should == users(:johan).email + @processor.expects(:log_event).times(4) @processor.log_events end it 'creates commit events even if the committer is unknown' do - stub_git_log + stub_git_log_and_user @processor.repository = Repository.first @processor.commit_summary = '0000000000000000000000000000000000000000 a9934c1d3a56edfa8f45e5f157869874c8dc2c34 refs/heads/foo_branch' @processor.action.should == :create @@ -101,11 +100,12 @@ describe PushEventProcessor do @processor.log_events end - def stub_git_log + def stub_git_log_and_user git = mock output = ['33f746e21ef5122511a5a69f381bfdf017f4d66c', 'john@nowhere.com','1233842115','This is really nice'].join(PushEventProcessor::GIT_OUTPUT_SEPARATOR) + "\n" git.stubs(:log).returns(output*3) @processor.stubs(:git).returns(git) + @processor.stubs(:user).returns(users(:johan)) end def stub_git_show |