From 5278ebe2ea1104f40167e2490d460f1738e86368 Mon Sep 17 00:00:00 2001 From: matiasdecarli Date: Wed, 25 Jun 2014 18:28:33 -0300 Subject: [PATCH 1/4] added init option --- lib/command_init.js | 25 +++++++++++++++++++++++++ lib/commands.js | 1 + test/init_test.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/command_init.js create mode 100644 test/init_test.js diff --git a/lib/command_init.js b/lib/command_init.js new file mode 100644 index 0000000..5ad0f15 --- /dev/null +++ b/lib/command_init.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = function (task, exec, done) { + var options = task.options({ + template: null, + separateGitDir: null + }); + + var args = ['init']; + + if (options.template) { + args.push('--template=' + options.template); + } + + if (options.separateGitDir) { + args.push('--separate-git-dir=' + options.separateGitDir); + } + + // Add callback + args.push(done); + + exec.apply(this, args); +}; + +module.exports.description = 'Init a repository.'; \ No newline at end of file diff --git a/lib/commands.js b/lib/commands.js index b45cf29..6b86f03 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -4,6 +4,7 @@ module.exports = { clean: require('./command_clean'), clone: require('./command_clone'), commit: require('./command_commit'), + init: require('./command_init'), merge: require('./command_merge'), pull: require('./command_pull'), push: require('./command_push'), diff --git a/test/init_test.js b/test/init_test.js new file mode 100644 index 0000000..f5332e1 --- /dev/null +++ b/test/init_test.js @@ -0,0 +1,35 @@ +'use strict'; + +var command = require('../lib/commands').init; +var Test = require('./_common'); + +describe('init', function () { + it('should init a repo', function (done) { + var options = { + }; + + new Test(command, options) + .expect(['init']) + .run(done); + }); + + it('should init a repo from a template', function (done) { + var options = { + template: 'testTemplate', + }; + + new Test(command, options) + .expect(['init', '--template=testTemplate']) + .run(done); + }); + + it('should init a with separate git directory', function (done) { + var options = { + separateGitDir: 'newDir' + }; + + new Test(command, options) + .expect(['init', '--separate-git-dir=newDir']) + .run(done); + }); +}); From 286cc285044ecf6175cd81bef587bb47dc39e2e3 Mon Sep 17 00:00:00 2001 From: matiasdecarli Date: Wed, 25 Jun 2014 18:47:25 -0300 Subject: [PATCH 2/4] added directory flag --- lib/command_init.js | 7 ++++++- test/init_test.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/command_init.js b/lib/command_init.js index 5ad0f15..9c77be9 100644 --- a/lib/command_init.js +++ b/lib/command_init.js @@ -3,11 +3,16 @@ module.exports = function (task, exec, done) { var options = task.options({ template: null, - separateGitDir: null + separateGitDir: null, + directory: null }); var args = ['init']; + if (options.directory) { + args.push(options.directory); + } + if (options.template) { args.push('--template=' + options.template); } diff --git a/test/init_test.js b/test/init_test.js index f5332e1..c4469c0 100644 --- a/test/init_test.js +++ b/test/init_test.js @@ -32,4 +32,14 @@ describe('init', function () { .expect(['init', '--separate-git-dir=newDir']) .run(done); }); + + it('should init a in a specified git directory', function (done) { + var options = { + directory: 'newDir' + }; + + new Test(command, options) + .expect(['init', 'newDir']) + .run(done); + }); }); From 00ee017c370089f798894c98592bfd9e80f6ea29 Mon Sep 17 00:00:00 2001 From: matiasdecarli Date: Fri, 27 Jun 2014 00:11:24 -0300 Subject: [PATCH 3/4] added add option --- lib/command_add.js | 26 ++++++++++++++++++++++++++ lib/commands.js | 1 + test/add_test.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 lib/command_add.js create mode 100644 test/add_test.js diff --git a/lib/command_add.js b/lib/command_add.js new file mode 100644 index 0000000..89e9791 --- /dev/null +++ b/lib/command_add.js @@ -0,0 +1,26 @@ +'use strict'; + +module.exports = function (task, exec, done) { + var options = task.options({ + directory: null, + files: null + }); + + var args = ['add']; + + if (options.directory) { + args.push('-C ' + options.directory); + } + + if (options.files && options.files.length === 1 && options.files[0] === '*') { + args.push('.'); + } + //else{} //TO DO: add individual files + + // Add callback + args.push(done); + + exec.apply(this, args); +}; + +module.exports.description = 'Add files to a repository'; \ No newline at end of file diff --git a/lib/commands.js b/lib/commands.js index 6b86f03..062617d 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -1,4 +1,5 @@ module.exports = { + add: require('./command_add'), archive: require('./command_archive'), checkout: require('./command_checkout'), clean: require('./command_clean'), diff --git a/test/add_test.js b/test/add_test.js new file mode 100644 index 0000000..46e9d2b --- /dev/null +++ b/test/add_test.js @@ -0,0 +1,36 @@ +'use strict'; + +var command = require('../lib/commands').add; +var Test = require('./_common'); + +describe('add', function () { + it('add', function (done) { + var options = { + }; + + new Test(command, options) + .expect(['add']) + .run(done); + }); + + it('add all files', function (done) { + var options = { + files: ['*'] + }; + + new Test(command, options) + .expect(['add', '.']) + .run(done); + }); + + it('should add all files to a specified directory', function (done) { + var options = { + directory: 'testDirectory', + files: ['*'] + }; + + new Test(command, options) + .expect(['add', '-C testDirectory', '.']) + .run(done); + }); +}); From 1cfe637330d8a9eb15d0aff09c8f962058d065ae Mon Sep 17 00:00:00 2001 From: matiasdecarli Date: Sat, 19 Jul 2014 15:12:49 -0300 Subject: [PATCH 4/4] changes to match flopmang as required on #65 --- lib/command_init.js | 49 +++++++++++++++++++++++++++------------------ test/init_test.js | 8 ++++---- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/command_init.js b/lib/command_init.js index 9c77be9..5776679 100644 --- a/lib/command_init.js +++ b/lib/command_init.js @@ -1,27 +1,36 @@ 'use strict'; -module.exports = function (task, exec, done) { - var options = task.options({ - template: null, - separateGitDir: null, - directory: null - }); - - var args = ['init']; - - if (options.directory) { - args.push(options.directory); - } +var ArgUtil = require('flopmang'); - if (options.template) { - args.push('--template=' + options.template); - } - - if (options.separateGitDir) { - args.push('--separate-git-dir=' + options.separateGitDir); - } +module.exports = function (task, exec, done) { + var argUtil = new ArgUtil(task, [ + { //