<commit_before>#!/usr/bin/env node

"use strict";

const moment = require("moment");
const sugar = require("sugar");
const chalk = require("chalk");
const exec = require("child_process").exec;

let fatal = err => {
    console.error(`fatal: ${err}`);
    process.exit(1);
};

process.argv.splice(0, 2);
if (process.argv.length === 0) {
    fatal("No date string given");
};

let date = process.argv.join(" ");
let parsedDate = new sugar.Date.create(date);

if (/Invalid Date/.test(parsedDate)) {
    fatal(`Could not parse ${date} into a valid date`);
};

let dateString = moment(parsedDate).format("ddd MMM DD HH:mm:ss YYYY ZZ");

let command = `GIT_COMMITTER_DATE="${dateString}" git commit --amend --date="${dateString}" --no-edit`;
exec(command, (err, stdout, stderr) => {
    if (err) fatal("Could not modify the date of the previous commit");
    console.log(chalk`\nModified previous commit:\n    AUTHOR_DATE {grey ${dateString}}\n    COMMITTER_DATE {grey ${dateString}}\n\nCommand executed:\n    {bgWhite.black ${command}}\n`);
});<commit_msg>Change colour of command executed<commit_after>#!/usr/bin/env node

"use strict";

const moment = require("moment");
const sugar = require("sugar");
const chalk = require("chalk");
const exec = require("child_process").exec;

let fatal = err => {
    console.error(`fatal: ${err}`);
    process.exit(1);
};

process.argv.splice(0, 2);
if (process.argv.length === 0) {
    fatal("No date string given");
};

let date = process.argv.join(" ");
let parsedDate = new sugar.Date.create(date);

if (/Invalid Date/.test(parsedDate)) {
    fatal(`Could not parse ${date} into a valid date`);
};

let dateString = moment(parsedDate).format("ddd MMM DD HH:mm:ss YYYY ZZ");

let command = `GIT_COMMITTER_DATE="${dateString}" git commit --amend --date="${dateString}" --no-edit`;
exec(command, (err, stdout, stderr) => {
    if (err) fatal("Could not modify the date of the previous commit");
    console.log(chalk`\nModified previous commit:\n    AUTHOR_DATE {grey ${dateString}}\n    COMMITTER_DATE {grey ${dateString}}\n\nCommand executed:\n    {grey ${command}}\n`);
});
{'fraction_non_alphanumeric': 0.18220539517274018, 'fraction_numerical': 0.003786086133459536, 'mean_word_length': 4.592592592592593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '166581', 'n_tokens_mistral': 705, 'n_tokens_neox': 693, 'n_words': 188}