<commit_before>"""Gather version information for PPROF."""

from plumbum import local
from plumbum.cmd import git

from pprof.settings import CFG
from os import path


def get_git_hash(from_url):
    """
    Get the git commit hash of HEAD from :from_url.

    Args:
        from_url: The file system url of our git repository.

    Returns:
        git commit hash of HEAD, or empty string.
    """
    if from_url is None:
        return ""

    if not path.exists(from_url):
        return ""

    with local.cwd(from_url):
        return git("rev-parse", "HEAD", retcode=None)


LLVM_VERSION = get_git_hash(CFG["llvm"]["src"])
CLANG_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools",
                                       "clang"))
POLLY_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools",
                                       "polly"))
POLLI_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools", "polly",
                                       "tools", "polli"))<commit_msg>versions: convert config value to string explicitly<commit_after>"""Gather version information for PPROF."""

from plumbum import local
from plumbum.cmd import git

from pprof.settings import CFG
from os import path


def get_git_hash(from_url):
    """
    Get the git commit hash of HEAD from :from_url.

    Args:
        from_url: The file system url of our git repository.

    Returns:
        git commit hash of HEAD, or empty string.
    """
    if from_url is None:
        return ""

    if not path.exists(from_url):
        return ""

    with local.cwd(from_url):
        return git("rev-parse", "HEAD", retcode=None)


LLVM_VERSION = get_git_hash(str(CFG["llvm"]["src"]))
CLANG_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools",
                                       "clang"))
POLLY_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools",
                                       "polly"))
POLLI_VERSION = get_git_hash(path.join(str(CFG["llvm"]["src"]), "tools", "polly",
                                       "tools", "polli"))
{'fraction_non_alphanumeric': 0.13031026252983294, 'fraction_numerical': 0.0, 'mean_word_length': 2.4530477759472817, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '82371', 'n_tokens_mistral': 649, 'n_tokens_neox': 644, 'n_words': 169}