robwierzbowski / grunt-build-control

Version control your built code.
MIT License
380 stars 36 forks source link

Ability to use a full commit message #37

Closed kevinawoo closed 9 years ago

kevinawoo commented 10 years ago

I was having a problem with \n characters in my commit message, because of shelljs.

I decided a commit message saved to a file would be best, this allows any kind of formatting.

kevinawoo commented 10 years ago

@daftmonk, you may find this interesting for your build.

robwierzbowski commented 10 years ago

Can we just escape the \n instead of writing to a temp file and then reading back in? Doing this without I/O would be preferable.

kevinawoo commented 10 years ago

I tried, but couldn't come up with a solution. I think the way shelljs handles a command doesn't allow for escaping nicely. This way may be the best option as it allows for any kind of extensibility. My options look like this in grunt:

options: {
    dir: 'dist',
    commit: true,
    push: true,
    message: '[{{ env }}] %sourcePriorCommit%..%sourceCommit% from branch "%sourceBranch%"\n' +
             '\n' +
             'Deployed Environment: {{ env }} @ {{ url }}\n' +
             'Latest source commit: Loopfirst/Loopfirst@%sourceCommit%\n' +
             'Source log: https://github.com/Loopfirst/Loopfirst/compare/%sourcePriorCommit%...%sourceCommit%'
},

and I further extend them with

var buildControl = grunt.config.get('buildcontrol');
var options = buildControl.options;

// set up build message dependant on the target
var message = options.message
    .replace(/{{ *env *}}/gi, target)
    .replace(/{{ *url *}}/gi, buildControl[target].url);