Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ Default value: `false`

When `true`, the task will commit the changes with the `--no-verify` flag.

#### options.force
Type: `Boolean`
Default value: `false`

When `true`, files will be added with the --force flag. This allows adding otherwise ignored files.

#### options.noStatus
Type: `Boolean`
Default value: `false`
Expand Down
14 changes: 12 additions & 2 deletions lib/command_commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = function (task, exec, done) {
message: 'Commit',
ignoreEmpty: false,
noVerify: false,
noStatus: false
noStatus: false,
force: false
});
var args = ['commit', '-m', options.message];

Expand All @@ -21,12 +22,21 @@ module.exports = function (task, exec, done) {

args.push(done);

var argsAdd = ['add'];
if (options.force) {
argsAdd.push('--force');
}

function addFiles(files, cb) {
async.forEachSeries(files.src, addFile, cb);
}

function addFile(file, cb) {
exec('add', file, cb);

var localArgs = argsAdd.slice(); // create a copy
localArgs.push(file);
localArgs.push(cb);
exec.apply(null, localArgs);
}

function checkStaged(cb) {
Expand Down
18 changes: 18 additions & 0 deletions test/commit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ describe('commit', function () {
.run(done);
});

it('should add files with the force flag', function (done) {
var options = {
force: true
};

var files = [
'test.txt',
'test2.txt'
];

new Test(command, options, files)
.expect(['add', '--force', 'test.txt'])
.expect(['add', '--force', 'test2.txt'])
.expect(['diff', '--cached', '--exit-code'], [null, 'diff', 1])
.expect(['commit', '-m', 'Commit'])
.run(done);
});

it('should not fail when there are no unstaged changes', function (done) {
var options = {
ignoreEmpty: false
Expand Down