<commit_before>// Copyright (C) 2020 <NAME>, <<EMAIL>>.
// This file is distributed under the MIT licence. For more information,
// please refer to the accompanying "LICENCE" file.

const childProcess = require('child_process');
const addSlugsToItems = require('toolbox-sass/buildstatic/modifiers/add-slugs-to-items');
const addSitemap = require('toolbox-sass/buildstatic/modifiers/add-sitemap')

function addGitMetadataToItems(globalData, items) {
  return [
    globalData,
    items.map((item) => {
      if (item.data.inputFilePath === null) {
        return item;
      }

      const [createdHash, createdTimestamp] =
        childProcess.execSync(
          `git log --diff-filter=A --follow --format='%H %at' -1 -- ${item.data.inputFilePath}`,
        )
          .toString()
          .split(' ');
      const [lastModifiedHash, lastModifiedTimestamp] =
        childProcess.execSync(
          `git log -n 1 --pretty=format:'%H %at' ${item.data.inputFilePath}`,
        )
          .toString()
          .split(' ');

      item.data.git = {
        created: {
          hash: createdHash,
          timestamp: new Date(parseInt(createdTimestamp, 10)),
        },
        updated: {
          hash: lastModifiedHash,
          timestamp: new Date(parseInt(lastModifiedTimestamp, 10)),
        }
      };
<commit_msg>Tweak Git metadata timestamp gubbins.<commit_after>// Copyright (C) 2020 <NAME>, <<EMAIL>>.
// This file is distributed under the MIT licence. For more information,
// please refer to the accompanying "LICENCE" file.

const childProcess = require('child_process');
const addSlugsToItems = require('toolbox-sass/buildstatic/modifiers/add-slugs-to-items');
const addSitemap = require('toolbox-sass/buildstatic/modifiers/add-sitemap')

function addGitMetadataToItems(globalData, items) {
  return [
    globalData,
    items.map((item) => {
      if (item.data.inputFilePath === null) {
        return item;
      }

      const [createdHash, createdTimestamp] =
        childProcess.execSync(
          `git log --diff-filter=A --follow --format='%H %ct' -1 -- ${item.data.inputFilePath}`,
        )
          .toString()
          .split(' ');
      const [lastModifiedHash, lastModifiedTimestamp] =
        childProcess.execSync(
          `git log -n 1 --pretty=format:'%H %ct' ${item.data.inputFilePath}`,
        )
          .toString()
          .split(' ');

      item.data.git = {
        created: {
          hash: createdHash,
          timestamp: new Date(parseInt(createdTimestamp, 10)),
        },
        updated: {
          hash: lastModifiedHash,
          timestamp: new Date(parseInt(lastModifiedTimestamp, 10)),
        }
      };

{'fraction_non_alphanumeric': 0.13490284005979072, 'fraction_numerical': 0.007473841554559043, 'mean_word_length': 2.4676165803108807, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4869330', 'n_tokens_mistral': 795, 'n_tokens_neox': 771, 'n_words': 176}