<commit_before>﻿# EXIT CODES
# 1: dotnet packaging failure
# 2: dotnet publishing failure
# 3: Unit test failure
# 4: dotnet / NuGet package restore failure

<#
.SYNOPSIS
    Gets the set of directories in which projects are available for compile/processing.

.PARAMETER RootPath
    Path where searching for project directories should begin.
#>
function Get-DotNetProjectDirectory {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $True, ValueFromPipeline = $False, ValueFromPipelineByPropertyName = $False)]
        [ValidateNotNullOrEmpty()]
        [string]
        $RootPath
    )

    Get-ChildItem -Path $RootPath -Recurse -Include "*.csproj" | Select-Object @{ Name = "ParentFolder"; Expression = { $_.Directory.FullName.TrimEnd("\") } } | Select-Object -ExpandProperty ParentFolder
}

<#
.SYNOPSIS
    Runs the dotnet CLI install script from GitHub to install a project-local
    copy of the CLI.
#>
function Install-DotNetCli {
    [CmdletBinding()]
    Param(
        [string]
        $Version = "Latest"
    )

    if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) {
        $installedVersions = dotnet --list-sdks
        foreach ($sdkListLine in $installedVersions)
        {
            $splitParts = $sdkListLine.Split(" ");

            $versionPart = $splitParts[0];
            $globalInstallLocation = $splitParts[1].Replace("[", "").Replace("]", "")

            if ($versionPart -eq $Version)
            {
                Write-Message ".NET Core SDK version $Version is already installed in $globalInstallLocation"
                Add-Path "$globalInstallLocation"
                return;
            }
        }
    }

    Write-Message "Installing .NET SDK version $Version"

    $callerPath = Split-Path $MyInvocation.PSCommandPath
    $installDir = Join-Path -Path $callerPath -ChildPath ".dotnet/cli"
    if (!(Test-Path $installDir)) {
        New-Item -ItemType Directory -Path "$installDir" | Out-Null
    }

    # Download the dotnet CLI install script
    if ($IsWindows) {
        if (!(Test-Path ./.dotnet/dotnet-install.ps1)) {
            Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./.dotnet/dotnet-install.ps1"
        }

        & ./.dotnet/dotnet-install.ps1 -InstallDir "$installDir" -Version $Version
    } else {
        if (!(Test-Path ./.dotnet/dotnet-install.sh)) {
            Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./.dotnet/dotnet-install.sh"
        }

        & bash ./.dotnet/dotnet-install.sh --install-dir "$installDir" --version $Version
    }

    Add-Path "$installDir"
}

<#
.SYNOPSIS
    Appends a given value to the path but only if the value does not yet exist within the path.
.PARAMETER Path
    The path to append.
#>
function Add-Path {
    [CmdletBinding()]
    Param(
        [ValidateNotNullOrEmpty()]
        [string]
        $Path
    )
    $pathValues = $env:PATH.Split(";");
    if ($pathValues -Contains $Path) {
      return;
    }
    $env:PATH = "$Path;$env:PATH"<commit_msg>Add path separator fix<commit_after>﻿# EXIT CODES
# 1: dotnet packaging failure
# 2: dotnet publishing failure
# 3: Unit test failure
# 4: dotnet / NuGet package restore failure

<#
.SYNOPSIS
    Gets the set of directories in which projects are available for compile/processing.

.PARAMETER RootPath
    Path where searching for project directories should begin.
#>
function Get-DotNetProjectDirectory {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $True, ValueFromPipeline = $False, ValueFromPipelineByPropertyName = $False)]
        [ValidateNotNullOrEmpty()]
        [string]
        $RootPath
    )

    Get-ChildItem -Path $RootPath -Recurse -Include "*.csproj" | Select-Object @{ Name = "ParentFolder"; Expression = { $_.Directory.FullName.TrimEnd("\") } } | Select-Object -ExpandProperty ParentFolder
}

<#
.SYNOPSIS
    Runs the dotnet CLI install script from GitHub to install a project-local
    copy of the CLI.
#>
function Install-DotNetCli {
    [CmdletBinding()]
    Param(
        [string]
        $Version = "Latest"
    )

    if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) {
        $installedVersions = dotnet --list-sdks
        foreach ($sdkListLine in $installedVersions)
        {
            $splitParts = $sdkListLine.Split(" ");

            $versionPart = $splitParts[0];
            $globalInstallLocation = $splitParts[1].Replace("[", "").Replace("]", "")

            if ($versionPart -eq $Version)
            {
                Write-Message ".NET Core SDK version $Version is already installed in $globalInstallLocation"
                Add-Path "$globalInstallLocation"
                return;
            }
        }
    }

    Write-Message "Installing .NET SDK version $Version"

    $callerPath = Split-Path $MyInvocation.PSCommandPath
    $installDir = Join-Path -Path $callerPath -ChildPath ".dotnet/cli"
    if (!(Test-Path $installDir)) {
        New-Item -ItemType Directory -Path "$installDir" | Out-Null
    }

    # Download the dotnet CLI install script
    if ($IsWindows) {
        if (!(Test-Path ./.dotnet/dotnet-install.ps1)) {
            Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./.dotnet/dotnet-install.ps1"
        }

        & ./.dotnet/dotnet-install.ps1 -InstallDir "$installDir" -Version $Version
    } else {
        if (!(Test-Path ./.dotnet/dotnet-install.sh)) {
            Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./.dotnet/dotnet-install.sh"
        }

        & bash ./.dotnet/dotnet-install.sh --install-dir "$installDir" --version $Version
    }

    Add-Path "$installDir"
}

<#
.SYNOPSIS
    Appends a given value to the path but only if the value does not yet exist within the path.
.PARAMETER Path
    The path to append.
#>
function Add-Path {
    [CmdletBinding()]
    Param(
        [ValidateNotNullOrEmpty()]
        [string]
        $Path
    )
    
    $pathSeparator = ":";

    if ($IsWindows) {
        $pathSeparator = ";";
    }

    $pathValues = $env:PATH.Split($pathSeparator);
    if ($pathValues -Contains $Path) {
      return;
    }

    $env:PATH = "${Path}${pathSeparator}$env:PATH"
{'fraction_non_alphanumeric': 0.12614789753504108, 'fraction_numerical': 0.0038666022232962784, 'mean_word_length': 2.4798206278026904, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925370', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1864, 'n_words': 478}