Skip to content

Commit 63e7e43

Browse files
committed
Github: update to use Git base class
1 parent f3ec4c5 commit 63e7e43

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

SourceGithub/SourceGithub.php

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
# Copyright (c) 2012 John Reese
44
# Licensed under the MIT license
55

6-
if ( false === include_once( config_get( 'plugin_path' ) . 'Source/MantisSourcePlugin.class.php' ) ) {
6+
if ( false === include_once( config_get( 'plugin_path' ) . 'Source/MantisSourceGitBasePlugin.class.php' ) ) {
77
return;
88
}
99

1010
require_once( config_get( 'core_path' ) . 'json_api.php' );
1111

12-
class SourceGithubPlugin extends MantisSourcePlugin {
12+
class SourceGithubPlugin extends MantisSourceGitBasePlugin {
1313

14-
const PLUGIN_VERSION = '1.3.2';
15-
const FRAMEWORK_VERSION_REQUIRED = '1.3.2';
16-
17-
const ERROR_INVALID_PRIMARY_BRANCH = 'invalid_branch';
14+
const PLUGIN_VERSION = '1.4.0';
15+
const FRAMEWORK_VERSION_REQUIRED = '1.5.0';
1816

1917
public $linkPullRequest = '/pull/%s';
2018

@@ -33,16 +31,6 @@ public function register() {
3331
$this->url = 'https://github.com/mantisbt-plugins/source-integration/';
3432
}
3533

36-
public function errors() {
37-
$t_errors_list = array(
38-
self::ERROR_INVALID_PRIMARY_BRANCH,
39-
);
40-
foreach( $t_errors_list as $t_error ) {
41-
$t_errors[$t_error] = plugin_lang_get( 'error_' . $t_error );
42-
}
43-
return $t_errors;
44-
}
45-
4634
public $type = 'github';
4735

4836
public function show_type() {
@@ -211,23 +199,7 @@ public function update_repo( $p_repo ) {
211199
$f_hub_app_secret = gpc_get_string( 'hub_app_secret' );
212200
$f_master_branch = gpc_get_string( 'master_branch' );
213201

214-
# Git branch name validation regex, based on rules defined in man page
215-
# http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
216-
# @TODO this should probably be moved to Source so the logic can be reused in other git-based plugins
217-
$s_valid_branch_regex = '%'
218-
# Must not start with '/'; cannot contain '/.', '//', '@{' or '\';
219-
# cannot be a single '@'.
220-
. '^(?!/|.*([/.]\.|//|@\{|\\)|@$)'
221-
# One or more chars, except the following: ASCII control, space,
222-
# tilde, caret, colon, question mark, asterisk, open bracket.
223-
. '[^\000-\037\177 ~^:?*[]+'
224-
# Must not end with '.lock', '/' or '.'
225-
. '(?<!\.lock|[/.])$'
226-
. '%';
227-
228-
if ( !preg_match( $s_valid_branch_regex, $f_master_branch ) ) {
229-
plugin_error( self::ERROR_INVALID_PRIMARY_BRANCH );
230-
}
202+
$this->validate_branch_list( $f_master_branch );
231203

232204
$p_repo->info['hub_username'] = $f_hub_username;
233205
$p_repo->info['hub_reponame'] = $f_hub_reponame;

SourceGithub/lang/strings_english.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ $s_plugin_SourceGithub_repo_authorization_failed = '<p style="color: red;">Sorry
2525

2626
$s_plugin_SourceGithub_oauth_authorization = 'GitHub OAuth Authorization';
2727
$s_plugin_SourceGithub_back_repo = 'Back to Repository';
28-
29-
$s_plugin_SourceGithub_error_invalid_branch = 'Invalid character in Primary Branch';

0 commit comments

Comments
 (0)