Skip to content

Commit

Permalink
use git reset instead of git stash
Browse files Browse the repository at this point in the history
The old undo command would have thrown away *all* stashes - causing data loss
  • Loading branch information
basti1302 committed Jan 30, 2016
1 parent e04ad56 commit b494884
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion conf/scms-win32.json
Expand Up @@ -5,7 +5,7 @@
"get": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git pull --rebase",
"changes": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git status -s && git log --branches --not --remotes --oneline",
"save": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git push origin master",
"undo": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git stash && git stash clear"
"undo": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git reset --hard"
},
"svn": {
"delete": "rmdir \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" /s /q",
Expand Down
2 changes: 1 addition & 1 deletion conf/scms.json
Expand Up @@ -5,7 +5,7 @@
"get": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git pull --rebase",
"changes": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git status -s; git log --branches --not --remotes --oneline",
"save": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git push origin master",
"undo": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git stash; git stash clear"
"undo": "cd \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\" && git reset --hard"
},
"svn": {
"delete": "rm -rf \"{{{workspace}}}{{{pathseparator}}}{{{name}}}\"",
Expand Down
2 changes: 1 addition & 1 deletion lib/repoman.js
Expand Up @@ -125,7 +125,7 @@ Repoman.prototype.exec = function (command, opts, cb) {
console.log('\n+ %s', name);
var renderedCommand = mustache.render(fullCommand, params);
if (opts.verbose) {
console.log('> %s', renderedCommand.replace(/^cd.+?; /, ''));
console.log('> %s', renderedCommand.replace(/^cd ".+?" && /, ''));
}
bag.exec(renderedCommand, !opts.failFast, cb);
});
Expand Down
2 changes: 1 addition & 1 deletion test-integration/success-config-file.yml
Expand Up @@ -34,4 +34,4 @@
- description: Command undo should remove uncommitted changes
command: '{repoman} undo'
exitcode: 0
output: 'No local changes to save'
output: 'HEAD is now at'
4 changes: 2 additions & 2 deletions test-integration/success.yml
Expand Up @@ -38,7 +38,7 @@
- description: Command undo should remove uncommitted changes
command: '{repoman} undo'
exitcode: 0
output: 'No local changes to save'
output: 'HEAD is now at'

- description: Command exec should execute nothing when tags is specified and there is no matching repo
command: '{repoman} --tags inexistingtag exec "touch somefile" --verbose'
Expand All @@ -48,4 +48,4 @@
- description: Command exec should execute nothing when regex is specified and there is no matching repo
command: '{repoman} --regex .*inexistingrepo.* exec "touch somefile" --verbose'
exitcode: 0
output: ''
output: ''
8 changes: 4 additions & 4 deletions test/repoman.js
Expand Up @@ -153,8 +153,8 @@ buster.testCase('repoman - exec', {
var repoman = new Repoman(this.repos, this.scms);
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";');
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";');
done();
});
},
Expand All @@ -168,7 +168,7 @@ buster.testCase('repoman - exec', {
var repoman = new Repoman(this.repos, this.scms);
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";');
assert.equals(results[0], 'cd "/somedir/couchdb" && touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
done();
});
},
Expand All @@ -182,7 +182,7 @@ buster.testCase('repoman - exec', {
var repoman = new Repoman(this.repos, this.scms);
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";');
assert.equals(results[0], 'cd "/somedir/couchdb" && touch .gitignore; echo "Created /somedir/couchdb/.gitignore file";');
done();
});
},
Expand Down

0 comments on commit b494884

Please sign in to comment.