Skip to content

Commit

Permalink
chore(grunt): fix how git version is figured out
Browse files Browse the repository at this point in the history
  • Loading branch information
c0bra committed Dec 20, 2013
1 parent 3451ad3 commit 84de806
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: node_js
node_js:
- '0.10'

notifications:
irc: "chat.freenode.net#ui-grid"

env:
global:
- SAUCE_USERNAME=nggrid
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
1. `readableColumnNames` need to be overrideable by i18n.
1. Add banners to compiled .css files (grunt-banner?)
1. Add grunt-nuget task to autodeploy builds to nuget
1. Use: git describe --tags `git rev-list --tags --max-count=1`
to replace the code in utils.getVersion();

1. [DONE] Add --browsers option for testing on saucelabs with specific browser(s)
1. [DONE] Make karmangular run in `watch` mode and in singlerun too.
Expand Down
12 changes: 12 additions & 0 deletions lib/grunt/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ module.exports = function(grunt) {
};
});

// Utility functions for showing the version
grunt.registerTask('current-version', function () {
grunt.log.writeln(util.getVersion());
});
grunt.registerTask('stable-version', function () {
grunt.log.writeln(util.getStableVersion());
});

grunt.registerMultiTask('cutrelease', 'Release the built code', function() {
// Require the build and ngdocs tassk to be run first
grunt.task.requires(['build']);
Expand All @@ -152,6 +160,10 @@ module.exports = function(grunt) {

grunt.log.writeln("Version: " + tag);

if (!tag) {
grunt.fatal("Couldn't get git version");
}

// Figure out if the tag is stable or not
var stable = !/-\w+$/.test(tag);
grunt.log.writeln('stable', stable);
Expand Down
5 changes: 3 additions & 2 deletions lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ var util = module.exports = {
// Get the current release version
getVersion: function() {
// Get the current git tag
var version = shell.exec('git describe', {silent:true}).output.trim();
// var version = shell.exec('git describe', {silent:true}).output.trim();
var version = shell.exec('git rev-list --all --max-count=1 | xargs git describe', {silent:true}).output.trim();

// Clean up the tag
var tag = version.replace(/-\d+-/, '-');
Expand All @@ -213,7 +214,7 @@ var util = module.exports = {
for (var i in lines) {
var l = lines[i];

var match = l.match(/\(tag: (.+?)(\)|,)/);
var match = l.match(/\(.*?tag: (.+?)(\)|,)/);
if (! match || match.length < 2 || !match[1]) { continue; }
var tag = match[1];

Expand Down

0 comments on commit 84de806

Please sign in to comment.