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
1010require_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 ;
0 commit comments