mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
fix dotnet hooks with prefixes
This commit is contained in:
parent
df7bcf78c3
commit
d79c886d99
6 changed files with 38 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
|
|
@ -58,9 +59,15 @@ def install_environment(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Determine tool from the packaged file <tool_name>.<version>.nupkg
|
# Determine tool from the packaged file <tool_name>.<version>.nupkg
|
||||||
|
# https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-basics
|
||||||
|
tool_name_re = re.compile(r'(.*)\.\d+\.\d+\.\d+(-.*)?\.nupkg')
|
||||||
|
|
||||||
build_outputs = os.listdir(os.path.join(prefix.prefix_dir, build_dir))
|
build_outputs = os.listdir(os.path.join(prefix.prefix_dir, build_dir))
|
||||||
for output in build_outputs:
|
for output in build_outputs:
|
||||||
tool_name = output.split('.')[0]
|
|
||||||
|
tool_name_match = tool_name_re.match(output)
|
||||||
|
assert tool_name_match
|
||||||
|
tool_name = tool_name_match.group(1)
|
||||||
|
|
||||||
# Install to bin dir
|
# Install to bin dir
|
||||||
helpers.run_setup_cmd(
|
helpers.run_setup_cmd(
|
||||||
|
|
|
||||||
3
testing/resources/dotnet_hooks_csproj_prefix_repo/.gitignore
vendored
Normal file
3
testing/resources/dotnet_hooks_csproj_prefix_repo/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
nupkg/
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
- id: dotnet-example-hook
|
||||||
|
name: dotnet example hook
|
||||||
|
entry: testeroni.tool
|
||||||
|
language: dotnet
|
||||||
|
files: ''
|
||||||
12
testing/resources/dotnet_hooks_csproj_prefix_repo/Program.cs
Normal file
12
testing/resources/dotnet_hooks_csproj_prefix_repo/Program.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace dotnet_hooks_repo
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello from dotnet!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<PackAsTool>true</PackAsTool>
|
||||||
|
<ToolCommandName>testeroni.tool</ToolCommandName>
|
||||||
|
<PackageOutputPath>./nupkg</PackageOutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -1052,6 +1052,7 @@ def test_local_perl_additional_dependencies(store):
|
||||||
'dotnet_hooks_csproj_repo',
|
'dotnet_hooks_csproj_repo',
|
||||||
'dotnet_hooks_sln_repo',
|
'dotnet_hooks_sln_repo',
|
||||||
'dotnet_hooks_combo_repo',
|
'dotnet_hooks_combo_repo',
|
||||||
|
'dotnet_hooks_csproj_prefix_repo',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_dotnet_hook(tempdir_factory, store, repo):
|
def test_dotnet_hook(tempdir_factory, store, repo):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue