diff --git a/.appveyor.yml b/.appveyor.yml index f7f80b0..a8b1255 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -11,8 +11,9 @@ install: - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null - ps: Invoke-WebRequest -Uri "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR' - - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.405 -InstallDir $env:DOTNET_INSTALL_DIR' - - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.102 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.417 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.404 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.100 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - ps: dotnet --info diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 409c718..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: 2 -updates: -- package-ecosystem: nuget - directory: "/src" - schedule: - interval: daily - time: "04:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: Cake.Core - versions: - - "(,3.0)" - - dependency-name: Cake.Testing - versions: - - "(,3.0)" - - dependency-name: Cake.Issues - versions: - - "> 1.0.0, < 2" - - dependency-name: Cake.Issues.Testing - versions: - - "> 1.0.0, < 2" diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..8588d1c --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>cake-contrib/renovate-presets:cake-issues" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..23de187 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "src\\Cake.Issues.GitRepository.sln" +} \ No newline at end of file diff --git a/README.md b/README.md index 6e4e2c4..61edab1 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ and for general information about the Cake build automation system see the [Cake - [Documentation](https://cakeissues.net) -## Chat Room +## Discussion -Come join in the conversation about this addin in our Gitter Chat Room. +For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category. -[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions) ## Contributing diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 54bf7ec..8576409 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,6 +28,10 @@ jobs: inputs: version: '7.x' displayName: 'Install .NET 7' + - task: UseDotNet@2 + inputs: + version: '8.x' + displayName: 'Install .NET 8' - powershell: ./build.ps1 displayName: 'Build' - publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet diff --git a/global.json b/global.json new file mode 100644 index 0000000..3660ff8 --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": true, + "version": "8.0.100", + "rollForward": "latestFeature" + } +} \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.GitRepository.nuspec b/nuspec/nuget/Cake.Issues.GitRepository.nuspec index 5629f98..88fbafd 100644 --- a/nuspec/nuget/Cake.Issues.GitRepository.nuspec +++ b/nuspec/nuget/Cake.Issues.GitRepository.nuspec @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © Pascal Berger cake cake-addin cake-issues cake-issueprovider code-analysis linting git - https://github.com/cake-contrib/Cake.Issues.GitRepository/releases/tag/3.0.0 + https://github.com/cake-contrib/Cake.Issues.GitRepository/releases/tag/4.0.0 @@ -34,5 +34,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin + + + diff --git a/recipe.cake b/recipe.cake index 9b022a9..4428f6f 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Cake.Recipe&version=3.0.0 +#load nuget:?package=Cake.Recipe&version=3.1.1 //************************************************************************************************* // Settings diff --git a/src/Cake.Issues.GitRepository.Tests/Cake.Issues.GitRepository.Tests.csproj b/src/Cake.Issues.GitRepository.Tests/Cake.Issues.GitRepository.Tests.csproj index b64a15f..05df807 100644 --- a/src/Cake.Issues.GitRepository.Tests/Cake.Issues.GitRepository.Tests.csproj +++ b/src/Cake.Issues.GitRepository.Tests/Cake.Issues.GitRepository.Tests.csproj @@ -23,28 +23,28 @@ - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - 4.1.0 + 4.2.1 1.1.118 runtime; build; native; contentfiles; analyzers all - + - 2.4.2 + 2.6.3 - 2.4.5 + 2.5.5 runtime; build; native; contentfiles; analyzers all diff --git a/src/Cake.Issues.GitRepository.Tests/GitRunnerFixture.cs b/src/Cake.Issues.GitRepository.Tests/GitRunnerFixture.cs index 6a042b7..2c83ac9 100644 --- a/src/Cake.Issues.GitRepository.Tests/GitRunnerFixture.cs +++ b/src/Cake.Issues.GitRepository.Tests/GitRunnerFixture.cs @@ -5,7 +5,7 @@ internal class GitRunnerFixture : ToolFixture { - private readonly List standardOutput = new List(); + private readonly List standardOutput = []; public GitRunnerFixture() : base("git") diff --git a/src/Cake.Issues.GitRepository/Cake.Issues.GitRepository.csproj b/src/Cake.Issues.GitRepository/Cake.Issues.GitRepository.csproj index a42b318..f8e2a31 100644 --- a/src/Cake.Issues.GitRepository/Cake.Issues.GitRepository.csproj +++ b/src/Cake.Issues.GitRepository/Cake.Issues.GitRepository.csproj @@ -2,7 +2,7 @@ Library - net6.0;net7.0 + net6.0;net7.0;net8.0 Git repository linting support for the Cake.Issues addin for Cake Build Automation System Pascal Berger Cake.Issues @@ -28,12 +28,12 @@ - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs b/src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs index 83c1e61..81125e4 100644 --- a/src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs +++ b/src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs @@ -95,16 +95,16 @@ protected override IEnumerable InternalReadIssues() /// Checks for binary files which are not tracked by LFS. /// /// List of issues for binary files which are not tracked by LFS. - private IEnumerable CheckForBinaryFilesNotTrackedByLfs() + private List CheckForBinaryFilesNotTrackedByLfs() { if (!this.allFiles.Value.Any()) { - return new List(); + return []; } if (!this.binaryFiles.Value.Any()) { - return new List(); + return []; } var lfsTrackedFiles = this.GetLfsTrackedFilesFromRepository(); @@ -133,11 +133,11 @@ private IEnumerable CheckForBinaryFilesNotTrackedByLfs() /// Checks for files path length. /// /// List of issues for repository files with paths exceeding the allowed maximum. - private IEnumerable CheckForFilesPathLength() + private List CheckForFilesPathLength() { if (!this.allFiles.Value.Any()) { - return new List(); + return []; } var result = new List(); @@ -165,7 +165,7 @@ private IEnumerable CheckForFilesPathLength() /// Returns a list of the files in the repository. /// /// List of files in the repository. - private IEnumerable GetAllFilesFromRepository() + private List GetAllFilesFromRepository() { this.Log.Verbose("Reading all files from repository '{0}'...", this.Settings.RepositoryRoot); @@ -176,23 +176,24 @@ private IEnumerable GetAllFilesFromRepository() settings.Arguments.Clear(); settings.Arguments.Add("ls-files -z"); - var allFiles = string.Join(string.Empty, this.runner.RunCommand(settings)).Split('\0').Where(x => !string.IsNullOrEmpty(x)); - - if (allFiles == null) - { - throw new Exception("Error reading files from repository"); - } - - this.Log.Verbose("Found {0} file(s)", allFiles.Count()); - - return allFiles.ToList(); + var allFiles = + string.Join( + string.Empty, + this.runner.RunCommand(settings)) + .Split('\0') + .Where(x => !string.IsNullOrEmpty(x)) + .ToList() + ?? throw new Exception("Error reading files from repository"); + this.Log.Verbose("Found {0} file(s)", allFiles.Count); + + return allFiles; } /// /// Returns a list of text files in the repository. /// /// List of text files in the repository. - private IEnumerable GetTextFilesFromRepository() + private List GetTextFilesFromRepository() { this.Log.Verbose("Reading all text files from repository '{0}'...", this.Settings.RepositoryRoot); @@ -206,12 +207,9 @@ private IEnumerable GetTextFilesFromRepository() settings.Arguments.Clear(); settings.Arguments.Add("grep -Il ."); - var textFiles = this.runner.RunCommand(settings); - if (textFiles == null) - { - throw new Exception("Error reading text files from repository"); - } - + var textFiles = + this.runner.RunCommand(settings) + ?? throw new Exception("Error reading text files from repository"); settings.Arguments.Clear(); settings.Arguments.Add("grep -IL ."); var emptyFiles = this.runner.RunCommand(settings); @@ -220,9 +218,11 @@ private IEnumerable GetTextFilesFromRepository() textFiles = textFiles.Concat(emptyFiles); } - this.Log.Verbose("Found {0} text file(s)", textFiles.Count()); + var result = textFiles.ToList(); + + this.Log.Verbose("Found {0} text file(s)", result.Count); - return textFiles.ToList(); + return result; } /// @@ -240,12 +240,9 @@ private IEnumerable GetLfsTrackedFilesFromRepository() settings.Arguments.Clear(); settings.Arguments.Add("lfs ls-files -n"); - var lfsTrackedFiles = this.runner.RunCommand(settings); - if (lfsTrackedFiles == null) - { - throw new Exception("Error reading LFS tracked files from repository"); - } - + var lfsTrackedFiles = + this.runner.RunCommand(settings) + ?? throw new Exception("Error reading LFS tracked files from repository"); this.Log.Verbose("Found {0} LFS tracked file(s)", lfsTrackedFiles.Count()); return lfsTrackedFiles; @@ -257,20 +254,20 @@ private IEnumerable GetLfsTrackedFilesFromRepository() /// List of all files in the repository. /// List of text files in the repository. /// List of binary files in the repository. - private IEnumerable DetermineBinaryFiles(IEnumerable allFiles, IEnumerable textFiles) + private List DetermineBinaryFiles(IEnumerable allFiles, IEnumerable textFiles) { this.Log.Verbose("Determine binary files..."); - var binaryFiles = allFiles.Except(textFiles); + var binaryFiles = allFiles.Except(textFiles).ToList(); - if (binaryFiles.Any()) + if (binaryFiles.Count > 0) { this.Log.Debug(string.Join(Environment.NewLine, binaryFiles)); } - this.Log.Verbose("Found {0} binary file(s)", binaryFiles.Count()); + this.Log.Verbose("Found {0} binary file(s)", binaryFiles.Count); - return binaryFiles.ToList(); + return binaryFiles; } /// @@ -279,20 +276,20 @@ private IEnumerable DetermineBinaryFiles(IEnumerable allFiles, I /// List of binary files in the repository. /// List of files tracked with LFS in the repository. /// List of binary files in the repository which are not tracked with LFS. - private IEnumerable DetermineBinaryFilesNotTrackedWithLfs(IEnumerable binaryFiles, IEnumerable lfsTrackedFiles) + private List DetermineBinaryFilesNotTrackedWithLfs(IEnumerable binaryFiles, IEnumerable lfsTrackedFiles) { this.Log.Verbose("Checking if binary files are tracked by LFS..."); - var binaryFilesNotTrackedWithLfs = binaryFiles.Except(lfsTrackedFiles); + var binaryFilesNotTrackedWithLfs = binaryFiles.Except(lfsTrackedFiles).ToList(); - if (binaryFilesNotTrackedWithLfs.Any()) + if (binaryFilesNotTrackedWithLfs.Count > 0) { this.Log.Debug(string.Join(Environment.NewLine, binaryFilesNotTrackedWithLfs)); } - this.Log.Verbose("Found {0} binary file(s) not tracked by LFS", binaryFilesNotTrackedWithLfs.Count()); + this.Log.Verbose("Found {0} binary file(s) not tracked by LFS", binaryFilesNotTrackedWithLfs.Count); - return binaryFilesNotTrackedWithLfs.ToList(); + return binaryFilesNotTrackedWithLfs; } } } \ No newline at end of file diff --git a/src/Cake.Issues.GitRepository/GitRunner.cs b/src/Cake.Issues.GitRepository/GitRunner.cs index fb3f077..a8dbe89 100644 --- a/src/Cake.Issues.GitRepository/GitRunner.cs +++ b/src/Cake.Issues.GitRepository/GitRunner.cs @@ -11,24 +11,17 @@ /// /// A wrapper around the Git CLI. /// - internal class GitRunner : Tool + /// The file system. + /// The Cake environment. + /// The process runner. + /// The tool locator. + internal class GitRunner( + IFileSystem fileSystem, + ICakeEnvironment environment, + IProcessRunner processRunner, + IToolLocator toolLocator) + : Tool(fileSystem, environment, processRunner, toolLocator) { - /// - /// Initializes a new instance of the class. - /// - /// The file system. - /// The Cake environment. - /// The process runner. - /// The tool locator. - public GitRunner( - IFileSystem fileSystem, - ICakeEnvironment environment, - IProcessRunner processRunner, - IToolLocator toolLocator) - : base(fileSystem, environment, processRunner, toolLocator) - { - } - /// /// Runs Git with specified settings. /// @@ -36,10 +29,7 @@ public GitRunner( /// Output of command. public IEnumerable RunCommand(GitRunnerSettings settings) { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } + ArgumentNullException.ThrowIfNull(settings); var args = new ProcessArgumentBuilder(); settings.Evaluate(args); diff --git a/src/Cake.Issues.GitRepository/GitRunnerSettings.cs b/src/Cake.Issues.GitRepository/GitRunnerSettings.cs index b774def..bc190f5 100644 --- a/src/Cake.Issues.GitRepository/GitRunnerSettings.cs +++ b/src/Cake.Issues.GitRepository/GitRunnerSettings.cs @@ -10,7 +10,7 @@ /// internal class GitRunnerSettings : ToolSettings { - private readonly List arguments = new List(); + private readonly List arguments = []; /// /// Gets arguments to pass to the target script. diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..a95ac95 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,5 @@ + + + latest + + \ No newline at end of file diff --git a/tests/script-runner/.config/dotnet-tools.json b/tests/script-runner/.config/dotnet-tools.json index a37608c..7b34695 100644 --- a/tests/script-runner/.config/dotnet-tools.json +++ b/tests/script-runner/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.0.0", + "version": "4.0.0", "commands": [ "dotnet-cake" ] diff --git a/tests/script-runner/global.json b/tests/script-runner/global.json new file mode 100644 index 0000000..c31f98b --- /dev/null +++ b/tests/script-runner/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": true, + "version": "6.0.100", + "rollForward": "latestFeature" + } +} \ No newline at end of file