using System.Diagnostics; using dotenv.net; DotEnv.Load(); var envVars = DotEnv.Read(); while (true) { var repoPaths = Directory.GetDirectories(String.IsNullOrEmpty(envVars["GIT_DIRECTORY"]) ? "./repos/" : envVars["GIT_DIRECTORY"]); foreach (var repoPath in repoPaths) { Console.WriteLine($"Fetching {repoPath}..."); var fetchProcess = Process.Start(new ProcessStartInfo { WorkingDirectory = repoPath, FileName = "git", Arguments = "fetch origin master:master" }); if (!fetchProcess!.HasExited) fetchProcess.WaitForExit(); Console.WriteLine($"Fetched with exit code {fetchProcess.ExitCode}."); } if (envVars.ContainsKey("CGIT_CACHE_DIRECTORY")) { foreach (var cacheFile in Directory.GetFiles(envVars["CGIT_CACHE_DIRECTORY"])) File.Delete(cacheFile); } Task.Delay(3600000).Wait(); }