diff --git a/Src/AiCommitMessage/Services/InstallHookService.cs b/Src/AiCommitMessage/Services/InstallHookService.cs index 081c007..6cbd213 100644 --- a/Src/AiCommitMessage/Services/InstallHookService.cs +++ b/Src/AiCommitMessage/Services/InstallHookService.cs @@ -26,7 +26,6 @@ public static void InstallHook(InstallHookOptions options) if (string.IsNullOrWhiteSpace(options.Path)) { directory = Path.Combine(GetGitRepositoryRootLevel(), GetHooksDirectory()); - EnsureDirectoryExists(directory); } var hookPath = Path.Combine(directory, "prepare-commit-msg"); @@ -190,7 +189,7 @@ private static void ExtractEmbeddedResource( string file ) { - EnsureDirectoryExists(outputDir); + EnsureDirectoryExists(Path.Combine(outputDir, file)); using var stream = typeof(InstallHookService).Assembly.GetManifestResourceStream( resourceLocation + "." + file ); @@ -219,7 +218,7 @@ string file private static void EnsureDirectoryExists(string path) { var directoryName = Path.GetDirectoryName(path); - if (directoryName is { Length: > 0 }) + if (directoryName is { Length: > 0 } && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } diff --git a/Tests/AiCommitMessage.Tests/AiCommitMessage.Tests.csproj b/Tests/AiCommitMessage.Tests/AiCommitMessage.Tests.csproj index 6a6c4ac..823f972 100644 --- a/Tests/AiCommitMessage.Tests/AiCommitMessage.Tests.csproj +++ b/Tests/AiCommitMessage.Tests/AiCommitMessage.Tests.csproj @@ -15,7 +15,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - +