# HG changeset patch # User Eugenio Piasini # Date 1354281868 0 # Fri Nov 30 13:24:28 2012 +0000 # Node ID 706d29d5504744935fe16e8fed1aa1b317cee8e3 # Parent 6e26cf2cd23b0557434122c3a3e8cdb96f4e3376 Improved 'hg pull' call to avoid cd'ing to the repo directory. diff --git a/app/controllers/bitbucket_hook_controller.rb b/app/controllers/bitbucket_hook_controller.rb --- a/app/controllers/bitbucket_hook_controller.rb +++ b/app/controllers/bitbucket_hook_controller.rb @@ -13,7 +13,7 @@ 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 BitBucket repository" unless repository.is_a?(Repository::Mercurial) || repository.is_a?(Repository::Git) @@ -22,7 +22,7 @@ if repository.is_a?(Repository::Git) update_git_repository(repository) else - command = "cd \"#{repository.url}\" && hg pull" + command = "hg --repository \"#{repository.url}\" pull" exec(command) end @@ -33,7 +33,7 @@ end private - + def exec(command) logger.info { "BitbucketHook: Executing command: '#{command}'" } output = Kernel.system("#{command}")