Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Echo the SCM commands to the console
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Asselin committed Jan 9, 2015
1 parent 4f63269 commit 732983c
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function processHistoryItem(history, index) {
workitem = change['workitem-label'];

// list the changes for this UUID so we can get the full work item and comment
exec(scm + ' list changes ' + uuid + ' -u ' + user + ' -P ' + password + ' -j', {
echoAndExec(scm + ' list changes ' + uuid + ' -u ' + user + ' -P ' + password + ' -j', {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;
Expand All @@ -45,19 +45,19 @@ function processHistoryItem(history, index) {
uuid = change.uuid;

// accept changes from RTC
exec(scm + ' accept ' + uuid + ' -u ' + user + ' -P ' + password + ' --overwrite-uncommitted', {
echoAndExec(scm + ' accept ' + uuid + ' -u ' + user + ' -P ' + password + ' --overwrite-uncommitted', {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;

// add all changes to git
exec('git add -A', {
echoAndExec('git add -A', {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;

// commit these changes
exec(['GIT_COMMITTER_EMAIL="' + email + '"',
echoAndExec(['GIT_COMMITTER_EMAIL="' + email + '"',
'GIT_COMMITTER_NAME="' + name + '"',
'GIT_COMMITTER_DATE="' + modified + '"',
'git commit',
Expand Down Expand Up @@ -107,7 +107,7 @@ function createCommitMessage(change) {
6. Repeat from step 2.
*/
function discardChanges(callback) {
exec(scm + ' show history -j -m 100 -C ' + component + ' -u ' + user + ' -P ' + password, {
echoAndExec(scm + ' show history -j -m 100 -C ' + component + ' -u ' + user + ' -P ' + password, {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;
Expand All @@ -127,7 +127,7 @@ function discardChanges(callback) {
return change.uuid;
});

exec(scm + ' discard -u ' + user + ' -P ' + password + ' --overwrite-uncommitted ' + uuids.join(' '), {
echoAndExec(scm + ' discard -u ' + user + ' -P ' + password + ' --overwrite-uncommitted ' + uuids.join(' '), {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;
Expand All @@ -141,10 +141,10 @@ function discardChanges(callback) {
discardChanges(walkThroughHistory);

function walkThroughHistory() {
exec('git init', function (err) {
echoAndExec('git init', function (err) {
if (err) throw err;

exec(scm + ' show history -j -C ' + component + ' -u ' + user + ' -P ' + password, {
echoAndExec(scm + ' show history -j -C ' + component + ' -u ' + user + ' -P ' + password, {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;
Expand All @@ -157,10 +157,10 @@ function walkThroughHistory() {
author = name + ' <' + email + '>',
modified = new Date(change.modified).toISOString();

exec('git add -A', function (err, stdout, stderr) {
echoAndExec('git add -A', function (err, stdout, stderr) {
if (err) throw err;

exec(['GIT_COMMITTER_EMAIL="' + email + '"',
echoAndExec(['GIT_COMMITTER_EMAIL="' + email + '"',
'GIT_COMMITTER_NAME="' + name + '"',
'GIT_COMMITTER_DATE="' + modified + '"',
'git commit',
Expand All @@ -170,7 +170,7 @@ function walkThroughHistory() {
'--allow-empty'].join(' '), function (err, stdout, stderr) {
if (err) throw err;

exec(scm + ' show status -i in:cbC -j -u ' + user + ' -P ' + password, {
echoAndExec(scm + ' show status -i in:cbC -j -u ' + user + ' -P ' + password, {
maxBuffer: maxBuffer
}, function (err, stdout, stderr) {
if (err) throw err;
Expand All @@ -189,3 +189,8 @@ function walkThroughHistory() {
});
});
}

function echoAndExec(cmd, options, callback) {
console.log(cmd);
return exec(cmd, options, callback);
}

0 comments on commit 732983c

Please sign in to comment.