Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding Bitbucket support. #94

Merged
merged 1 commit into from

4 participants

Almog Baku Grexeo Sharron Denice Daniel André Eikeland
Almog Baku

fix issue #1128

Almog Baku AlmogBaku Adding Bitbucket support.
fix issue #1128

** Changes:
- changing all the translations strings
- adding documentation
- fixing browser bug
b9ba776
Daniel André Eikeland zegenie merged commit f37d639 into from
Grexeo

Discovered a really annoying typo after trying to set this up - the doc (modules/publish/fixtures/VCSIntegration) tells you to set the bitbucket URL to:

http://www.your-tbg-site.com/vcs_integration/report/PROJECTID/bitcucket/?passkey=PASSKEY

Obviously it should be bitbucket, not bitcucket. I copy + pasted the URL and then adapted it, so it took me a while to find the problem.

Almog Baku

it seems you right! I'll work on it ASAP.

please open an issue..

Grexeo

Already done, and it seems someone beat me to it ;)

Almog Baku

can you please attach the issue ID/link?

Grexeo

Certainly: http://issues.thebuggenie.com/thebuggenie/issues/1926

And here's the duplicate I opened that needs deleting/closing: http://issues.thebuggenie.com/thebuggenie/issues/1947 (Sorry about that!)

Sharron Denice
Collaborator

Has work been completed for this bug? Neither ticket has any code changes I see...are we missing a commit?

Sharron Denice
Collaborator

I added in the fix I think in the confusion I think you all may have thought the duplicate issue had been worked but it hadn't...I added in the fix and it'll be pulled in soon.

Almog Baku

great! thanks!
and sorry for the confusing bug :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2012
  1. Almog Baku

    Adding Bitbucket support.

    AlmogBaku authored
    fix issue #1128
    
    ** Changes:
    - changing all the translations strings
    - adding documentation
    - fixing browser bug
This page is out of date. Refresh to see the latest.
2  i18n/de_DE/strings.inc.php
View
@@ -3823,7 +3823,7 @@
//$strings['Access method'] = '';
//$strings['Direct Access (via a call to tbg_cli)'] = '';
//$strings['HTTP Access (via a call to a URL)'] = '';
- //$strings['Required for Github and Gitorious users'] = '';
+ //$strings['Required for Github, Gitorious and Bitbucket users'] = '';
//$strings['HTTP Passkey'] = '';
//$strings['URL to repository browser'] = '';
//$strings['If the repository name is part of the URL (e.g. http://www.example.com/viewvc/myrepo), please include it as part of this field.'] = '';
2  i18n/en_US/strings.inc.php
View
@@ -3823,7 +3823,7 @@
$strings['Access method'] = 'Access method';
$strings['Direct Access (via a call to tbg_cli)'] = 'Direct Access (via a call to tbg_cli)';
$strings['HTTP Access (via a call to a URL)'] = 'HTTP Access (via a call to a URL)';
- $strings['Required for Github and Gitorious users'] = 'Required for Github and Gitorious users';
+ $strings['Required for Github, Gitorious and Bitbucket users'] = 'Required for Github, Gitorious and Bitbucket users';
$strings['HTTP Passkey'] = 'HTTP Passkey';
$strings['URL to repository browser'] = 'URL to repository browser';
$strings['If the repository name is part of the URL (e.g. http://www.example.com/viewvc/myrepo), please include it as part of this field.'] = 'If the repository name is part of the URL (e.g. http://www.example.com/viewvc/myrepo), please include it as part of this field.';
2  i18n/es_ES/strings.inc.php
View
@@ -3823,7 +3823,7 @@
$strings['Access method'] = 'Método de acceso';
$strings['Direct Access (via a call to tbg_cli)'] = 'Acceso Directo (via llamada a tbg_cli)';
$strings['HTTP Access (via a call to a URL)'] = 'Acceso HTTP (via llamada a URL)';
- $strings['Required for Github and Gitorious users'] = 'Necesario para usuarios de Github y Gitorious';
+ $strings['Required for Github, Gitorious and Bitbucket users'] = 'Necesario para usuarios de Github, Gitorious y Bitbucket';
$strings['HTTP Passkey'] = 'Passkey HTTP';
$strings['URL to repository browser'] = 'URL al navegador de repositorio';
$strings['If the repository name is part of the URL (e.g. http://www.example.com/viewvc/myrepo), please include it as part of this field.'] = 'Si el nombre del repositorio es parte de la UTL (ej. http://www.ejemplo.com/viewvc/mirepo), por favor inclúyalo como parte de este campo.';
2  i18n/fr_FR/strings.inc.php
View
@@ -3823,7 +3823,7 @@
//$strings['Access method'] = '';
//$strings['Direct Access (via a call to tbg_cli)'] = '';
//$strings['HTTP Access (via a call to a URL)'] = '';
-//$strings['Required for Github and Gitorious users'] = '';
+//$strings['Required for Github, Gitorious and Bitbucket users'] = '';
//$strings['HTTP Passkey'] = '';
//$strings['URL to repository browser'] = '';
//$strings['If the repository name is part of the URL (e.g. http://www.example.com/viewvc/myrepo), please include it as part of this field.'] = '';
9 modules/publish/fixtures/VCSIntegration
View
@@ -33,6 +33,15 @@ You will need to set the hostname and path correctly as appropriate, as well as
Any commits which follow the rules for being picked up (see below) will then be recorded against their respective issues on push, though commits which make no changes to the filesystem (i.e. nothing added, removed or modified) will not be recorded in this release of VCS Integration.
+==== Bitbucket support ====
+If you wish to use the bitbucket hook, please set up HTTP access as previously discussed. You will then need to set up your Bitbucket project's post-receive hook to contact The Bug Genie.
+
+To do this, go to your project's service hooks page on bitbucket, and set a POST URL to point to the following URL:
+ http://www.your-tbg-site.com/vcs_integration/report/PROJECTID/bitcucket/?passkey=PASSKEY
+You will need to set the hostname and path correctly as appropriate, as well as replacing PASSKEY with the passkey you set, and PROJECTID with the ID number of the project, which can be found on the projects tab of VCS Integration configuration.
+
+Any commits which follow the rules for being picked up (see below) will then be recorded against their respective issues on push, though commits which make no changes to the filesystem (i.e. nothing added, removed or modified) will not be recorded in this release of VCS Integration.
+
==== Gitorious support ====
If you have a locally hosted Gitorious server, then you can integrate that with The Bug Genie.
8 modules/vcs_integration/classes/TBGVCSIntegration.class.php
View
@@ -81,6 +81,7 @@ protected function _addRoutes()
$this->addRoute('vcs_commitspage', '/:project_key/commits', 'projectCommits');
$this->addRoute('normalcheckin', '/vcs_integration/report/:project_id/', 'addCommit');
$this->addRoute('githubcheckin', '/vcs_integration/report/:project_id/github/', 'addCommitGithub');
+ $this->addRoute('bitbucketcheckin', '/vcs_integration/report/:project_id/bitbucket/', 'addCommitBitbucket');
$this->addRoute('gitoriouscheckin', '/vcs_integration/report/:project_id/gitorious/', 'addCommitGitorious');
$this->addRoute('configure_vcs_settings', '/configure/project/:project_id/vcs', 'configureProjectSettings', array('config_module' => 'core', 'section' => TBGSettings::CONFIGURATION_SECTION_PROJECTS));
}
@@ -286,6 +287,13 @@ protected function _upgrade()
$link_diff = '/commit/%revno%';
$link_view = '/blob/%revno%/%file%';
break;
+ case 'bitbucket':
+ $base_url = 'https://bitbucket.org/' . $web_repo;
+ $link_rev = '/changeset/%revno%';
+ $link_file = '/history/%file%';
+ $link_diff = '/changeset/%revno%#chg-%file%';
+ $link_view = '/src/%revno%/%file%';
+ break;
case 'gitorious':
$base_url = $web_path . '/' . $web_repo;
$link_rev = '/commit/%revno%';
87 modules/vcs_integration/classes/actions.class.php
View
@@ -241,6 +241,86 @@ public function runAddCommitGithub(TBGRequest $request)
exit();
}
+ /**
+ * Bitbucket gateway - adding commit
+ * @see http://confluence.atlassian.com/display/BITBUCKET/Setting+Up+the+bitbucket+POST+Service
+ * @author AlmogBaku <almog.baku@gmail.com>
+ *
+ * @param TBGRequest $request
+ */
+ public function runAddCommitBitbucket(TBGRequest $request)
+ {
+ TBGContext::getResponse()->setContentType('text/plain');
+ TBGContext::getResponse()->renderHeaders();
+
+ $passkey = TBGContext::getRequest()->getParameter('passkey');
+ $project_id = urldecode(TBGContext::getRequest()->getParameter('project_id'));
+
+ try
+ {
+ $project = TBGContext::factory()->TBGProject($project_id);
+ }
+ catch (Exception $e)
+ {
+ $project = false;
+ }
+
+ // Validate access
+ if (!$project)
+ {
+ echo 'Error: The project with the ID '.$project_id.' does not exist';
+ exit;
+ }
+
+ if (TBGSettings::get('access_method_'.$project->getID(), 'vcs_integration') == TBGVCSIntegration::ACCESS_DIRECT)
+ {
+ echo 'Error: This project uses the CLI access method, and so access via HTTP has been disabled';
+ exit;
+ }
+
+ if (TBGSettings::get('access_passkey_'.$project->getID(), 'vcs_integration') != $passkey)
+ {
+ echo 'Error: The passkey specified does not match the passkey specified for this project';
+ exit;
+ }
+
+ // Validate data
+ $data = html_entity_decode(TBGContext::getRequest()->getParameter('payload'));
+ if (empty($data) || $data == null)
+ {
+ die('Error: No payload was provided');
+ }
+
+ $entries = json_decode($data);
+ if ($entries == null)
+ {
+ die('Error: The payload could not be decoded');
+ }
+
+ foreach($entries->commits as $commit)
+ {
+ $changed=array();
+ foreach($commit->files as $file)
+ {
+ switch($file->type) {
+ case "modified":
+ $changed[]="M".$file->file;
+ break;
+ case "removed":
+ $changed[]="D".$file->file;
+ break;
+ case "added":
+ $changed[]="A".$file->file;
+ break;
+ }
+ }
+
+ echo TBGVCSIntegration::processCommit($project, $commit->message, $commit->parents[0], $commit->node, strtotime($commit->timestamp), implode("\n",$changed), $commit->author, $commit->branch);
+ $previous = $commit->node;
+ }
+ exit();
+ }
+
public function runAddCommitGitorious(TBGRequest $request)
{
TBGContext::getResponse()->setContentType('text/plain');
@@ -397,6 +477,13 @@ public function runConfigureProjectSettings(TBGRequest $request)
$link_diff = '/commit/%revno%';
$link_view = '/blob/%revno%/%file%';
break;
+ case 'bitbucket':
+ $base_url = $request['browser_url'];
+ $link_rev = '/changeset/%revno%';
+ $link_file = '/history/%file%';
+ $link_diff = '/changeset/%revno%#chg-%file%';
+ $link_view = '/src/%revno%/%file%';
+ break;
case 'gitorious':
$base_url = $request['browser_url'];
$link_rev = '/commit/%revno%';
3  modules/vcs_integration/hooks/AUTHORS.TXT
View
@@ -9,6 +9,9 @@ SVN hook:
Github:
- Philip Kent <kentphilip@gmail.com>
+Bitbucket:
+ - Almog Baku <almog.baku@gmail.com>
+
Gitorious:
- Joyce Babu <contact@joycebabu.com>
3  modules/vcs_integration/templates/_projectconfig_panel.inc.php
View
@@ -36,7 +36,7 @@
<td style="width: 580px;">
<select name="access_method" id="access_method" style="width: 100%" onchange="if ($('access_method').getValue() == '1') { $('http_passkey').show(); } else { $('http_passkey').hide(); }">
<option value="0"<?php if (TBGSettings::get('access_method_'.$project->getID(), 'vcs_integration') != 1): ?> selected="selected"<?php endif;?>><?php echo __('Direct Access (via a call to tbg_cli)'); ?></option>
- <option value="1"<?php if (TBGSettings::get('access_method_'.$project->getID(), 'vcs_integration') == 1): ?> selected="selected"<?php endif;?>><?php echo __('HTTP Access (via a call to a URL)'); ?> - <?php echo __('Required for Github and Gitorious users'); ?></option>
+ <option value="1"<?php if (TBGSettings::get('access_method_'.$project->getID(), 'vcs_integration') == 1): ?> selected="selected"<?php endif;?>><?php echo __('HTTP Access (via a call to a URL)'); ?> - <?php echo __('Required for Github, Gitorious and Bitbucket users'); ?></option>
</select>
</td>
</tr>
@@ -75,6 +75,7 @@
<option value='cgit' >cgit</option>
<option value='gitorious'>Gitorious (<?php echo __('locally hosted'); ?>)</option>
<option value='github'>Github</option>
+ <option value='bitbucket'>Bitbucket</option>
</optgroup>
<optgroup label="Bazaar">
<option value='loggerhead'>Loggerhead</option>
Something went wrong with that request. Please try again.