<commit_before>//// NPM
const simpleGit = require('simple-git/promise')
//// CORE
const path = require('path')
//// LOCAL
const { format, log } = require('../lib/log')
const { words } = require('../lib/store')

const { appRepo } = require('../package.json')
const config = require('../config/config.json')

const git = simpleGit(process.cwd())

const remote = `https://${config.git.user}:${Promise.resolve(words.getLast('remote'))}@${config.git.origin}`;

module.exports = repo = {
  commit: async (commitComment=`autocommit at shutdown`) => {
    if (!await git.checkIsRepo()) {
      log('error', `would have run newLocal` )
      //await repo.newLocal()
    } 
    return git.add('.')
    .then( (result) => {  
// TODO !!! prompt for comment  !!!     
      return git.commit('Changes detected at anonym shutdown')
    })
    .catch( err => log('error', `(commitChanges) error\n${format(error)}`))  
  },  
  git,  
  newLocal: async () => {
    if (!await git.checkIsRepo()) {
      await git.addConfig('user.name', config.git.user)
      await git.addConfig('user.email', config.git.email)
      await git.init(process.cwd())
      await git.addRemote('origin', config.git.origin)
      ///////await git.fetch() // fetch will overwrite local
    }              
  },
  push: async (origin=config.git.origin) => {
    if (origin && (await repo.git.status()).ahead>0) {
      await git.addRemote('origin', origin)
      await git.push('origin', 'master')
      log('log', `tracked changes pushed`)
    }  
  }

}
<commit_msg>Changes detected at anonym shutdown<commit_after>//// NPM
const simpleGit = require('simple-git/promise')
//// CORE
const path = require('path')
//// LOCAL
const { format, log } = require('../lib/log')
const { words } = require('../lib/store')

const { appRepo } = require('../package.json')
const config = require('../config/config.json')

const git = simpleGit(process.cwd())

const remote = `https://${config.git.user}:${Promise.resolve(words.getLast('remote'))}@${config.git.origin}`;

module.exports = repo = {
  commit: async (commitComment=`autocommit at shutdown`) => {
    if (!await git.checkIsRepo()) {
      log('error', `would have run newLocal` )
      //await repo.newLocal()
    } 
    return git.add('.')
    .then( (result) => {  
// TODO !!! prompt for comment  !!!     
      return git.commit('Changes detected at anonym shutdown')
    })
    .catch( err => log('error', `(commitChanges) error\n${format(error)}`))  
  },  
  git,  
  newLocal: async () => {
    if (!await git.checkIsRepo()) {
      await git.addConfig('user.name', config.git.user)
      await git.addConfig('user.email', config.git.email)
      await git.init(process.cwd())
      await git.addRemote('origin', config.git.origin)
      ///////await git.fetch() // fetch will overwrite local
    }              
  },
  push: async (origin=config.git.origin) => {
    try {
      if (origin && (await repo.git.status()).ahead>0) {
        if (await git.getRemote()) await git.push('origin', 'master')
        log('log', `tracked changes pushed`)
      }  
    }
    catch(err) {
      log('error', `(push) error \n${format(err)}`)
    }
  }

}

{'fraction_non_alphanumeric': 0.1941808981657179, 'fraction_numerical': 0.0006325110689437065, 'mean_word_length': 2.8479318734793186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '166896', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1029, 'n_words': 220}