@@ -18,8 +18,12 @@ class SourceGithubPlugin extends MantisSourceGitBasePlugin {
1818 const PLUGIN_VERSION = '2.3.1 ' ;
1919 const FRAMEWORK_VERSION_REQUIRED = '2.5.0 ' ;
2020
21+ /**
22+ * GitHub URLs
23+ */
24+ const URL_MAIN = 'https://github.com/ ' ;
2125 const URL_API = 'https://api.github.com/ ' ;
22- const URL_OAUTH = ' https://github.com/ login/oauth/ ' ;
26+ const URL_OAUTH = self :: URL_MAIN . ' login/oauth/ ' ;
2327
2428 public $ linkPullRequest = '/pull/%s ' ;
2529
@@ -216,27 +220,25 @@ public function show_file( $p_repo, $p_changeset, $p_file ) {
216220 return "$ p_file ->action - $ p_file ->filename " ;
217221 }
218222
223+ public function url_base ( $ p_repo ) {
224+ return self ::URL_MAIN . $ p_repo ->info ['hub_username ' ] . '/ ' . $ p_repo ->info ['hub_reponame ' ];
225+ }
226+
219227 public function url_repo ( $ p_repo , $ p_changeset =null ) {
220228 if ( empty ( $ p_repo ->info ) ) {
221229 return '' ;
222230 }
223- $ t_username = $ p_repo ->info ['hub_username ' ];
224- $ t_reponame = $ p_repo ->info ['hub_reponame ' ];
225- $ t_ref = "" ;
226231
232+ $ t_ref = '' ;
227233 if ( !is_null ( $ p_changeset ) ) {
228234 $ t_ref = "/tree/ $ p_changeset ->revision " ;
229235 }
230236
231- return " https://github.com/ $ t_username / $ t_reponame $ t_ref" ;
237+ return $ this -> url_base ( $ p_repo ) . $ t_ref ;
232238 }
233239
234240 public function url_changeset ( $ p_repo , $ p_changeset ) {
235- $ t_username = $ p_repo ->info ['hub_username ' ];
236- $ t_reponame = $ p_repo ->info ['hub_reponame ' ];
237- $ t_ref = $ p_changeset ->revision ;
238-
239- return "https://github.com/ $ t_username/ $ t_reponame/commit/ $ t_ref " ;
241+ return $ this ->url_base ( $ p_repo ) . '/commit/ ' . $ p_changeset ->revision ;
240242 }
241243
242244 public function url_file ( $ p_repo , $ p_changeset , $ p_file ) {
@@ -245,12 +247,10 @@ public function url_file( $p_repo, $p_changeset, $p_file ) {
245247 return '' ;
246248 }
247249
248- $ t_username = $ p_repo ->info ['hub_username ' ];
249- $ t_reponame = $ p_repo ->info ['hub_reponame ' ];
250250 $ t_ref = $ p_changeset ->revision ;
251251 $ t_filename = $ p_file ->getFilename ();
252252
253- return " https://github.com/ $ t_username / $ t_reponame /blob/ $ t_ref/ $ t_filename " ;
253+ return $ this -> url_base ( $ p_repo ) . " /blob/ $ t_ref/ $ t_filename " ;
254254 }
255255
256256 /**
0 commit comments