Skip to content

Commit 887df21

Browse files
committed
chore: add husky pre-commit hook
1 parent 3521a26 commit 887df21

7 files changed

+50
-29
lines changed

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!csx

.husky/commit-msg

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
dotnet husky run --name "commit-message-linter" --args "$1"
5+
echo
6+
echo Great work! 🥂
7+
echo

.husky/csx/commit-lint.csx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Text.RegularExpressions;
2+
3+
private var pattern = @"^(?=.{1,90}$)(?:build|feat|ci|chore|docs|fix|perf|refactor|revert|style|test)(?:\(.+\))*(?::).{4,}(?:#\d+)*(?<![\.\s])$";
4+
private var msg = File.ReadAllLines(Args[0])[0];
5+
6+
if (Regex.IsMatch(msg, pattern))
7+
return 0;
8+
9+
Console.ForegroundColor = ConsoleColor.Red;
10+
Console.WriteLine("Invalid commit message");
11+
Console.ResetColor();
12+
Console.WriteLine("e.g: 'feat(scope): subject' or 'fix: subject'");
13+
Console.ForegroundColor = ConsoleColor.Gray;
14+
Console.WriteLine("more info: https://www.conventionalcommits.org/en/v1.0.0/");
15+
16+
return 1;

.husky/pre-commit

-4
This file was deleted.

.husky/task-runner.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"tasks": [
3+
{
4+
"name": "commit-message-linter",
5+
"command": "dotnet",
6+
"args": [
7+
"husky",
8+
"exec",
9+
".husky/csx/commit-lint.csx",
10+
"--args",
11+
"${args}"
12+
]
13+
}
14+
]
15+
}

honeybadger-dotnet.sln

-13
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Honeybadger.DotNetCoreWebAp
3333
EndProject
3434
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Honeybadger.DotNetCoreWebApp.Logger", "examples\Honeybadger.DotNetCoreWebApp.Logger\Honeybadger.DotNetCoreWebApp.Logger.csproj", "{938C7968-B408-4A5B-8587-9084A43C8C6A}"
3535
EndProject
36-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{E3A37898-6F77-449B-90BB-CD5542912906}"
37-
ProjectSection(SolutionItems) = preProject
38-
dotnet-tools.json = .config\dotnet-tools.json
39-
EndProjectSection
40-
EndProject
41-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{B836B05A-3C07-4D6E-BB1F-458E3A2EF03D}"
42-
ProjectSection(SolutionItems) = preProject
43-
pre-commit = .husky\pre-commit
44-
task-runner.json = .husky\task-runner.json
45-
EndProjectSection
46-
EndProject
4736
Global
4837
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4938
Debug|Any CPU = Debug|Any CPU
@@ -103,7 +92,5 @@ Global
10392
{AD4D0F8B-CE5E-4782-9CF4-BDDA060DBA02} = {89C7DC71-C55D-40D7-94F2-2F2F7C40FAC1}
10493
{8E0CD14F-BD8A-42B5-9A23-5E4C9D7ECBF7} = {89C7DC71-C55D-40D7-94F2-2F2F7C40FAC1}
10594
{938C7968-B408-4A5B-8587-9084A43C8C6A} = {89C7DC71-C55D-40D7-94F2-2F2F7C40FAC1}
106-
{B836B05A-3C07-4D6E-BB1F-458E3A2EF03D} = {9D7E2F87-D6F4-4BBB-8980-87D0A8344C74}
107-
{E3A37898-6F77-449B-90BB-CD5542912906} = {9D7E2F87-D6F4-4BBB-8980-87D0A8344C74}
10895
EndGlobalSection
10996
EndGlobal

src/Honeybadger/Honeybadger.csproj

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<Project Sdk="Microsoft.NET.Sdk">
2-
33
<PropertyGroup>
44
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
55
<LangVersion>10.0</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
9-
109
<ItemGroup>
1110
<PackageReference Include="IsExternalInit" Version="1.0.2">
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13-
<PrivateAssets>all</PrivateAssets>
11+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12+
<PrivateAssets>all</PrivateAssets>
1413
</PackageReference>
1514
</ItemGroup>
16-
1715
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) or '$(TargetFramework)' == 'net461'">
18-
<PackageReference Include="System.Text.Json" Version="6.0.3" />
16+
<PackageReference Include="System.Text.Json" Version="6.0.3"/>
1917
</ItemGroup>
20-
2118
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
22-
<PackageReference Include="System.Text.Json" Version="5.0.2" />
19+
<PackageReference Include="System.Text.Json" Version="5.0.2"/>
2320
</ItemGroup>
24-
2521
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
26-
<PackageReference Include="System.Net.Http" Version="4.3.4" />
22+
<PackageReference Include="System.Net.Http" Version="4.3.4"/>
2723
</ItemGroup>
28-
29-
</Project>
24+
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0 and '$(IsCrossTargetingBuild)' == 'true'">
25+
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High"/>
26+
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory="../.."/>
27+
</Target>
28+
</Project>

0 commit comments

Comments
 (0)