Skip to content

Commit

Permalink
fix: update getGitBranch test and skip when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 30, 2017
1 parent 85d788a commit 636aa45
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -79,7 +79,6 @@
"dont-crack": "1.2.1",
"git-issues": "1.3.1",
"github-post-release": "1.13.1",
"is-ci": "1.0.10",
"license-checker": "15.0.0",
"mocha": "4.0.1",
"nsp": "2.8.1",
Expand Down
59 changes: 31 additions & 28 deletions src/git-api-spec.js
Expand Up @@ -8,7 +8,6 @@ const { stubSpawnShellOnce } = require('stub-spawn-once')
const Promise = require('bluebird')
const snapshot = require('snap-shot-it')
const { join } = require('path')
const isCI = require('is-ci')

/* eslint-env mocha */
describe('git-api', () => {
Expand All @@ -34,34 +33,38 @@ describe('git-api', () => {
// because the branch command fails with an error
// fatal: Not a git repository: '.git'
// thus we usually skip it locally and run on CI
if (isCI) {
it.only('finds branch in given repo folder', () => {
la(
is.unemptyString(currentBranch),
'missing branch in current folder',
currentBranch
)
// on CI the branch is also usually "HEAD" but we want actual
// branch there. So it really makes sense to run this
// test locally, but not when committing
it.only('finds branch in given repo folder', () => {
if (is.emptyString(currentBranch)) {
return
}
console.log('current branch "%s"', currentBranch)

la(
is.unemptyString(currentBranch),
'missing branch in current folder',
currentBranch
)

const outsideFolder = join(__dirname, '..', '..')
return chdir
.to(outsideFolder)
.then(() => getGitBranch(__dirname))
.finally(chdir.back)
.then(branch => {
la(
is.unemptyString(branch),
'missing branch with given path',
branch
)
la(
branch === currentBranch,
'two branch values should be the same',
branch,
currentBranch
)
})
})
}
const outsideFolder = join(__dirname, '..', '..')
// assume repo folder is current working directory!
const repoFolder = process.cwd()
return chdir
.to(outsideFolder)
.then(() => getGitBranch(repoFolder))
.finally(chdir.back)
.then(branch => {
la(is.unemptyString(branch), 'missing branch with given path', branch)
la(
branch === currentBranch,
'two branch values should be the same',
branch,
currentBranch
)
})
})
})

describe('subject and body', () => {
Expand Down

0 comments on commit 636aa45

Please sign in to comment.