<commit_before>// Copyright 2015, University of Colorado Boulder

/**
 * Grunt task that determines created and last modified dates from git, and updates copyright statements accordingly,
 * see #403
 *
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> <<EMAIL>>
 */

'use strict';

const execute = require( './execute' );
const fs = require( 'fs' );

/**
 * @public
 * @param {string} repo - The repository of the file to update (should be a git root)
 * @param {string} relativeFile - The filename relative to the repository root.
 * @returns {Promise}
 */
module.exports = async ( repo, relativeFile ) => {

  const startDate = ( await execute( 'git', [
    'log', '--diff-filter=A', '--follow', '--date=short', '--format=%cd', '-1', '--', relativeFile
  ], {
    cwd: `../${repo}`
  } ) ).trim().split( '-' )[ 0 ];

  const endDate = ( await execute( 'git', [
    'log', '--follow', '--date=short', '--format=%cd', '-1', '--', relativeFile
  ], {
    cwd: `../${repo}`
  } ) ).trim().split( '-' )[ 0 ];
<commit_msg>fill in 2002 as start date if there is a bug in getting the start date, https://github.com/phetsims/chipper/issues/766<commit_after>// Copyright 2015, University of Colorado Boulder

/**
 * Grunt task that determines created and last modified dates from git, and updates copyright statements accordingly,
 * see #403
 *
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> <<EMAIL>>
 */

'use strict';

const execute = require( './execute' );
const fs = require( 'fs' );

/**
 * @public
 * @param {string} repo - The repository of the file to update (should be a git root)
 * @param {string} relativeFile - The filename relative to the repository root.
 * @returns {Promise}
 */
module.exports = async ( repo, relativeFile ) => {

  let startDate = ( await execute( 'git', [
    'log', '--diff-filter=A', '--follow', '--date=short', '--format=%cd', '-1', '--', relativeFile
  ], {
    cwd: `../${repo}`
  } ) ).trim().split( '-' )[ 0 ];

  // There is a bug with the above git log command that sometimes yields a blank link as output
  if ( startDate === '' ) {
    startDate = '2002';
  }

  const endDate = ( await execute( 'git', [
    'log', '--follow', '--date=short', '--format=%cd', '-1', '--', relativeFile
  ], {
    cwd: `../${repo}`
  } ) ).trim().split( '-' )[ 0 ];

{'fraction_non_alphanumeric': 0.1950171821305842, 'fraction_numerical': 0.014175257731958763, 'mean_word_length': 3.2268602540834848, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '2739353', 'n_tokens_mistral': 762, 'n_tokens_neox': 731, 'n_words': 250}