<commit_before>"use strict";

/* eslint no-process-exit:0 */

var parseDiff = require("../parse-diff");
var _ = require("lodash");
var async = require("async");
var fs = require("fs");

var git = require("../git");
var todos = require("../todos");
var github = require("../github");


exports.config = function (opts) {
  return opts
    .boolean("r")
    .alias("r", "remote")
    .describe("r", "Remote to which the push is being done")
    .string("R")
    .alias("R", "range")
    .describe("R", "Commits range to analyze, will expect git-hook data from standard input otherwise");
};

exports.run = function (argv, opts, conf) {
  if (process.env.DRY_RUN) {
    console.log("[Github-Todos] DRY_RUN set: no modifications to filesystem, no calls to Github API");
  }

  process.stdout.write("[Github-Todos] Checking Github Authentication… ");

  github.connect(conf, function (err) {
    if (err) {
      console.log("FAIL");
      console.error("Run 'github-todos auth' to re-authenticate to Github");
      console.error(err);
      process.exit(1);
      return;
    }

    console.log("OK");
    main(argv, conf);
  });
};

// Main process
// Object, Object → void
function main (argv, conf) {
  // FIXME detect repository or get from local config or get from CLI ?
  var repo = "naholyr/test-repos-for-github-todos";

  if (argv.range) {

    // Extract target SHA
    var targetCommit = _.last(argv.range.split(".."));
    git.run("rev-parse '" + targetCommit + "'", function (err, sha) {
      if (err) {
        throw err;
      }
<commit_msg>_hook: do not connect if not necessary (faster push when no TODO added)<commit_after>"use strict";

/* eslint no-process-exit:0 */

var parseDiff = require("../parse-diff");
var _ = require("lodash");
var async = require("async");
var fs = require("fs");

var git = require("../git");
var todos = require("../todos");
var github = require("../github");


exports.config = function (opts) {
  return opts
    .boolean("r")
    .alias("r", "remote")
    .describe("r", "Remote to which the push is being done")
    .string("R")
    .alias("R", "range")
    .describe("R", "Commits range to analyze, will expect git-hook data from standard input otherwise");
};

exports.run = function (argv, opts, conf) {
  if (process.env.DRY_RUN) {
    console.log("[Github-Todos] DRY_RUN set: no modifications to filesystem, no calls to Github API");
  }

  process.stdout.write("[Github-Todos] Checking Github Authentication… ");

  main(argv, conf);
};

// Main process
// Object, Object → void
function main (argv, conf) {
  // FIXME detect repository or get from local config or get from CLI ?
  var repo = "naholyr/test-repos-for-github-todos";

  if (argv.range) {

    // Extract target SHA
    var targetCommit = _.last(argv.range.split(".."));
    git.run("rev-parse '" + targetCommit + "'", function (err, sha) {
      if (err) {
        throw err;
      }

{'fraction_non_alphanumeric': 0.16964900206469374, 'fraction_numerical': 0.0010323468685478321, 'mean_word_length': 3.206946454413893, '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': '1407084', 'n_tokens_mistral': 955, 'n_tokens_neox': 933, 'n_words': 277}