Skip to content

Instantly share code, notes, and snippets.

@MadLittleMods
Last active October 1, 2015 16:24
Show Gist options
  • Select an option

  • Save MadLittleMods/7366e2797eb96da5857c to your computer and use it in GitHub Desktop.

Select an option

Save MadLittleMods/7366e2797eb96da5857c to your computer and use it in GitHub Desktop.
Removes files that are missing from the repo. `node svn-remove-missing.js`
var exec = require('child_process').exec;
var svnRemoveFile = function(filePath) {
var child = exec('svn rm "' + filePath + '" --force', function(err, stdout, stderr) {
/* * /
if(err) {
console.log(err);
}
if(stderr) {
console.log(stderr);
}
/* */
console.log(stdout);
});
child.on('exit', function (exitCode) {
if(exitCode !== 0) {
console.log(`Child exited with code: ${exitCode}`);
}
process.exitCode = 0;
});
};
console.log('Starting to remove missing files from SVN repo');
exec('svn st | grep ^!', function(err, stdout, stderr) {
if(err) {
console.log(err);
}
if(stderr) {
console.log(stderr);
}
var missingFilePaths = stdout
.split(/\n/)
.map(function(item) {
var matches = item.match(/!\s*(.*?)$/);
if(matches && matches.length >= 1) {
return matches[1];
}
return false;
})
.filter(function(path) {
return path;
});
missingFilePaths.forEach(function(filePath) {
svnRemoveFile(filePath);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment