ericmatthys/grunt-changelog

How about referring to a single commit instead of before/after?

Closed this issue · 1 comments

That way, one can use changelog with tags and also can use it programmatically, for example:

As of now it is near impossible to get the changelog for the first tag, say, v0.0.1 where there is a history of commits before the initial release.

With the patched version of grunt-changelog I am using, I am now able to do this in my gruntfile

100 determinePreviousTag = (grunt, tag, callback) ->
101 
102     grunt.util.spawn { cmd : 'git', args : ['tag'] }, (error, result) ->
103 
104         if error
105 
106             grunt.fail.fatal(error)
107 
108         tags = result.toString().split('\n')
109 
110         index = tags.indexOf(tag)
111 
112         previousTag = null
113         if index > 0
114 
115             previousTag = tags[index - 1]
116 
117         callback previousTag

to determine the previous release version tag. Now, for the first release tag that would be null.

I've tried convincing grunt-changelog that I only need the before but it always determined that this was a date range and thus generated the wrong output.

In a wrapper task I am using this

325     grunt.registerTask 'update-changelog', ->
326 
327         latebind grunt
328 
329         done = this.async()
330 
331         pkg = grunt.config.get 'pkg'
332         tag = "v#{pkg.version}"
333 
334         determinePreviousTag grunt, tag, (previousTag) ->
335 
336             changelogTask = 'changelog:default'
337 
338             if previousTag is null
339 
340                 changelogTask += ":commit:#{tag}"
341 
342             else
343 
344                 changlogTask += ":#{previousTag}:#{tag}"
345 
346             grunt.task.run changelogTask
347 
348             done()

to programmatically adjust the changelog configuration, namely setting either the commit option or the before and after option.

In return this will then run

  git log v0.0.1 --pretty=format:%s --no-merges

for the first tag instead of

  git log --after=<valid-date> --before=<invalid date containing NaNs> ...

For subsequent tags it will run

  git log v0.0.1..v0.0.2 --pretty=format:%s --no-merges

and so on.

See the upcoming pull request below.

See #23