<commit_before>/**
 * gitclone <https://github.com/tunnckoCore/gitclone>
 *
 * Copyright (c) 2014-2015 <NAME>, contributors.
 * Released under the MIT license.
 */

'use strict';

var path = require('path');
var fmt = require('util').format;
var run = require('exec-cmd');
var handleArguments = require('handle-arguments');
var stringify = require('stringify-github-short-url');
var handleErrors = require('handle-errors')('gitclone');
var error = handleErrors.error;
var type = handleErrors.type;

// docs
module.exports = function gitclone() {
  var argz = handleArguments(arguments);
  var args = checkArguments(argz.args);
  args = buildArguments(args);

  return run(args.cmd, args.opts, argz.callback);
};

/**
 * > Create flexible arguments - check types and normalize incoming arguments.
 *<commit_msg>notify when branch/tag not found<commit_after>/**
 * gitclone <https://github.com/tunnckoCore/gitclone>
 *
 * Copyright (c) 2014-2015 <NAME>, contributors.
 * Released under the MIT license.
 */

'use strict';

var path = require('path');
var fmt = require('util').format;
var run = require('exec-cmd');
var rimraf = require('rimraf');
var arrayEqual = require('array-equal');
var handleArguments = require('handle-arguments');
var stringify = require('stringify-github-short-url');
var handleErrors = require('handle-errors')('gitclone');
var error = handleErrors.error;
var type = handleErrors.type;

// docs
module.exports = function gitclone() {
  var argz = handleArguments(arguments);
  var args = checkArguments(argz.args);
  args = buildArguments(args);

  return run(args.cmd, args.opts, argz.callback).catch(function(err) {
    var dir = args.dest.split('/')[0];
    if (arrayEqual(args.opts.stdio, [null, null, null])) {
      // jscs:disable maximumLineLength
      console.log('fatal: Remote branch %s not found in upstream origin', args.res.branch);
      // jscs:enable maximumLineLength
      rimraf.sync(dir);
      throw err;
    }
    rimraf.sync(dir);
    throw err;
  });
};

/**
 * > Create flexible arguments - check types and normalize incoming arguments.
 *
{'fraction_non_alphanumeric': 0.15105162523900573, 'fraction_numerical': 0.008126195028680689, 'mean_word_length': 4.352941176470588, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '5570843', 'n_tokens_mistral': 646, 'n_tokens_neox': 620, 'n_words': 166}