# HG changeset patch # User Peter Sanchez # Date 1348535508 25200 # Mon Sep 24 18:11:48 2012 -0700 # Node ID c25b963dee4839316564a4c90bee2b05f1cd5978 # Parent e4875e699d3638bb6d31425d7daafb33f4ab7548 Working on getting Redmine 2.1.0 compat diff --git a/app/controllers/bitbucket_hook_controller.rb b/app/controllers/bitbucket_hook_controller.rb deleted file mode 100644 --- a/app/controllers/bitbucket_hook_controller.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'json' - -class BitbucketHookController < ApplicationController - - skip_before_filter :verify_authenticity_token, :check_if_login_required - - def index - payload = JSON.parse(params[:payload]) - logger.debug { "Received from Bitbucket: #{payload.inspect}" } - - # For now, we assume that the repository name is the same as the project identifier - identifier = payload['repository']['name'] - - project = Project.find_by_identifier(identifier) - raise ActiveRecord::RecordNotFound, "No project found with identifier '#{identifier}'" if project.nil? - - repository = project.repository - raise TypeError, "Project '#{identifier}' has no repository" if repository.nil? - raise TypeError, "Repository for project '#{identifier}' is not a Mercurial repository" unless repository.is_a?(Repository::Mercurial) - - # Get updates from the bitbucket repository - command = "cd \"#{repository.url}\" && hg pull" - exec(command) - - # Fetch the new changesets into Redmine - repository.fetch_changesets - - render(:text => 'OK') - end - - private - - def exec(command) - logger.info { "BitbucketHook: Executing command: '#{command}'" } - output = `#{command}` - logger.info { "BitbucketHook: Shell returned '#{output}'" } - end - -end diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,3 @@ -ActionController::Routing::Routes.draw do |map| - map.connect '/bitbucket_hook/:action', :controller => 'bitbucket_hook' -end \ No newline at end of file +RedmineApp::Application.routes.draw do + match 'bitbucket_hook', :to => 'bitbucket_hook#index', :via => [:post] +end diff --git a/init.rb b/init.rb --- a/init.rb +++ b/init.rb @@ -4,5 +4,5 @@ name 'Redmine Bitbucket Hook plugin' author 'Alessio Caiazza' description 'This plugin allows your Redmine installation to receive Bitbucket post-receive notifications. Based on github work by Jakob Skjerning.' - version '0.1.2' + version '0.1.3' end diff --git a/test/test_helper.rb b/test/test_helper.rb --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,2 @@ -# Load the normal Rails helper -require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') - -# Ensure that we are using the temporary fixture path -Engines::Testing.set_fixture_path +# Load the normal Rails helper from the Redmine host app +require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')