<commit_before>var fs = require('fs')
  , path = require('path')
  , root = process.cwd().replace(/node_modules\//, '')
  , utils = require('./utils')
  , hooks = require('./hooks')
  , userHooksDir = '.hooks';

var gh = {

  root: root,

  userHooks: userHooksDir,

  isGitProject: function() {
    return utils.dirExists(path.join(root, '.git'));
  },

  hasGitHooksDir: function() {
    return utils.dirExists(path.join(root, '.git/hooks'));
  },

  hasUserHooksDir: function() {
    return utils.dirExists(path.join(root, userHooksDir));
  },

  installHooks: function(hook) {
    var userHooks = fs.readdirSync(path.join(root, userHooksDir)) || []
      , installHooks = typeof hook !== 'undefined' ? hooks.filter(function(h) { return h === hook; }) : hooks;

    installHooks.forEach(function(hook) {
      var userHook = path.join(root, userHooksDir, hook);
      if(utils.fileExists(userHook)) {
        var targetPath = path.join(root, '.git/hooks', hook);

        // check to see if the user already has a git hook
        if(utils.fileExists(targetPath) &&
          !fs.readFileSync(targetPath, 'UTF-8').match('Generated by git-hooked. Do not modify!')) {
          console.log(
            'Found an existing hook for ' + hook + '\n' +
            'Backing up to .git/hooks/' + hook + '.user'
          );
          fs.renameSync(targetPath, targetPath + '.user');
        }

        console.log('Installing ' + hook + ' hook...')

        fs.createReadStream(path.join(__dirname, 'hook.template.js'))
          .pipe(fs.createWriteStream(targetPath, hook))
          .on('end', function() {
            fs.chmod(targetPath, 0755);
            fs.chmod(userHook, 0755);
          });

      }

    });

  }

};

module.exports = gh;<commit_msg>fixing chmod<commit_after>var fs = require('fs')
  , path = require('path')
  , root = process.cwd().replace(/node_modules\//, '')
  , utils = require('./utils')
  , hooks = require('./hooks')
  , userHooksDir = '.hooks';

var gh = {

  root: root,

  userHooks: userHooksDir,

  isGitProject: function() {
    return utils.dirExists(path.join(root, '.git'));
  },

  hasGitHooksDir: function() {
    return utils.dirExists(path.join(root, '.git/hooks'));
  },

  hasUserHooksDir: function() {
    return utils.dirExists(path.join(root, userHooksDir));
  },

  installHooks: function(hook) {
    var userHooks = fs.readdirSync(path.join(root, userHooksDir)) || []
      , installHooks = typeof hook !== 'undefined' ? hooks.filter(function(h) { return h === hook; }) : hooks;

    installHooks.forEach(function(hook) {
      var userHook = path.join(root, userHooksDir, hook);
      if(utils.fileExists(userHook)) {
        var targetPath = path.join(root, '.git/hooks', hook);

        // check to see if the user already has a git hook
        if(utils.fileExists(targetPath) &&
          !fs.readFileSync(targetPath, 'UTF-8').match('Generated by git-hooked. Do not modify!')) {
          console.log(
            'Found an existing hook for ' + hook + '\n' +
            'Backing up to .git/hooks/' + hook + '.user'
          );
          fs.renameSync(targetPath, targetPath + '.user');
        }

        console.log('Installing ' + hook + ' hook...')

        fs.createReadStream(path.join(__dirname, 'hook.template.js'))
          .pipe(fs.createWriteStream(targetPath, hook))

        fs.chmod(targetPath, 0755);
        fs.chmod(userHook, 0755);

      }

    });

  }

};

module.exports = gh;
{'fraction_non_alphanumeric': 0.16502890173410403, 'fraction_numerical': 0.005202312138728324, 'mean_word_length': 2.6508438818565403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1827787', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1121, 'n_words': 222}