7b912396c5a5 — Peter Sanchez 12 years ago
Appears to be working with Redmine 2.x
6 files changed, 85 insertions(+), 73 deletions(-)

R README => 
A => README.rdoc
A => Rakefile
M app/controllers/bitbucket_hook_controller.rb
A => app/helpers/bitbucket_hook_helper.rb
M config/routes.rb
R README =>  +0 -70
@@ 1,70 0,0 @@ 
-= Redmine Bitbucket Hook
-
-This plugin allows you to update your local Mercurial repositories in Redmine when changes have been pushed to Bitbucket.
-
-This plugin is a fork from Redmine Github Hook from Jakob Skjerning ( http://github.com/koppen/redmine_github_hook )
-
-== Description
-
-Redmine <http://redmine.org> has supported Mercurial repositories for a long time, allowing you to browse your code and view your changesets directly in Redmine. For this purpose, Redmine relies on local clones of the Mercurial repositories.
-
-If your shared repository is on a remote machine - for example on Bitbucket - this unfortunately means a bit of legwork to keep the local, Redmine-accessible repository up-to-date. The common approach is to set up a cronjob that pulls in any changes with regular intervals and updates Redmine with them.
-
-That approach works perfectly fine, but is a bit heavy-handed and cumbersome. The Redmine Bitbucket Hook plugin allows Bitbucket to notify your Redmine installation when changes have been pushed to a repository, triggering an update of your local repository and Redmine data only when it is actually necessary.
-
-
-== Installation
-
-1. Installing the plugin
-   1. Install the json gem <http://json.rubyforge.org/> on the machine where Redmine is running.
-   2. Follow the plugin installation procedure at http://www.redmine.org/wiki/redmine/Plugins.
-   3. Restart your Redmine.
-   4. If you already have a local Mercurial repository set up and working from Redmine go to step 3, otherwise continue at step 2.
-
-2. Adding a Mercurial repository to a project (note, this should work whether you want to use Redmine Bitbucket Hook or not). Either follow the instructions at http://www.redmine.org/wiki/redmine/HowTo_keep_in_sync_your_git_repository_for_redmine or the ones below:
-   1. Go to the directory on your Redmine machine where you want to keep your repository, for example /home/redmine/repositories/.
-   2. Get a clone of the repository into that location: hg clone http://bitbucket.org/nolith/redmine-bitbucket. This creates a repository directory at /home/redmine/repositories/redmine-bitbucket/.
-   3. Open Redmine in your browser and navigate to the Settings for the project you want to add a Mercurial repository to.
-   4. Under the Repository tab, choose Mercurial as your SCM and enter the full path to the repository directory from step 2; /home/redmine/repositories/redmine-bitbucket/ . Click "Create".
-   5. Click the new "Repository" link in the main navigation to verify that your repository integration works - this might take a while as Redmine is fetching all commits.
-
-3. Connecting Bitbucket to Redmine
-   1. Go to the repository Admin interface on Bitbucket and click the 'Service' link on 'Additional options/settings' menu.
-   2. Under "Services Administration" add a new "POST" service.
-   3. Compile the URL field with: "[redmine_installation_url]/bitbucket_hook" (for example "http://example.com/bitbucket_hook").
-
-That's it. Bitbucket will now send a HTTP POST to the Redmine Bitbucket Hook plugin whenever changes are pushed to Bitbucket. The plugin then takes care of pulling the changes to the local repository and updating the Redmine database with them.
-
-
-== Assumptions
-
-* Your project identifier in Redmine is the same as the project name on Bitbucket.
-* Redmine 0.8 running on a *nix-like system.
-* Mercurial available on the commandline and the repository has the bitbucket url as a default path.
-
-
-== License
-
-Copyright (c) 2010 Alessio Caiazza
-Copyright (c) 2009 Jakob Skjerning
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.

          
A => README.rdoc +71 -0
@@ 0,0 1,71 @@ 
+= Redmine Bitbucket Hook
+
+This plugin allows you to update your local Mercurial repositories in Redmine when changes have been pushed to Bitbucket.
+
+This plugin is a fork from Redmine Github Hook from Jakob Skjerning ( http://github.com/koppen/redmine_github_hook )
+
+== Description
+
+Redmine <http://redmine.org> has supported Mercurial repositories for a long time, allowing you to browse your code and view your changesets directly in Redmine. For this purpose, Redmine relies on local clones of the Mercurial repositories.
+
+If your shared repository is on a remote machine - for example on Bitbucket - this unfortunately means a bit of legwork to keep the local, Redmine-accessible repository up-to-date. The common approach is to set up a cronjob that pulls in any changes with regular intervals and updates Redmine with them.
+
+That approach works perfectly fine, but is a bit heavy-handed and cumbersome. The Redmine Bitbucket Hook plugin allows Bitbucket to notify your Redmine installation when changes have been pushed to a repository, triggering an update of your local repository and Redmine data only when it is actually necessary.
+
+
+== Installation
+
+1. Installing the plugin
+   1. Install the json gem <http://json.rubyforge.org/> on the machine where Redmine is running.
+   2. Follow the plugin installation procedure at http://www.redmine.org/wiki/redmine/Plugins.
+   3. This directory MUST BE NAMED: redmine_bitbucket_hook
+   4. Restart your Redmine.
+   5. If you already have a local Mercurial repository set up and working from Redmine go to step 3, otherwise continue at step 2.
+
+2. Adding a Mercurial repository to a project (note, this should work whether you want to use Redmine Bitbucket Hook or not). Either follow the instructions at http://www.redmine.org/wiki/redmine/HowTo_keep_in_sync_your_git_repository_for_redmine or the ones below:
+   1. Go to the directory on your Redmine machine where you want to keep your repository, for example /home/redmine/repositories/.
+   2. Get a clone of the repository into that location: hg clone http://bitbucket.org/nolith/redmine-bitbucket. This creates a repository directory at /home/redmine/repositories/redmine-bitbucket/.
+   3. Open Redmine in your browser and navigate to the Settings for the project you want to add a Mercurial repository to.
+   4. Under the Repository tab, choose Mercurial as your SCM and enter the full path to the repository directory from step 2; /home/redmine/repositories/redmine-bitbucket/ . Click "Create".
+   5. Click the new "Repository" link in the main navigation to verify that your repository integration works - this might take a while as Redmine is fetching all commits.
+
+3. Connecting Bitbucket to Redmine
+   1. Go to the repository Admin interface on Bitbucket and click the 'Service' link on 'Additional options/settings' menu.
+   2. Under "Services Administration" add a new "POST" service.
+   3. Compile the URL field with: "[redmine_installation_url]/bitbucket_hook" (for example "http://example.com/bitbucket_hook").
+
+That's it. Bitbucket will now send a HTTP POST to the Redmine Bitbucket Hook plugin whenever changes are pushed to Bitbucket. The plugin then takes care of pulling the changes to the local repository and updating the Redmine database with them.
+
+
+== Assumptions
+
+* Your project identifier in Redmine is the same as the project name on Bitbucket.
+* Redmine 0.8 running on a *nix-like system.
+* Mercurial available on the commandline and the repository has the bitbucket url as a default path.
+
+
+== License
+
+Copyright (c) 2010 Alessio Caiazza
+Copyright (c) 2009 Jakob Skjerning
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

          
A => Rakefile +10 -0
@@ 0,0 1,10 @@ 
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+  t.libs << "test"
+  files = FileList['test/**/*test.rb']
+  t.test_files = files
+  t.verbose = true
+end
+
+task :default => :test
  No newline at end of file

          
M app/controllers/bitbucket_hook_controller.rb +1 -2
@@ 32,8 32,7 @@ class BitbucketHookController < Applicat
   
   def exec(command)
     logger.info { "BitbucketHook: Executing command: '#{command}'" }
-    #output = `#{command}`
-    output = system("#{command}")
+    output = Kernel.system("#{command}")
     logger.info { "BitbucketHook: Shell returned '#{output}'" }
   end
 

          
A => app/helpers/bitbucket_hook_helper.rb +2 -0
@@ 0,0 1,2 @@ 
+module BitbucketHookHelper
+end

          
M config/routes.rb +1 -1
@@ 1,3 1,3 @@ 
 RedmineApp::Application.routes.draw do
-  match 'bitbucket_hook', :to => 'bitbucket_hook#index', :via => [:post]
+  match 'bitbucket_hook' => 'bitbucket_hook#index', :via => [:post]
 end