Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2 from semantic-release/feat-tag
Browse files Browse the repository at this point in the history
feat: helpful error output for git tag
  • Loading branch information
boennemann committed Jan 7, 2016
2 parents 7eb4d57 + c54408a commit c486406
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var semver = require('semver')
var SRError = require('@semantic-release/error')

module.exports = function (pluginConfig, config, cb) {
Expand All @@ -19,15 +20,21 @@ module.exports = function (pluginConfig, config, cb) {
))
}

if (options.branch !== env.CI_BRANCH) {
if (options.branch === env.CI_BRANCH) return cb(null)

if (semver.valid(env.CI_BRANCH)) {
return cb(new SRError(
'This test run was triggered on the branch ' + env.CI_BRANCH +
', while semantic-release is configured to only publish from ' +
options.branch + '.\n' +
'You can customize this behavior using the "branch" option: git.io/sr-options',
'EBRANCHMISMATCH'
'This test run was triggered by a git tag that was created by semantic-release itself.\n' +
'Everything is okay. For log output of the actual publishing process look at the build that ran before this one.',
'EGITTAG'
))
}

cb(null)
return cb(new SRError(
'This test run was triggered on the branch ' + env.CI_BRANCH +
', while semantic-release is configured to only publish from ' +
options.branch + '.\n' +
'You can customize this behavior using the "branch" option: git.io/sr-options',
'EBRANCHMISMATCH'
))
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"url": "https://github.com/semantic-release/condition-codeship/issues"
},
"dependencies": {
"@semantic-release/error": "^1.0.0"
"@semantic-release/error": "^1.0.0",
"semver": "^5.1.0"
},
"devDependencies": {
"coveralls": "^2.11.2",
Expand Down
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,19 @@ test('raise errors in codeship environment', function (t) {
})
})

t.test('not running on tags', function (tt) {
tt.plan(2)
condition({}, {
env: {
CI_NAME: 'codeship',
CI_BRANCH: 'v1.0.0'
},
options: {}
}, function (err) {
tt.ok(err instanceof SRError)
tt.is(err.code, 'EGITTAG')
})
})

t.end()
})

0 comments on commit c486406

Please sign in to comment.