Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

Commit

Permalink
Merge 0789b00 into 2d967ae
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Aug 26, 2015
2 parents 2d967ae + 0789b00 commit 006fd83
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions conf/commands.json
@@ -1,6 +1,7 @@
{
"options": [
{ "arg": "-f, --fail-fast", "desc": "Exit as soon as any command failure" },
{ "arg": "-v, --verbose", "desc": "Print executed commands (for debugging" },
{ "arg": "-c, --config-file <configFile>", "desc": "Configuration file" },
{ "arg": "-t, --tags <tags>", "desc": "Comma-separated tags filter, to be matched against repo tags" },
{ "arg": "-r, --regex <regex>", "desc": "Regular expression filter, to be matched against repo name and URL" }
Expand Down
2 changes: 1 addition & 1 deletion conf/scms-win32.json
Expand Up @@ -3,7 +3,7 @@
"delete": "rmdir {workspace}\\\\{name} /s /q",
"init": "git clone {url} {workspace}\\\\{name}",
"get": "cd {workspace}\\\\{name} && git pull --rebase",
"changes": "cd {workspace}\\\\{name} && git status",
"changes": "cd {workspace}\\\\{name} && git status -s && git log --branches --not --remotes --oneline",
"save": "cd {workspace}\\\\{name} && git push origin master",
"undo": "cd {workspace}\\\\{name} && git stash && git stash clear"
},
Expand Down
2 changes: 1 addition & 1 deletion conf/scms.json
Expand Up @@ -3,7 +3,7 @@
"delete": "rm -rf {workspace}/{name}",
"init": "git clone {url} {workspace}/{name}",
"get": "cd {workspace}/{name}; git pull --rebase",
"changes": "cd {workspace}/{name}; git status",
"changes": "cd {workspace}/{name}; git status -s; git log --branches --not --remotes --oneline",
"save": "cd {workspace}/{name}; git push origin master",
"undo": "cd {workspace}/{name}; git stash; git stash clear"
},
Expand Down
1 change: 1 addition & 0 deletions lib/cli.js
Expand Up @@ -49,6 +49,7 @@ function _exec(command, args) {
}

opts.failFast = args.parent.failFast;
opts.verbose = args.parent.verbose;
opts.regex = args.parent.regex;
if (args.parent.tags) {
opts.tags = args.parent.tags.split(',');
Expand Down
5 changes: 4 additions & 1 deletion lib/repoman.js
Expand Up @@ -98,6 +98,7 @@ Repoman.prototype.exec = function (command, opts, cb) {
opts = opts || {};

opts.failFast = opts.failFast || false;
opts.verbose = opts.verbose || false;

var dir = process.cwd();
var tasks = [];
Expand All @@ -113,7 +114,9 @@ Repoman.prototype.exec = function (command, opts, cb) {
tasks.push(function (cb) {
console.log('\n+ %s', name);
jazz.compile(_command).process(params, function (text) {
console.log('> %s', text.replace(/^cd.+; /, ''));
if (opts.verbose) {
console.log('> %s', text.replace(/^cd.+?; /, ''));
}
bag.exec(text, !opts.failFast, cb);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test-integration/success-config-file.yml
Expand Up @@ -22,7 +22,7 @@
output: 'Current branch master is up to date.'

- description: Command exec should execute same command on all repositories
command: '{repoman} exec "touch somefile"'
command: '{repoman} exec "touch somefile" --verbose'
exitcode: 0
output: 'touch somefile'

Expand Down
6 changes: 3 additions & 3 deletions test-integration/success.yml
Expand Up @@ -26,7 +26,7 @@
output: 'Current branch master is up to date.'

- description: Command exec should execute same command on all repositories
command: '{repoman} exec "touch somefile"'
command: '{repoman} exec "touch somefile" --verbose'
exitcode: 0
output: 'touch somefile'

Expand All @@ -41,11 +41,11 @@
output: 'No local changes to save'

- description: Command exec should execute nothing when tags is specified and there is no matching repo
command: '{repoman} --tags inexistingtag exec "touch somefile"'
command: '{repoman} --tags inexistingtag exec "touch somefile" --verbose'
exitcode: 0
output: ''

- description: Command exec should execute nothing when regex is specified and there is no matching repo
command: '{repoman} --regex .*inexistingrepo.* exec "touch somefile"'
command: '{repoman} --regex .*inexistingrepo.* exec "touch somefile" --verbose'
exitcode: 0
output: ''
18 changes: 9 additions & 9 deletions test/repoman.js
Expand Up @@ -135,23 +135,23 @@ buster.testCase('repoman - exec', {
cb(null, command);
});
var repoman = new Repoman(this.repos, this.scms);
repoman.exec('init', {}, function cb(err, results) {
repoman.exec('init', { verbose: true }, function cb(err, results) {
assert.equals(results[0], 'git clone http://git-wip-us.apache.org/repos/asf/couchdb.git /somedir/couchdb');
assert.equals(results[1], 'svn checkout http://svn.apache.org/repos/asf/httpd/httpd/trunk/ /somedir/httpd');
done();
});
},
'should execute command as-is on each repository when command is unsupported': function (done) {
this.mockConsole.expects('log').once().withExactArgs('\n+ %s', 'couchdb');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'echo "Created /somedir/couchdb/.gitignore file";');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
this.mockConsole.expects('log').once().withExactArgs('\n+ %s', 'httpd');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'echo "Created /somedir/httpd/.gitignore file";');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'touch .gitignore; echo "Created /somedir/httpd/.gitignore file";');
this.stub(bag, 'exec', function (command, fallthrough, cb) {
assert.isTrue(fallthrough);
cb(null, command);
});
var repoman = new Repoman(this.repos, this.scms);
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', undefined, function cb(err, results) {
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { verbose: true }, function cb(err, results) {
assert.equals(results.length, 2);
assert.equals(results[0], 'cd /somedir/couchdb; touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
assert.equals(results[1], 'cd /somedir/httpd; touch .gitignore; echo "Created /somedir/httpd/.gitignore file";');
Expand All @@ -160,27 +160,27 @@ buster.testCase('repoman - exec', {
},
'should execute command as-is on matching repository when tag is provided': function (done) {
this.mockConsole.expects('log').once().withExactArgs('\n+ %s', 'couchdb');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'echo "Created /somedir/couchdb/.gitignore file";');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
this.stub(bag, 'exec', function (command, fallthrough, cb) {
assert.isTrue(fallthrough);
cb(null, command);
});
var repoman = new Repoman(this.repos, this.scms);
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { tags: ['database', 'someothertag'] }, function cb(err, results) {
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { tags: ['database', 'someothertag'], verbose: true }, function cb(err, results) {
assert.equals(results.length, 1);
assert.equals(results[0], 'cd /somedir/couchdb; touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
done();
});
},
'should execute command as-is on matching repository when regex is provided': function (done) {
this.mockConsole.expects('log').once().withExactArgs('\n+ %s', 'couchdb');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'echo "Created /somedir/couchdb/.gitignore file";');
this.mockConsole.expects('log').once().withExactArgs('> %s', 'touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
this.stub(bag, 'exec', function (command, fallthrough, cb) {
assert.isTrue(fallthrough);
cb(null, command);
});
var repoman = new Repoman(this.repos, this.scms);
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { regex: '.*couchdb.*' }, function cb(err, results) {
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { regex: '.*couchdb.*', verbose: true }, function cb(err, results) {
assert.equals(results.length, 1);
assert.equals(results[0], 'cd /somedir/couchdb; touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
done();
Expand All @@ -192,7 +192,7 @@ buster.testCase('repoman - exec', {
cb(null, command);
});
var repoman = new Repoman(this.repos, this.scms);
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { regex: 'blah', tags: ['inexistingtag1', 'inexistingtag2'] }, function cb(err, results) {
repoman.exec('touch .gitignore; echo "Created {workspace}/{name}/.gitignore file";', { regex: 'blah', tags: ['inexistingtag1', 'inexistingtag2'], verbose: true }, function cb(err, results) {
assert.equals(results.length, 0);
done();
});
Expand Down

0 comments on commit 006fd83

Please sign in to comment.