Skip to content

Commit 636aa45

Browse files
committed
fix: update getGitBranch test and skip when appropriate
1 parent 85d788a commit 636aa45

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"dont-crack": "1.2.1",
8080
"git-issues": "1.3.1",
8181
"github-post-release": "1.13.1",
82-
"is-ci": "1.0.10",
8382
"license-checker": "15.0.0",
8483
"mocha": "4.0.1",
8584
"nsp": "2.8.1",

src/git-api-spec.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const { stubSpawnShellOnce } = require('stub-spawn-once')
88
const Promise = require('bluebird')
99
const snapshot = require('snap-shot-it')
1010
const { join } = require('path')
11-
const isCI = require('is-ci')
1211

1312
/* eslint-env mocha */
1413
describe('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

Comments
 (0)