Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Dec 23, 2023
2 parents 3440996 + 135e116 commit cfa4d72
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 104 deletions.
5 changes: 3 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 0 additions & 21 deletions .github/dependabot.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>cake-contrib/renovate-presets:cake-issues"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "src\\Cake.Issues.GitRepository.sln"
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"allowPrerelease": true,
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
5 changes: 4 additions & 1 deletion nuspec/nuget/Cake.Issues.GitRepository.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.GitRepository.git"/>
<copyright>Copyright © Pascal Berger</copyright>
<tags>cake cake-addin cake-issues cake-issueprovider code-analysis linting git</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.GitRepository/releases/tag/3.0.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.GitRepository/releases/tag/4.0.0</releaseNotes>
</metadata>
<files>
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
Expand All @@ -34,5 +34,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<file src="net7.0/Cake.Issues.GitRepository.dll" target="lib\net7.0" />
<file src="net7.0/Cake.Issues.GitRepository.pdb" target="lib\net7.0" />
<file src="net7.0/Cake.Issues.GitRepository.xml" target="lib\net7.0" />
<file src="net8.0/Cake.Issues.GitRepository.dll" target="lib\net8.0" />
<file src="net8.0/Cake.Issues.GitRepository.pdb" target="lib\net8.0" />
<file src="net8.0/Cake.Issues.GitRepository.xml" target="lib\net8.0" />
</files>
</package>
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:?package=Cake.Recipe&version=3.0.0
#load nuget:?package=Cake.Recipe&version=3.1.1

//*************************************************************************************************
// Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cake.Issues">
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Cake.Issues.Testing">
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Cake.Testing">
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Shouldly">
<Version>4.1.0</Version>
<Version>4.2.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit">
<Version>2.4.2</Version>
<Version>2.6.3</Version>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio">
<Version>2.4.5</Version>
<Version>2.5.5</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Issues.GitRepository.Tests/GitRunnerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

internal class GitRunnerFixture : ToolFixture<GitRunnerSettings>
{
private readonly List<string> standardOutput = new List<string>();
private readonly List<string> standardOutput = [];

public GitRunnerFixture()
: base("git")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Description>Git repository linting support for the Cake.Issues addin for Cake Build Automation System</Description>
<Authors>Pascal Berger</Authors>
<Product>Cake.Issues</Product>
Expand All @@ -28,12 +28,12 @@

<ItemGroup>
<PackageReference Include="Cake.Core">
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Cake.Issues">
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
79 changes: 38 additions & 41 deletions src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ protected override IEnumerable<IIssue> InternalReadIssues()
/// Checks for binary files which are not tracked by LFS.
/// </summary>
/// <returns>List of issues for binary files which are not tracked by LFS.</returns>
private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs()
private List<IIssue> CheckForBinaryFilesNotTrackedByLfs()
{
if (!this.allFiles.Value.Any())
{
return new List<IIssue>();
return [];
}

if (!this.binaryFiles.Value.Any())
{
return new List<IIssue>();
return [];
}

var lfsTrackedFiles = this.GetLfsTrackedFilesFromRepository();
Expand Down Expand Up @@ -133,11 +133,11 @@ private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs()
/// Checks for files path length.
/// </summary>
/// <returns>List of issues for repository files with paths exceeding the allowed maximum.</returns>
private IEnumerable<IIssue> CheckForFilesPathLength()
private List<IIssue> CheckForFilesPathLength()
{
if (!this.allFiles.Value.Any())
{
return new List<IIssue>();
return [];
}

var result = new List<IIssue>();
Expand Down Expand Up @@ -165,7 +165,7 @@ private IEnumerable<IIssue> CheckForFilesPathLength()
/// Returns a list of the files in the repository.
/// </summary>
/// <returns>List of files in the repository.</returns>
private IEnumerable<string> GetAllFilesFromRepository()
private List<string> GetAllFilesFromRepository()
{
this.Log.Verbose("Reading all files from repository '{0}'...", this.Settings.RepositoryRoot);

Expand All @@ -176,23 +176,24 @@ private IEnumerable<string> 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;
}

/// <summary>
/// Returns a list of text files in the repository.
/// </summary>
/// <returns>List of text files in the repository.</returns>
private IEnumerable<string> GetTextFilesFromRepository()
private List<string> GetTextFilesFromRepository()
{
this.Log.Verbose("Reading all text files from repository '{0}'...", this.Settings.RepositoryRoot);

Expand All @@ -206,12 +207,9 @@ private IEnumerable<string> 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);
Expand All @@ -220,9 +218,11 @@ private IEnumerable<string> 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;
}

/// <summary>
Expand All @@ -240,12 +240,9 @@ private IEnumerable<string> 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;
Expand All @@ -257,20 +254,20 @@ private IEnumerable<string> GetLfsTrackedFilesFromRepository()
/// <param name="allFiles">List of all files in the repository.</param>
/// <param name="textFiles">List of text files in the repository.</param>
/// <returns>List of binary files in the repository.</returns>
private IEnumerable<string> DetermineBinaryFiles(IEnumerable<string> allFiles, IEnumerable<string> textFiles)
private List<string> DetermineBinaryFiles(IEnumerable<string> allFiles, IEnumerable<string> 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;
}

/// <summary>
Expand All @@ -279,20 +276,20 @@ private IEnumerable<string> DetermineBinaryFiles(IEnumerable<string> allFiles, I
/// <param name="binaryFiles">List of binary files in the repository.</param>
/// <param name="lfsTrackedFiles">List of files tracked with LFS in the repository.</param>
/// <returns>List of binary files in the repository which are not tracked with LFS.</returns>
private IEnumerable<string> DetermineBinaryFilesNotTrackedWithLfs(IEnumerable<string> binaryFiles, IEnumerable<string> lfsTrackedFiles)
private List<string> DetermineBinaryFilesNotTrackedWithLfs(IEnumerable<string> binaryFiles, IEnumerable<string> 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;
}
}
}
32 changes: 11 additions & 21 deletions src/Cake.Issues.GitRepository/GitRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,25 @@
/// <summary>
/// A wrapper around the Git CLI.
/// </summary>
internal class GitRunner : Tool<GitRunnerSettings>
/// <param name="fileSystem">The file system.</param>
/// <param name="environment">The Cake environment.</param>
/// <param name="processRunner">The process runner.</param>
/// <param name="toolLocator">The tool locator.</param>
internal class GitRunner(
IFileSystem fileSystem,
ICakeEnvironment environment,
IProcessRunner processRunner,
IToolLocator toolLocator)
: Tool<GitRunnerSettings>(fileSystem, environment, processRunner, toolLocator)
{
/// <summary>
/// Initializes a new instance of the <see cref="GitRunner" /> class.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="environment">The Cake environment.</param>
/// <param name="processRunner">The process runner.</param>
/// <param name="toolLocator">The tool locator.</param>
public GitRunner(
IFileSystem fileSystem,
ICakeEnvironment environment,
IProcessRunner processRunner,
IToolLocator toolLocator)
: base(fileSystem, environment, processRunner, toolLocator)
{
}

/// <summary>
/// Runs Git with specified settings.
/// </summary>
/// <param name="settings">Settings for running Git.</param>
/// <returns>Output of command.</returns>
public IEnumerable<string> RunCommand(GitRunnerSettings settings)
{
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}
ArgumentNullException.ThrowIfNull(settings);

var args = new ProcessArgumentBuilder();
settings.Evaluate(args);
Expand Down
Loading

0 comments on commit cfa4d72

Please sign in to comment.