@@ -8,7 +8,6 @@ const { stubSpawnShellOnce } = require('stub-spawn-once')
88const Promise = require ( 'bluebird' )
99const snapshot = require ( 'snap-shot-it' )
1010const { join } = require ( 'path' )
11- const isCI = require ( 'is-ci' )
1211
1312/* eslint-env mocha */
1413describe ( 'git-api' , ( ) => {
@@ -34,34 +33,38 @@ describe('git-api', () => {
3433 // because the branch command fails with an error
3534 // fatal: Not a git repository: '.git'
3635 // thus we usually skip it locally and run on CI
37- if ( isCI ) {
38- it . only ( 'finds branch in given repo folder' , ( ) => {
39- la (
40- is . unemptyString ( currentBranch ) ,
41- 'missing branch in current folder' ,
42- currentBranch
43- )
36+ // on CI the branch is also usually "HEAD" but we want actual
37+ // branch there. So it really makes sense to run this
38+ // test locally, but not when committing
39+ it . only ( 'finds branch in given repo folder' , ( ) => {
40+ if ( is . emptyString ( currentBranch ) ) {
41+ return
42+ }
43+ console . log ( 'current branch "%s"' , currentBranch )
44+
45+ la (
46+ is . unemptyString ( currentBranch ) ,
47+ 'missing branch in current folder' ,
48+ currentBranch
49+ )
4450
45- const outsideFolder = join ( __dirname , '..' , '..' )
46- return chdir
47- . to ( outsideFolder )
48- . then ( ( ) => getGitBranch ( __dirname ) )
49- . finally ( chdir . back )
50- . then ( branch => {
51- la (
52- is . unemptyString ( branch ) ,
53- 'missing branch with given path' ,
54- branch
55- )
56- la (
57- branch === currentBranch ,
58- 'two branch values should be the same' ,
59- branch ,
60- currentBranch
61- )
62- } )
63- } )
64- }
51+ const outsideFolder = join ( __dirname , '..' , '..' )
52+ // assume repo folder is current working directory!
53+ const repoFolder = process . cwd ( )
54+ return chdir
55+ . to ( outsideFolder )
56+ . then ( ( ) => getGitBranch ( repoFolder ) )
57+ . finally ( chdir . back )
58+ . then ( branch => {
59+ la ( is . unemptyString ( branch ) , 'missing branch with given path' , branch )
60+ la (
61+ branch === currentBranch ,
62+ 'two branch values should be the same' ,
63+ branch ,
64+ currentBranch
65+ )
66+ } )
67+ } )
6568 } )
6669
6770 describe ( 'subject and body' , ( ) => {
0 commit comments