Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Adding Bitbucket support. #94

Merged
merged 1 commit into from almost 2 years ago

4 participants

Almog Baku Grexeo Sharron Denice Daniel André Eikeland
Almog Baku

fix issue #1128

Almog Baku 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 July 13, 2012
Daniel André Eikeland zegenie closed this July 13, 2012
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

Showing 1 unique commit by 1 author.

Jul 11, 2012
Almog Baku Adding Bitbucket support.
fix issue #1128

** Changes:
- changing all the translations strings
- adding documentation
- fixing browser bug
b9ba776
This page is out of date. Refresh to see the latest.
2  i18n/de_DE/strings.inc.php
@@ -3823,7 +3823,7 @@
3823 3823
 	//$strings['Access method'] = '';
3824 3824
 	//$strings['Direct Access (via a call to tbg_cli)'] = '';
3825 3825
 	//$strings['HTTP Access (via a call to a URL)'] = '';
3826  
-	//$strings['Required for Github and Gitorious users'] = '';
  3826
+	//$strings['Required for Github, Gitorious and Bitbucket users'] = '';
3827 3827
 	//$strings['HTTP Passkey'] = '';
3828 3828
 	//$strings['URL to repository browser'] = '';
3829 3829
 	//$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
@@ -3823,7 +3823,7 @@
3823 3823
   $strings['Access method'] = 'Access method';
3824 3824
   $strings['Direct Access (via a call to tbg_cli)'] = 'Direct Access (via a call to tbg_cli)';
3825 3825
   $strings['HTTP Access (via a call to a URL)'] = 'HTTP Access (via a call to a URL)';
3826  
-  $strings['Required for Github and Gitorious users'] = 'Required for Github and Gitorious users';
  3826
+  $strings['Required for Github, Gitorious and Bitbucket users'] = 'Required for Github, Gitorious and Bitbucket users';
3827 3827
   $strings['HTTP Passkey'] = 'HTTP Passkey';
3828 3828
   $strings['URL to repository browser'] = 'URL to repository browser';
3829 3829
   $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
@@ -3823,7 +3823,7 @@
3823 3823
   $strings['Access method'] = 'Método de acceso';
3824 3824
   $strings['Direct Access (via a call to tbg_cli)'] = 'Acceso Directo (via llamada a tbg_cli)';
3825 3825
   $strings['HTTP Access (via a call to a URL)'] = 'Acceso HTTP (via llamada a URL)';
3826  
-  $strings['Required for Github and Gitorious users'] = 'Necesario para usuarios de Github y Gitorious';
  3826
+  $strings['Required for Github, Gitorious and Bitbucket users'] = 'Necesario para usuarios de Github, Gitorious y Bitbucket';
3827 3827
   $strings['HTTP Passkey'] = 'Passkey HTTP';
3828 3828
   $strings['URL to repository browser'] = 'URL al navegador de repositorio';
3829 3829
   $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
@@ -3823,7 +3823,7 @@
3823 3823
 //$strings['Access method'] = '';
3824 3824
 //$strings['Direct Access (via a call to tbg_cli)'] = '';
3825 3825
 //$strings['HTTP Access (via a call to a URL)'] = '';
3826  
-//$strings['Required for Github and Gitorious users'] = '';
  3826
+//$strings['Required for Github, Gitorious and Bitbucket users'] = '';
3827 3827
 //$strings['HTTP Passkey'] = '';
3828 3828
 //$strings['URL to repository browser'] = '';
3829 3829
 //$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
@@ -33,6 +33,15 @@ You will need to set the hostname and path correctly as appropriate, as well as
33 33
 
34 34
 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.
35 35
 
  36
+==== Bitbucket support ====
  37
+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.
  38
+
  39
+To do this, go to your project's service hooks page on bitbucket, and set a POST URL to point to the following URL:
  40
+  http://www.your-tbg-site.com/vcs_integration/report/PROJECTID/bitcucket/?passkey=PASSKEY
  41
+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.
  42
+
  43
+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.
  44
+
36 45
 ==== Gitorious support ====
37 46
 If you have a locally hosted Gitorious server, then you can integrate that with The Bug Genie.
38 47
 
8  modules/vcs_integration/classes/TBGVCSIntegration.class.php
@@ -81,6 +81,7 @@ protected function _addRoutes()
81 81
 			$this->addRoute('vcs_commitspage', '/:project_key/commits', 'projectCommits');
82 82
 			$this->addRoute('normalcheckin', '/vcs_integration/report/:project_id/', 'addCommit');
83 83
 			$this->addRoute('githubcheckin', '/vcs_integration/report/:project_id/github/', 'addCommitGithub');
  84
+			$this->addRoute('bitbucketcheckin', '/vcs_integration/report/:project_id/bitbucket/', 'addCommitBitbucket');
84 85
 			$this->addRoute('gitoriouscheckin', '/vcs_integration/report/:project_id/gitorious/', 'addCommitGitorious');
85 86
 			$this->addRoute('configure_vcs_settings', '/configure/project/:project_id/vcs', 'configureProjectSettings', array('config_module' => 'core', 'section' => TBGSettings::CONFIGURATION_SECTION_PROJECTS));
86 87
 		}
@@ -286,6 +287,13 @@ protected function _upgrade()
286 287
 								$link_diff = '/commit/%revno%';
287 288
 								$link_view = '/blob/%revno%/%file%';
288 289
 								break;
  290
+							case 'bitbucket':
  291
+								  $base_url = 'https://bitbucket.org/' . $web_repo;
  292
+								  $link_rev = '/changeset/%revno%';
  293
+								  $link_file = '/history/%file%';
  294
+								  $link_diff = '/changeset/%revno%#chg-%file%';
  295
+								  $link_view = '/src/%revno%/%file%';
  296
+								  break;
289 297
 							case 'gitorious':
290 298
 								$base_url = $web_path . '/' . $web_repo;
291 299
 								$link_rev = '/commit/%revno%';
87  modules/vcs_integration/classes/actions.class.php
@@ -241,6 +241,86 @@ public function runAddCommitGithub(TBGRequest $request)
241 241
 			exit();
242 242
 		}
243 243
 		
  244
+		/**
  245
+		 * Bitbucket gateway - adding commit
  246
+		 * @see http://confluence.atlassian.com/display/BITBUCKET/Setting+Up+the+bitbucket+POST+Service
  247
+		 * @author AlmogBaku <almog.baku@gmail.com>
  248
+		 * 
  249
+		 * @param TBGRequest $request
  250
+		 */
  251
+		public function runAddCommitBitbucket(TBGRequest $request)
  252
+		{
  253
+		  TBGContext::getResponse()->setContentType('text/plain');
  254
+		  TBGContext::getResponse()->renderHeaders();
  255
+		
  256
+		  $passkey = TBGContext::getRequest()->getParameter('passkey');
  257
+		  $project_id = urldecode(TBGContext::getRequest()->getParameter('project_id'));
  258
+		   
  259
+		  try
  260
+		  {
  261
+		    $project = TBGContext::factory()->TBGProject($project_id);
  262
+		  }
  263
+		  catch (Exception $e)
  264
+		  {
  265
+		    $project = false;
  266
+		  }
  267
+		   
  268
+		  // Validate access
  269
+		  if (!$project)
  270
+		  {
  271
+		    echo 'Error: The project with the ID '.$project_id.' does not exist';
  272
+		    exit;
  273
+		  }
  274
+		   
  275
+		  if (TBGSettings::get('access_method_'.$project->getID(), 'vcs_integration') == TBGVCSIntegration::ACCESS_DIRECT)
  276
+		  {
  277
+		    echo 'Error: This project uses the CLI access method, and so access via HTTP has been disabled';
  278
+		    exit;
  279
+		  }
  280
+		   
  281
+		  if (TBGSettings::get('access_passkey_'.$project->getID(), 'vcs_integration') != $passkey)
  282
+		  {
  283
+		    echo 'Error: The passkey specified does not match the passkey specified for this project';
  284
+		    exit;
  285
+		  }
  286
+		   
  287
+		  // Validate data
  288
+		  $data = html_entity_decode(TBGContext::getRequest()->getParameter('payload'));
  289
+		  if (empty($data) || $data == null)
  290
+		  {
  291
+		    die('Error: No payload was provided');
  292
+		  }
  293
+		
  294
+		  $entries = json_decode($data);
  295
+		  if ($entries == null)
  296
+		  {
  297
+		    die('Error: The payload could not be decoded');
  298
+		  }
  299
+		
  300
+		  foreach($entries->commits as $commit)
  301
+		  {
  302
+		    $changed=array();
  303
+		    foreach($commit->files as $file)
  304
+		    {
  305
+		      switch($file->type) {
  306
+		        case "modified":
  307
+		          $changed[]="M".$file->file;
  308
+		          break;
  309
+		        case "removed":
  310
+		          $changed[]="D".$file->file;
  311
+		          break;
  312
+		        case "added":
  313
+		          $changed[]="A".$file->file;
  314
+		          break;
  315
+		      }
  316
+		    }
  317
+		
  318
+		    echo TBGVCSIntegration::processCommit($project, $commit->message, $commit->parents[0], $commit->node, strtotime($commit->timestamp), implode("\n",$changed), $commit->author, $commit->branch);
  319
+		    $previous = $commit->node;
  320
+		  }
  321
+		  exit();
  322
+		}
  323
+		
244 324
 		public function runAddCommitGitorious(TBGRequest $request)
245 325
 		{
246 326
 			TBGContext::getResponse()->setContentType('text/plain');
@@ -397,6 +477,13 @@ public function runConfigureProjectSettings(TBGRequest $request)
397 477
 						$link_diff = '/commit/%revno%';
398 478
 						$link_view = '/blob/%revno%/%file%';
399 479
 						break;
  480
+					case 'bitbucket':
  481
+						  $base_url = $request['browser_url'];
  482
+						  $link_rev = '/changeset/%revno%';
  483
+						  $link_file = '/history/%file%';
  484
+						  $link_diff = '/changeset/%revno%#chg-%file%';
  485
+						  $link_view = '/src/%revno%/%file%';
  486
+						  break;
400 487
 					case 'gitorious':
401 488
 						$base_url = $request['browser_url'];
402 489
 						$link_rev = '/commit/%revno%';
3  modules/vcs_integration/hooks/AUTHORS.TXT
@@ -9,6 +9,9 @@ SVN hook:
9 9
 Github:
10 10
  - Philip Kent <kentphilip@gmail.com>
11 11
  
  12
+Bitbucket:
  13
+ - Almog Baku <almog.baku@gmail.com>
  14
+ 
12 15
 Gitorious:
13 16
  - Joyce Babu <contact@joycebabu.com>
14 17
 
3  modules/vcs_integration/templates/_projectconfig_panel.inc.php
@@ -36,7 +36,7 @@
36 36
 					<td style="width: 580px;">
37 37
 						<select name="access_method" id="access_method" style="width: 100%" onchange="if ($('access_method').getValue() == '1') { $('http_passkey').show(); } else { $('http_passkey').hide(); }">
38 38
 							<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>
39  
-							<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>
  39
+							<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>
40 40
 						</select>
41 41
 					</td>
42 42
 				</tr>
@@ -75,6 +75,7 @@
75 75
 								<option value='cgit' >cgit</option>
76 76
 								<option value='gitorious'>Gitorious (<?php echo __('locally hosted'); ?>)</option>
77 77
 								<option value='github'>Github</option>
  78
+								<option value='bitbucket'>Bitbucket</option>
78 79
 							</optgroup>
79 80
 							<optgroup label="Bazaar">
80 81
 								<option value='loggerhead'>Loggerhead</option>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.