<commit_before>#l "buildserver.cake"

//-------------------------------------------------------------

public class GeneralContext : BuildContextWithItemsBase
{
    public GeneralContext(IBuildContext parentBuildContext)
        : base(parentBuildContext)
    {
    }

    public string Target { get; set; }
    public string RootDirectory { get; set; }
    public string OutputRootDirectory { get; set; }

    public bool IsCiBuild { get; set; }
    public bool IsAlphaBuild { get; set; }
    public bool IsBetaBuild { get; set; }
    public bool IsOfficialBuild { get; set; }
    public bool IsLocalBuild { get; set; }
    public bool UseVisualStudioPrerelease { get; set; }
    public bool VerifyDependencies { get; set; }

    public VersionContext Version { get; set; }
    public CopyrightContext Copyright { get; set; }
    public NuGetContext NuGet { get; set; }
    public SolutionContext Solution { get; set; }
    public SourceLinkContext SourceLink { get; set; }
    public CodeSignContext CodeSign { get; set; }
    public RepositoryContext Repository { get; set; }
    public SonarQubeContext SonarQube { get; set; }

    public List<string> Includes { get; set; }
    public List<string> Excludes { get; set; }

    protected override void ValidateContext()
    {
    }
    
    protected override void LogStateInfoForContext()
    {
        CakeContext.Information($"Running target '{Target}'");
        CakeContext.Information($"Using output directory '{OutputRootDirectory}'");
    }
}

//-------------------------------------------------------------

public class VersionContext : BuildContextBase
{
    private GitVersion _gitVersionContext;

    public VersionContext(IBuildContext parentBuildContext)
        : base(parentBuildContext)
    {
    }

    public GitVersion GetGitVersionContext(GeneralContext generalContext)
    {
        if (_gitVersionContext is null)
        {
            var gitVersionSettings = new GitVersionSettings
            {
                UpdateAssemblyInfo = false
            };

            var gitDirectory = ".git";
            if (!CakeContext.DirectoryExists(gitDirectory))
            {
                CakeContext.Information("No local .git directory found, treating as dynamic repository");

                //// TEMP CODE - START
                //
                //CakeContext.Warning("Since dynamic repositories do not yet work correctly, we clear out the cloned temp directory (which is slow, but should be fixed in 5.0 beta)");
                //
                //// Make a *BIG* assumption that the solution name == repository name
                //var repositoryName = generalContext.Solution.Name;
                //var tempDirectory = $"{System.IO.Path.GetTempPath()}\\{repositoryName}";
                //
                //if (CakeContext.DirectoryExists(tempDirectory))
                //{
                //    CakeContext.DeleteDirectory(tempDirectory, new DeleteDirectorySettings
                //    {
                //        Force = true,
                //        Recursive = true
                //    });
                //}
                //
                //// TEMP CODE - END

                // Dynamic repository
                gitVersionSettings.UserName = generalContext.Repository.Username;
                gitVersionSettings.Password = <PASSWORD>Context.Repository.Password;
                gitVersionSettings.Url = generalContext.Repository.Url;
                gitVersionSettings.Branch = generalContext.Repository.BranchName;
                gitVersionSettings.Commit = generalContext.Repository.CommitId;
            }

            _gitVersionContext = CakeContext.GitVersion(gitVersionSettings);
        }

        return _gitVersionContext;
    }

    public string MajorMinorPatch { get; set; }
    public string FullSemVer { get; set; }
    public string NuGet { get; set; }
    public string CommitsSinceVersionSource { get; set; }

    protected override void ValidateContext()<commit_msg>GitHubSync update<commit_after>#l "buildserver.cake"

//-------------------------------------------------------------

public class GeneralContext : BuildContextWithItemsBase
{
    public GeneralContext(IBuildContext parentBuildContext)
        : base(parentBuildContext)
    {
    }

    public string Target { get; set; }
    public string RootDirectory { get; set; }
    public string OutputRootDirectory { get; set; }

    public bool IsCiBuild { get; set; }
    public bool IsAlphaBuild { get; set; }
    public bool IsBetaBuild { get; set; }
    public bool IsOfficialBuild { get; set; }
    public bool IsLocalBuild { get; set; }
    public bool UseVisualStudioPrerelease { get; set; }
    public bool VerifyDependencies { get; set; }

    public VersionContext Version { get; set; }
    public CopyrightContext Copyright { get; set; }
    public NuGetContext NuGet { get; set; }
    public SolutionContext Solution { get; set; }
    public SourceLinkContext SourceLink { get; set; }
    public CodeSignContext CodeSign { get; set; }
    public RepositoryContext Repository { get; set; }
    public SonarQubeContext SonarQube { get; set; }

    public List<string> Includes { get; set; }
    public List<string> Excludes { get; set; }

    protected override void ValidateContext()
    {
    }
    
    protected override void LogStateInfoForContext()
    {
        CakeContext.Information($"Running target '{Target}'");
        CakeContext.Information($"Using output directory '{OutputRootDirectory}'");
    }
}

//-------------------------------------------------------------

public class VersionContext : BuildContextBase
{
    private GitVersion _gitVersionContext;

    public VersionContext(IBuildContext parentBuildContext)
        : base(parentBuildContext)
    {
    }

    public GitVersion GetGitVersionContext(GeneralContext generalContext)
    {
        if (_gitVersionContext is null)
        {
            var gitVersionSettings = new GitVersionSettings
            {
                UpdateAssemblyInfo = false,
                Verbosity = GitVersionVerbosity.Debug
            };

            var gitDirectory = ".git";
            if (!CakeContext.DirectoryExists(gitDirectory))
            {
                CakeContext.Information("No local .git directory found, treating as dynamic repository");

                // TEMP CODE - START
                
                CakeContext.Warning("Since dynamic repositories do not yet work correctly, we clear out the cloned temp directory (which is slow, but should be fixed in 5.0 beta)");
                
                // Make a *BIG* assumption that the solution name == repository name
                var repositoryName = generalContext.Solution.Name;
                var tempDirectory = $"{System.IO.Path.GetTempPath()}\\{repositoryName}";
                
                if (CakeContext.DirectoryExists(tempDirectory))
                {
                    CakeContext.DeleteDirectory(tempDirectory, new DeleteDirectorySettings
                    {
                        Force = true,
                        Recursive = true
                    });
                }
                
                // TEMP CODE - END

                // Dynamic repository
                gitVersionSettings.UserName = generalContext.Repository.Username;
                gitVersionSettings.Password = generalContext.Repository.Password;
                gitVersionSettings.Url = generalContext.Repository.Url;
                gitVersionSettings.Branch = generalContext.Repository.BranchName;
                gitVersionSettings.Commit = generalContext.Repository.CommitId;
            }

            _gitVersionContext = CakeContext.GitVersion(gitVersionSettings);
        }

        return _gitVersionContext;
    }

    public string MajorMinorPatch { get; set; }
    public string FullSemVer { get; set; }
    public string NuGet { get; set; }
    public string CommitsSinceVersionSource { get; set; }

    protected override void ValidateContext()
{'fraction_non_alphanumeric': 0.10788226490396607, 'fraction_numerical': 0.0004988775255674732, 'mean_word_length': 1.97, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4808407', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1868, 'n_words': 522}