<commit_before>/* eslint no-console: 'off' */
import argv from 'minimist-argv';
import { readFileSync, unlinkSync } from 'fs';
import { execSync, spawnSync } from 'child_process';
import prepareCommitMessage from './prepare-commit-msg';
import notification from './notifications';

export default function () {
  ['p', 'C', 'c', 'm', 't'].forEach((argKey) => {
    if (argv[argKey]) {
      console.log(`Argument -${argKey} not supported`);
      process.exit(1);
    }
  });

  [
    'patch',
    'reuse-message',
    'reedit-message',
    'fixup',
    'squash',
    'message',
    'template',
    'amend',
  ].forEach((argKey) => {
    if (argv[argKey]) {
      console.log(`Argument --${argKey} not supported`);
      process.exit(1);
    }
  });

  argv.path = '#temp_commit';
  prepareCommitMessage()
    .then(() => {
      execSync('$EDITOR \\#temp_commit', { stdio: 'inherit' });

      const commitMsg = readFileSync(argv.path);
      if (!commitMsg) {
        throw new Error('The commit message is empty');
      }

      spawnSync(
        'git',
        ['commit'].concat(process.argv.slice(2)).concat(`-m${commitMsg}`),
        { stdio: 'inherit' },
      );
    })
    .then(() => {
      unlinkSync(argv.path);
    })
    .catch((msg) => {
      notification.failure(msg);
      process.exit(1);
    });
}
<commit_msg>fix(msg): use -f options instead of -m when commiting<commit_after>/* eslint no-console: 'off' */
import argv from 'minimist-argv';
import { unlinkSync } from 'fs';
import { execSync, spawnSync } from 'child_process';
import prepareCommitMessage from './prepare-commit-msg';
import notification from './notifications';

export default function () {
  ['p', 'C', 'c', 'm', 't'].forEach((argKey) => {
    if (argv[argKey]) {
      console.log(`Argument -${argKey} not supported`);
      process.exit(1);
    }
  });

  [
    'patch',
    'reuse-message',
    'reedit-message',
    'fixup',
    'squash',
    'message',
    'template',
    'amend',
  ].forEach((argKey) => {
    if (argv[argKey]) {
      console.log(`Argument --${argKey} not supported`);
      process.exit(1);
    }
  });

  argv.path = '#temp_commit';
  prepareCommitMessage()
    .then(() => {
      execSync('$EDITOR \\#temp_commit', { stdio: 'inherit' });

      spawnSync(
        'git',
        ['commit', `-F${argv.path}`].concat(process.argv.slice(2)),
        { stdio: 'inherit' },
      );
    })
    .then(() => {
      unlinkSync(argv.path);
    })
    .catch((msg) => {
      notification.failure(msg);
      process.exit(1);
    });
}

{'fraction_non_alphanumeric': 0.19850921930168694, 'fraction_numerical': 0.003138485680659082, 'mean_word_length': 2.6956521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1145325', 'n_tokens_mistral': 855, 'n_tokens_neox': 855, 'n_words': 170}