2016-03-18 21:34:31 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
2018-09-01 14:32:23 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
|
2016-03-18 21:34:31 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PatchTester;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper class for Joomla's issue tracker integrations
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
abstract class TrackerHelper
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Array containing the supported repositories integrated with the Joomla! Issue Tracker
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
private static $projects = array(
|
|
|
|
'joomla-cms' => array(
|
|
|
|
'githubUser' => 'joomla',
|
|
|
|
'githubrepo' => 'joomla-cms',
|
|
|
|
'projectAlias' => 'joomla-cms',
|
|
|
|
),
|
|
|
|
'patchtester' => array(
|
|
|
|
'githubUser' => 'joomla-extensions',
|
|
|
|
'githubrepo' => 'patchtester',
|
|
|
|
'projectAlias' => 'patchtester',
|
|
|
|
),
|
|
|
|
'weblinks' => array(
|
|
|
|
'githubUser' => 'joomla-extensions',
|
|
|
|
'githubrepo' => 'weblinks',
|
|
|
|
'projectAlias' => 'weblinks',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the issue tracker project alias for a GitHub repository
|
|
|
|
*
|
|
|
|
* @param string $githubUser The owner of the GitHub repository (user or organization)
|
|
|
|
* @param string $githubRepo The GitHub repository name
|
|
|
|
*
|
|
|
|
* @return string|boolean The project alias if supported or boolean false
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
public static function getTrackerAlias($githubUser, $githubRepo)
|
|
|
|
{
|
|
|
|
// If the repo isn't even listed, no point in going further
|
|
|
|
if (!array_key_exists($githubRepo, self::$projects))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the GitHub user must match the project (we don't support forks, sorry!)
|
|
|
|
if (self::$projects[$githubRepo]['githubUser'] !== $githubUser)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This project is supported
|
|
|
|
return self::$projects[$githubRepo]['projectAlias'];
|
|
|
|
}
|
|
|
|
}
|