Make PowerShell strictly optional for Git hooks
...and remove auto-`dotnet tool restore`. If you don't have PowerShell on `$PATH`/`%PATH%`, Git hooks will simply not be ran. I still intend to migrate the rest of `/Dist` to PowerShell. Undecided on unmanaged cores and wbox.
This commit is contained in:
parent
1d46919f6a
commit
c5f6dcd4e8
|
@ -1,5 +1,8 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
pwsh="$(command -v pwsh)"
|
||||
if [ -z "$pwsh" ]; then pwsh="$(command -v dotnet) pwsh"; fi
|
||||
if ! ("$pwsh" -v >/dev/null 2>/dev/null); then exit 0; fi
|
||||
kind="$(basename "$0")"
|
||||
dotnet pwsh "./Dist/git_hooks/$kind.ps1" "$@"
|
||||
if [ -e "./Dist/git_hooks/$kind.local.ps1" ]; then dotnet pwsh "./Dist/git_hooks/$kind.local.ps1" "$@"; fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env -S dotnet pwsh
|
||||
#!/usr/bin/env -S pwsh
|
||||
$msg = Get-Content $args[0] -TotalCount 1 # this commit hook is always passed the commit message scratch file's path, so read the first line of that
|
||||
if ($msg -Match "^fix(?:ed|es)? #\d+$") {
|
||||
echo "An issue reference alone is not a suitable commit message. Vetoed."
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$targetDir = "$PSScriptRoot/../.git/hooks"
|
||||
if (Test-Path $targetDir -PathType Container) { # is Git repo
|
||||
$PSCommandFilename = Split-Path $PSCommandPath -Leaf
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
, git-cola ? pkgs.git-cola
|
||||
, git ? pkgs.gitMinimal
|
||||
, nano ? pkgs.nano
|
||||
, powershell ? pkgs.powershell
|
||||
, debugDotnetHostCrashes ? false # forwarded to Dist/launch-scripts.nix
|
||||
, debugPInvokes ? false # forwarded to Dist/launch-scripts.nix
|
||||
, forNixOS ? true
|
||||
|
@ -15,7 +16,7 @@
|
|||
# thinking of exposing pre-configured IDEs from `default.nix` so they're available here
|
||||
avail = import ./. { inherit debugDotnetHostCrashes debugPInvokes forNixOS system; };
|
||||
f = drv: mkShell {
|
||||
packages = [ git ]
|
||||
packages = [ git powershell ]
|
||||
++ lib.optionals useNanoAndCola [ git-cola nano ]
|
||||
++ lib.optionals useKate [] #TODO
|
||||
++ lib.optionals useVSCode [] #TODO https://devblogs.microsoft.com/dotnet/csharp-dev-kit-now-generally-available/ https://learn.microsoft.com/en-us/training/modules/implement-visual-studio-code-debugging-tools/
|
||||
|
|
|
@ -16,12 +16,8 @@
|
|||
<ItemGroup>
|
||||
<Analyzer Include="$(MSBuildProjectDirectory)/../../References/BizHawk.SrcGen.VersionInfo.dll" />
|
||||
</ItemGroup>
|
||||
<Target Name="RestoreTools" BeforeTargets="PreBuildEvent">
|
||||
<!-- why is this not the default behaviour -->
|
||||
<Exec Command="dotnet tool restore"
|
||||
StandardOutputImportance="low" /> <!-- this parameter has almost no documentation, hooray -->
|
||||
</Target>
|
||||
<Target Name="InstallGitHooks" AfterTargets="PreBuildEvent">
|
||||
<Exec Command="dotnet pwsh $(MSBuildProjectDirectory)/../../Dist/install_git_hooks.ps1" />
|
||||
<Exec Command="$(MSBuildProjectDirectory)/../../Dist/install_git_hooks.ps1"
|
||||
IgnoreExitCode="true" /> <!-- i.e. may fail... though it was actually using the exit code properly, but oh well -->
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue