Skip to content

Instantly share code, notes, and snippets.

@gimmi
Created November 16, 2011 08:24
Show Gist options
  • Save gimmi/1369576 to your computer and use it in GitHub Desktop.
Save gimmi/1369576 to your computer and use it in GitHub Desktop.
JSMake examples
jsmake.svn = {};
jsmake.svn.SvnUtils = function () {
this._svnVersionPath = 'svnversion';
};
jsmake.svn.SvnUtils.prototype = {
isWorkingFolderClear: function (path) {
var version = this._svnVersion(path);
return !(version.modified || version.switched || version.partial || version.mixed);
},
getWorkingFolderRevision: function (path) {
return this._svnVersion(path).revision;
},
updateWorkingFolder: function (path) {
// TODO
},
_svnVersion: function (path) {
var out = this._run(this._svnVersionPath, [ '--no-newline', path ]);
return {
modified: out.indexOf('M') !== -1,
switched: out.indexOf('S') !== -1,
partial: out.indexOf('P') !== -1,
mixed: out.indexOf(':') !== -1,
revision: parseInt(/^\d+/.exec(out), 10)
};
},
_run: function (command, args) {
var options = {
args: args,
output: ''
};
var exitStatus = runCommand(command, options);
if( exitStatus !== 0) {
throw 'Command failed with exit status ' + exitStatus;
}
return options.output;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment