grunt-git-deploy
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -96,2 +96,3 @@ /* | ||
url: '../repo', | ||
tag: 'v1', | ||
message: 'first deploy' | ||
@@ -104,2 +105,3 @@ }, | ||
url: '../repo', | ||
tag: 'v2', | ||
message: 'second deploy' | ||
@@ -106,0 +108,0 @@ }, |
{ | ||
"name": "grunt-git-deploy", | ||
"description": "Deploy files to any branch of any remote git repository.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/iclanzan/grunt-git-deploy", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -6,3 +6,3 @@ # grunt-git-deploy | ||
## Getting Started | ||
This plugin requires Grunt `~0.4.1` | ||
This plugin requires Grunt `~0.4.1` and must be used with Git `1.8.3` or better (see [Git changelog](https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.3.txt#L155-L156)). | ||
@@ -60,3 +60,23 @@ If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: | ||
#### options.tag | ||
Type: `Boolean`/`String` | ||
Default value: `false` | ||
Whether to tag the release. Provide a tag name (string) to tag the release commit. To use the package version, first | ||
read the package.json | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON("package.json") | ||
... | ||
}) | ||
and then pass the value `'<%= pkg.version %>'` | ||
#### options.tagMessage | ||
Type: `String` | ||
Default value: `'autocommit'` | ||
The message for the tag referenced above. This option is ignored if `options.tag` is `false`. | ||
## Contributing | ||
If you can think of a way to unit test this plugin please take a shot at it. |
@@ -21,2 +21,4 @@ /* | ||
message: 'autocommit', | ||
tag: false, | ||
tagMessage: 'autocommit', | ||
branch: 'gh-pages' | ||
@@ -99,3 +101,3 @@ }); | ||
grunt.util.async.series([ | ||
var commands = [ | ||
git(['clone', '-b', options.branch, options.url, '.' ]), | ||
@@ -105,8 +107,15 @@ git(['checkout', '-B', options.branch]), | ||
git(['add', '--all']), | ||
git(['commit', '--message=' + options.message]), | ||
git(['push', '--prune', '--quiet', options.url, options.branch]) | ||
], done); | ||
git(['commit', '--message=' + options.message ]) | ||
]; | ||
if ( options.tag ) { | ||
commands.push( git(['tag', '-a', options.tag, '-m', options.tagMessage]) ); | ||
} | ||
commands.push( git(['push', '--prune', '--force', '--quiet', '--follow-tags', options.url, options.branch]) ); | ||
grunt.util.async.series(commands, done); | ||
}); | ||
}; | ||
@@ -35,3 +35,3 @@ 'use strict'; | ||
default_options: function(test) { | ||
test.expect(7); | ||
test.expect(6); | ||
@@ -44,3 +44,7 @@ grunt.file.recurse('test/fixtures/second', function(abs, root, subdir, file) { | ||
test.ok(!grunt.file.exists(path.join('tmp/repo', 'to-be-removed')), 'The file ‘to-be-removed’ should have been removed from the repository.'); | ||
test.done(); | ||
}, | ||
commit_message: function(test) { | ||
test.expect(1); | ||
grunt.util.spawn({ | ||
@@ -50,11 +54,24 @@ cmd: 'git', | ||
opts: {cwd: 'tmp/repo'} | ||
}, function( a, b, c ){ | ||
}, function(error, result, code){ | ||
//Get repo history | ||
var expected = "second deploy\nfirst deploy\nInitial commit"; | ||
test.equal( b.stdout, expected, 'The deployment repository`s history is not as expected' ) | ||
test.equal( result.stdout, expected, 'The deployment repository`s history is not as expected' ) | ||
test.done(); | ||
} ); | ||
} | ||
}, | ||
tags: function(test) { | ||
test.expect(1); | ||
grunt.util.spawn({ | ||
cmd: 'git', | ||
args: ['tag'], | ||
opts: {cwd: 'tmp/repo'} | ||
},function( error, result, code ){ | ||
//Get repo history | ||
var expected = "v1\nv2"; | ||
test.equal( result.stdout, expected, 'The deployment repository`s tags are not as expected' ) | ||
test.done(); | ||
}); | ||
}, | ||
}; |
13116
266
81