Skip to content

Commit

Permalink
Exclude changes in git foldern
Browse files Browse the repository at this point in the history
  • Loading branch information
fpommerening committed Aug 11, 2023
1 parent 4559dc2 commit 5dc5c21
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Business/FileWatchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class FileWatchCommand : PipelinesCommand<PipelinesCommandSettings>

}

bool hasChanges = false;

protected override async Task<int> ExecuteEngineAsync(CommandContext commandContext, PipelinesCommandSettings commandSettings,
IEngineManager engineManager)
Expand All @@ -39,18 +40,15 @@ public class FileWatchCommand : PipelinesCommand<PipelinesCommandSettings>
{
return (int)completeResult;
}

bool hasChanges = false;

do
{
var slidesFolder = new DirectoryInfo(commandSettings.InputPaths.First()).Parent;

using FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(slidesFolder.FullName);
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.Changed += (sender, args) => hasChanges = true;
fileSystemWatcher.Created += (sender, args) => hasChanges = true;
fileSystemWatcher.Deleted += (sender, args) => hasChanges = true;
fileSystemWatcher.Changed += FileSystemWatcherOnChanged;
fileSystemWatcher.Created += FileSystemWatcherOnChanged;
fileSystemWatcher.Deleted += FileSystemWatcherOnChanged;
fileSystemWatcher.EnableRaisingEvents = true;

while (!cancellationTokenSource.IsCancellationRequested)
Expand All @@ -71,5 +69,13 @@ public class FileWatchCommand : PipelinesCommand<PipelinesCommandSettings>

return 0;
}

private void FileSystemWatcherOnChanged(object sender, FileSystemEventArgs e)
{
if (!hasChanges && !e.FullPath.Contains("\\.git\\") && !e.FullPath.Contains("/.git/"))
{
hasChanges = true;
}
}
}
}

0 comments on commit 5dc5c21

Please sign in to comment.