<commit_before>var os = require('os');
var path = require('path');
var async = require('async');
var rmdir = require('rimraf');
var Getopt = require('node-getopt');
var randomstring = require('randomstring');

var git = require('./lib/git.js');
var pkg = require('./lib/version.js');
var notes = require('./lib/release-notes.js');

// Clean up after ourselves. We can happily just blitz the entire repository
// since we no longer need it.

function cleanup(repo) {
    rmdir(repo, function(err) {
        if (err) {
            console.log('Error removing temporary repository %s', repo);
        }
    });
}

// The minimum we need from the user is a remote URL for the repository being
// cloned and release to (or the help flag, but then we're just bailing and
// displaying the usage). The working directory used is generated using a
// random, prefixed directory name but can be overridden using the relevant
// flag.

getopt = new Getopt([
    ['', 'remote=URL',
        '[Required] The URL of the git repository to release to'],
    ['', 'tmpdir=PATH',
        '[Optional] The temporary directory to clone the repository to'],
    ['h', 'help', 'display this help text.']
]);

getopt.setHelp("Usage: rbrelease [options]\n[[OPTIONS]]");
getopt.bindHelp();

var version = '0.0.0';
var options = getopt.parseSystem().options;
var repo = os.tmpdir() + path.sep + 'rbrelease_' + randomstring.generate(8);

if (!options.remote) {
    getopt.showHelp();
    process.exit(1);
}

if (options.tmpdir) {
    repo = options.tmpdir;
}

// Since there is nothing to clean up until we've successfully done the clone.
// The remaining steps are done using `async.waterfall` so we pass values down
// the chain and know that the cloned repository will be cleaned up regardless
// of if the release completed successfully or not.

git.clone(options.remote, repo , function(err) {
    if (err) {
        console.log(err);
    } else {
        async.waterfall(
            [
                function(callback) {
                    pkg.getDefaultVersion(repo, callback);
                },
                function(defaultVersion, callback) {
                    pkg.getVersion(defaultVersion, callback);
                },
                function(releaseVersion, callback) {
                    version = releaseVersion;
                    pkg.setVersion(repo, version, callback);
                },
                function(callback) {
                    notes.update(repo, callback);
                },
                function(callback) {
                    git.release(repo, version, callback);
                }
            ], function (err) {
                cleanup(repo);

                if (err) {
                    console.log(err);
                } else {
                    console.log('Released %s to production branch.', version);
                }

            }
        );
    }
});<commit_msg>Add license to file<commit_after>var os = require('os');
var path = require('path');
var async = require('async');
var rmdir = require('rimraf');
var Getopt = require('node-getopt');
var randomstring = require('randomstring');

var git = require('./lib/git.js');
var pkg = require('./lib/version.js');
var notes = require('./lib/release-notes.js');

// Clean up after ourselves. We can happily just blitz the entire repository
// since we no longer need it.

function cleanup(repo) {
    rmdir(repo, function(err) {
        if (err) {
            console.log('Error removing temporary repository %s', repo);
        }
    });
}

// The minimum we need from the user is a remote URL for the repository being
// cloned and release to (or the help flag, but then we're just bailing and
// displaying the usage). The working directory used is generated using a
// random, prefixed directory name but can be overridden using the relevant
// flag.

getopt = new Getopt([
    ['', 'remote=URL',
        '[Required] The URL of the git repository to release to'],
    ['', 'tmpdir=PATH',
        '[Optional] The temporary directory to clone the repository to'],
    ['h', 'help', 'display this help text.']
]);

getopt.setHelp("Usage: rbrelease [options]\n[[OPTIONS]]");
getopt.bindHelp();

var version = '0.0.0';
var options = getopt.parseSystem().options;
var repo = os.tmpdir() + path.sep + 'rbrelease_' + randomstring.generate(8);

if (!options.remote) {
    getopt.showHelp();
    process.exit(1);
}

if (options.tmpdir) {
    repo = options.tmpdir;
}

// Since there is nothing to clean up until we've successfully done the clone.
// The remaining steps are done using `async.waterfall` so we pass values down
// the chain and know that the cloned repository will be cleaned up regardless
// of if the release completed successfully or not.

git.clone(options.remote, repo , function(err) {
    if (err) {
        console.log(err);
    } else {
        async.waterfall(
            [
                function(callback) {
                    pkg.getDefaultVersion(repo, callback);
                },
                function(defaultVersion, callback) {
                    pkg.getVersion(defaultVersion, callback);
                },
                function(releaseVersion, callback) {
                    version = releaseVersion;
                    pkg.setVersion(repo, version, callback);
                },
                function(callback) {
                    notes.update(repo, callback);
                },
                function(callback) {
                    git.release(repo, version, callback);
                }
            ], function (err) {
                cleanup(repo);

                if (err) {
                    console.log(err);
                } else {
                    console.log('Released %s to production branch.', version);
                }

            }
        );
    }
});

// ## License
//
// Copyright (c) 2014, <NAME> <<EMAIL>>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
{'fraction_non_alphanumeric': 0.11524500907441017, 'fraction_numerical': 0.002117362371445856, 'mean_word_length': 2.2384916748285995, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1937508', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1694, 'n_words': 622}