diff --git a/.nuke/Build.Container.cs b/.nuke/Build.Container.cs index 7a9db5b42062eb41c7f56493b509a009398c0a38..35b795ebe3abf4a3ae97ec1975a0261c5cab5350 100644 --- a/.nuke/Build.Container.cs +++ b/.nuke/Build.Container.cs @@ -61,7 +61,7 @@ sealed partial class Build : NukeBuild }; /// - /// Return the proper image tag for a given OS. For the second tupple value, if the image mush be marked as "latest" + /// Return the proper image tag for a given OS. For the second tuple value, if the image mush be marked as "latest" /// (string, bool) ContainerRuntimeIdentifier => runtimeIdentifier switch { diff --git a/README.md b/README.md index 1f6ab1f73e60778477cd565ade1f55ebe3d97c43..d130e27081aa16a3139208f7ca7bb6368bd651a0 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Official site: https://sucos.brunomassa.com [![Latest release](https://gitlab.com/sucos/sucos/-/badges/release.svg)](https://gitlab.com/sucos/sucos) ![Pipepline](https://gitlab.com/sucos/sucos/badges/main/pipeline.svg?ignore_skipped=true) [![Latest release](https://gitlab.com/sucos/sucos/badges/main/coverage.svg)](https://gitlab.com/sucos/sucos) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1fe0cc1ca72649ee9b85e13e7294a03a)](https://app.codacy.com/gl/sucos/sucos/dashboard?utm_source=gl&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) ## Install diff --git a/source/Commands/ServeCommand.cs b/source/Commands/ServeCommand.cs index f62f451b75885aea80c63372cbcc4a722df53dd4..253c8ce143fb992970cae98da9031285d87671d7 100644 --- a/source/Commands/ServeCommand.cs +++ b/source/Commands/ServeCommand.cs @@ -54,6 +54,8 @@ public sealed class ServeCommand : BaseGeneratorCommand, IDisposable private Task? _loop; + private (WatcherChangeTypes changeType, string fullPath, DateTime dateTime) lastFileChanged; + /// /// Constructor for the ServeCommand class. /// @@ -247,11 +249,20 @@ public sealed class ServeCommand : BaseGeneratorCommand, IDisposable /// The FileSystemEventArgs containing information about the file change. private void OnSourceFileChanged(object sender, FileSystemEventArgs e) { - if (e.FullPath.Contains("\\.git\\", StringComparison.InvariantCulture)) + if (e.FullPath.Contains(@".git", StringComparison.InvariantCulture)) + { + return; + } + + if (lastFileChanged.fullPath == e.FullPath + && e.ChangeType == lastFileChanged.changeType + && (DateTime.Now - lastFileChanged.dateTime).TotalMilliseconds < 150) { return; } + lastFileChanged = (e.ChangeType, e.FullPath, DateTime.Now); + // File changes are firing multiple events in a short time. // Debounce the event handler to prevent multiple events from firing in a short time _debounceTimer?.Dispose();