Compare commits

...
2 Commits
Author SHA1 Message Date
Kaito UdagawaandGregor Martynus 3f8559731f fix(post): Create a tag before makeing a release 2017-08-13 20:29:49 -07:00
Kaito UdagawaandGregor Martynus f148a61339 fix(post): fix target_commitish to be the default branch
target_commitish in GitHub Releases has two different meanings:
* Target commit that a new associated tag will be created on
* Target branch to compute how many "commits to since this release"

target_commitish is usually the default branch (aka master), because the
distance between the release and the latest branch is the primary concern.

Before this change, target_commitish was left to be a hash and the
feature of GitHub Releases that shows how much time passed since the
release is ruined, because no tracking branch is given.

By this change, target_commitish is changed to be the default branch
given in the configuration (options.branch) via edit a release API after
the release and tag are created via crate a release API.
2017-08-13 20:29:49 -07:00
3 changed files with 31 additions and 8 deletions
+22 -4
View File
@@ -24,12 +24,18 @@ module.exports = function (config, cb) {
if (err) return cb(err)
var ghRepo = parseSlug(pkg.repository.url)
var tag = {
owner: ghRepo[0],
repo: ghRepo[1],
ref: 'refs/heads/v' + pkg.version,
sha: hash
}
var release = {
owner: ghRepo[0],
repo: ghRepo[1],
name: 'v' + pkg.version,
tag_name: 'v' + pkg.version,
target_commitish: hash,
name: 'v' + pkg.version,
target_commitish: options.branch,
draft: !!options.debug,
body: log
}
@@ -43,10 +49,22 @@ module.exports = function (config, cb) {
token: options.githubToken
})
github.repos.createRelease(release, function (err) {
if (options.debug) {
return github.repos.createRelease(release, function (err) {
if (err) return cb(err)
cb(null, true, release)
})
}
github.gitdata.createReference(tag, function (err) {
if (err) return cb(err)
cb(null, true, release)
github.repos.createRelease(release, function (err) {
if (err) return cb(err)
cb(null, true, release)
})
})
})
})
+5
View File
@@ -3,6 +3,11 @@ module.exports = function () {
authenticate: function () {
return true
},
gitdata: {
createReference: function (release, cb) {
cb(null)
}
},
repos: {
createRelease: function (release, cb) {
cb(null)
+4 -4
View File
@@ -23,14 +23,14 @@ var defaultRelease = {
repo: 'up',
name: 'v1.0.0',
tag_name: 'v1.0.0',
target_commitish: 'bar',
target_commitish: 'master',
body: 'the log'
}
test('full post run', function (t) {
t.test('in debug mode w/o token', function (tt) {
post({
options: {debug: true},
options: {debug: true, branch: 'master'},
pkg: pkg,
plugins: plugins
}, function (err, published, release) {
@@ -44,7 +44,7 @@ test('full post run', function (t) {
t.test('in debug mode w/token', function (tt) {
post({
options: {debug: true, githubToken: 'yo'},
options: {debug: true, githubToken: 'yo', branch: 'master'},
pkg: pkg,
plugins: plugins
}, function (err, published, release) {
@@ -58,7 +58,7 @@ test('full post run', function (t) {
t.test('production', function (tt) {
post({
options: {githubToken: 'yo'},
options: {githubToken: 'yo', branch: 'master'},
pkg: pkg,
plugins: plugins
}, function (err, published, release) {