<commit_before>#!/usr/bin/env node
require('shelljs/global');

// Creates a changelog for the current build and puts it in the root
// Commits the changelog if it updated
// Does not push commit

function parseGitUri(uri) {
  return uri.match(/https:..github.com\/([^./]+)\/([^./]+).*/) ||
    uri.match(/git@github.com:(.*)\/(.*)\.git/);
}

function verifyChangelog() {
  var diff = exec('git diff HEAD~1').split('\n');
  var changelog = cat('CHANGELOG.md').split('\n');
  var isOneLine = (changelog.length === 1);
  var deletions = 0;
  var containsErrorMessage = false;
  diff.filter(function (line) {
    if (/^-/.test(line)) deletions++;
    if (line.indexOf('Make a POST first') >= 0) containsErrorMessage = true;
  });
  if (isOneLine) {
    revertChanges();
    console.error('Changelog diff should be more than 1 line long');
    process.exit(3);
  }
  if (deletions > 10) {
    revertChanges();
    console.error('Too many deletions (-' + deletions + '), verify that the changes to CHANGELOG.md are correct');
    process.exit(4);
  }
  if (containsErrorMessage) {<commit_msg>Diff against HEAD, and only for changelog<commit_after>#!/usr/bin/env node
require('shelljs/global');

// Creates a changelog for the current build and puts it in the root
// Commits the changelog if it updated
// Does not push commit

function parseGitUri(uri) {
  return uri.match(/https:..github.com\/([^./]+)\/([^./]+).*/) ||
    uri.match(/git@github.com:(.*)\/(.*)\.git/);
}

function verifyChangelog() {
  var diff = exec('git diff HEAD CHANGELOG.md').split('\n');
  var changelog = cat('CHANGELOG.md').split('\n');
  var isOneLine = (changelog.length === 1);
  var deletions = 0;
  var containsErrorMessage = false;
  diff.filter(function (line) {
    if (/^-/.test(line)) deletions++;
    if (line.indexOf('Make a POST first') >= 0) containsErrorMessage = true;
  });
  if (isOneLine) {
    revertChanges();
    console.error('Changelog diff should be more than 1 line long');
    process.exit(3);
  }
  if (deletions > 10) {
    revertChanges();
    console.error('Too many deletions (-' + deletions + '), verify that the changes to CHANGELOG.md are correct');
    process.exit(4);
  }
  if (containsErrorMessage) {
{'fraction_non_alphanumeric': 0.1786521935775667, 'fraction_numerical': 0.007688828584350972, 'mean_word_length': 3.523517382413088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1125691', 'n_tokens_mistral': 761, 'n_tokens_neox': 729, 'n_words': 199}