File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,17 @@ class ScmRouter extends Scm {
357357 getDisplayName ( config ) {
358358 return this . scms [ config . scmContext ] . getDisplayName ( ) ;
359359 }
360+
361+ /**
362+ * Get branch info of scmContext
363+ * @method _getBranchList
364+ * @param {Object } config Configuration
365+ * @param {String } config.scmContext Name of scm context
366+ * @return {String } branch info of scmContext
367+ */
368+ _getBranchList ( config ) {
369+ return this . chooseScm ( config ) . then ( scm => scm . getBranchList ( config ) ) ;
370+ }
360371}
361372
362373module . exports = ScmRouter ;
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ describe('index test', () => {
4949 'getFile' ,
5050 'getChangedFiles' ,
5151 'getOpenedPRs' ,
52- 'getPrInfo'
52+ 'getPrInfo' ,
53+ 'getBranchList'
5354 ] . forEach ( ( method ) => {
5455 mock [ method ] = sinon . stub ( ) . resolves ( plugin ) ;
5556 } ) ;
@@ -900,4 +901,23 @@ describe('index test', () => {
900901 assert . calledOnce ( exampleScm . getDisplayName ) ;
901902 } ) ;
902903 } ) ;
904+
905+ describe ( '_getBranchList' , ( ) => {
906+ const config = { scmContext : 'example.context' } ;
907+
908+ it ( 'call origin getBranchList' , ( ) => {
909+ const scmGithub = scm . scms [ 'github.context' ] ;
910+ const exampleScm = scm . scms [ 'example.context' ] ;
911+ const scmGitlab = scm . scms [ 'gitlab.context' ] ;
912+
913+ return scm . _getBranchList ( config )
914+ . then ( ( result ) => {
915+ assert . strictEqual ( result , 'example' ) ;
916+ assert . notCalled ( scmGithub . getBranchList ) ;
917+ assert . notCalled ( scmGitlab . getBranchList ) ;
918+ assert . calledOnce ( exampleScm . getBranchList ) ;
919+ assert . calledWith ( exampleScm . getBranchList , config ) ;
920+ } ) ;
921+ } ) ;
922+ } ) ;
903923} ) ;
You can’t perform that action at this time.
0 commit comments