Open djmccormick opened 9 years ago
I've now tried the same with v0.3.0-alpha and got similar results with the gitadd
task.
Hi,
got the same problem. Any idea when it would be resolved?
regards
Thank you for bringing this up. I've traced the issue to lib/command_commit.js, which references each file's file.src
property. This is an array, of what appear to be path names relative to the Grunt process' CWD (not relative to the cwd specified in the file options!). For instance, assume the following directory structure:
project/
Gruntfile.js
dist/
foo.html
and the grunt files directive that you've supplied:
files: [{
expand: true,
cwd: 'dist',
src: ['**/*']
}]
The resulting files array for the task will look like this:
[{ src: [ 'dist/foo.html' ],
orig: { expand: true, src: [ '**/*' ] },
dest: 'foo.html' }]
I would expect the src
to be given relative to the file's cwd option, not relative to the Grunt process' CWD.
The solution may be to use the file's dest
property instead of the src
property.
I will continue investigating, and submit a fix when I'm confident in the solution.
Has anyone found a workaround for this in the meantime?
This is because the grunt file API returns paths relative to the Gruntfile, even if a cwd is specified. I am working on a solution.
Respectfully, Dylan Wood The Mind Research Network Neuroinformatics +1.505.480.5346 dwood@mrn.org
On Tue, Dec 16, 2014 at 10:53 PM, Peter Sieg notifications@github.com wrote:
Has anyone found a workaround for this in the meantime?
— Reply to this email directly or view it on GitHub https://github.com/rubenv/grunt-git/issues/79#issuecomment-67283927.
@dylancwood thanks for your work on this!
I found a workaround yesterday that I will use until this is solved. For anyone needing an immediate workaround solution, you can use grunt.util.spawn to run git commands:
grunt.registerTask('gitcommitworkaround', '', function() {
var done, child;
done = this.async();
child = grunt.util.spawn({
cmd: 'git',
args: ['-C', 'the/path/to/your/subdirectory', 'commit', '-m', 'This is a commit message.'],
}, function(err, result, code) {
done();
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
});
any news on this issue? grunt is still giving us the cwd relative to the gruntfile?
I've found another possible workaroud, which is ugly too, this issue affects all grunt-git tasks, not just gitcommit:
var rootPath = process.cwd();
grunt.registerTask("cd", function(subpath) {
var path = require('path');
if(env === 'restore') {
return grunt.file.setBase(rootPath);
}
return grunt.file.setBase(path.resolve('my/subdir/' + subpath));
});
grunt.registerTask("taskName", function(env) {
grunt.task.run("cd:" + env);
grunt.task.run("gitreset:" + env);
grunt.task.run("gitpull:" + env);
grunt.task.run("cd:restore");
grunt.task.run("othertasks...");
});
I'm attempting to use
gitcommit
against a repository in a sub-directory within my project. Thecwd
option doesn't seem to be working properly.My
gitcommit
task looks like this:And when I run it, I get something like this:
Or, with verbose mode:
It appears that the
dist/
portion is still being included despite mycwd
, given that the file is in the appropriate location:Am I doing something incorrectly or is this a bug?
node v0.10.28 grunt-cli v0.1.13 grunt v0.4.4 grunt-git v0.2.14