<commit_before>const { execSync } = require("child_process");

module.exports = {
    run: function run(command) {
        return execSync(command).toString().trim()
    },
    getCommitId: function getCommitId() {
        return this.run('git rev-parse --short HEAD');
    },
    determineVersion: function determineVersion() {
        // Form version string - branch name and commit id
        let commitId = this.getCommitId();
        let branchName;
        if (process.env.BRANCH_NAME) {
            console.log('Using BRANCH_NAME from the environment')
            branchName = process.env.BRANCH_NAME
        } else {
            console.log('Using local Git repo to determine branch name (environment BRANCH_NAME may also be used)')
            branchName = this.run('git branch --show-current').replace(/\//g,"-")
        }

        // Distinguish from local use
        let ciIndicator = (process.env.BUILDKITE ? "ci-" : "")

        // Get the current version from lerna.json
        const lerna = require("../lerna.json");
        let lernaVersion = lerna.version.match(/^[1-9][0-9]*\.[0-9]+\.[0-9]+/)[0];

        return `${lernaVersion}-${ciIndicator}${branchName}.${commitId}`
    }
}<commit_msg>chore(review): review comments actioned<commit_after>const lerna = require("../lerna.json");
const { execSync } = require("child_process");

module.exports = {
    run: function run(command) {
        return execSync(command).toString().trim()
    },
    getCommitId: function getCommitId() {
        return this.run('git rev-parse --short HEAD');
    },
    determineVersion: function determineVersion() {
        // Form version string - branch name and commit id
        let commitId = this.getCommitId();
        let branchName;
        if (process.env.BRANCH_NAME) {
            console.log('Using BRANCH_NAME from the environment')
            branchName = process.env.BRANCH_NAME
        } else {
            console.log('Using local Git repo to determine branch name (environment BRANCH_NAME may also be used)')
            branchName = this.run('git rev-parse --abbrev-ref HEAD').replace(/\//g,"-")
        }

        // Distinguish from local use
        let ciIndicator = (process.env.BUILDKITE ? "ci-" : "")

        // Get the current version from lerna.json
        let lernaVersion = lerna.version.match(/^[1-9][0-9]*\.[0-9]+\.[0-9]+/)[0];

        return `${lernaVersion}-${ciIndicator}${branchName}.${commitId}`
    }
}
{'fraction_non_alphanumeric': 0.1437908496732026, 'fraction_numerical': 0.007352941176470588, 'mean_word_length': 2.488603988603989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1154706', 'n_tokens_mistral': 716, 'n_tokens_neox': 714, 'n_words': 170}