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

Commit c486406

Browse files
committed
Merge pull request #2 from semantic-release/feat-tag
feat: helpful error output for git tag
2 parents 7eb4d57 + c54408a commit c486406

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var semver = require('semver')
12
var SRError = require('@semantic-release/error')
23

34
module.exports = function (pluginConfig, config, cb) {
@@ -19,15 +20,21 @@ module.exports = function (pluginConfig, config, cb) {
1920
))
2021
}
2122

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

32-
cb(null)
33+
return cb(new SRError(
34+
'This test run was triggered on the branch ' + env.CI_BRANCH +
35+
', while semantic-release is configured to only publish from ' +
36+
options.branch + '.\n' +
37+
'You can customize this behavior using the "branch" option: git.io/sr-options',
38+
'EBRANCHMISMATCH'
39+
))
3340
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"url": "https://github.com/semantic-release/condition-codeship/issues"
77
},
88
"dependencies": {
9-
"@semantic-release/error": "^1.0.0"
9+
"@semantic-release/error": "^1.0.0",
10+
"semver": "^5.1.0"
1011
},
1112
"devDependencies": {
1213
"coveralls": "^2.11.2",

test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,19 @@ test('raise errors in codeship environment', function (t) {
6868
})
6969
})
7070

71+
t.test('not running on tags', function (tt) {
72+
tt.plan(2)
73+
condition({}, {
74+
env: {
75+
CI_NAME: 'codeship',
76+
CI_BRANCH: 'v1.0.0'
77+
},
78+
options: {}
79+
}, function (err) {
80+
tt.ok(err instanceof SRError)
81+
tt.is(err.code, 'EGITTAG')
82+
})
83+
})
84+
7185
t.end()
7286
})

0 commit comments

Comments
 (0)