aboutsummaryrefslogtreecommitdiff
path: root/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Program.cs')
-rw-r--r--Program.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..79ed13b
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,33 @@
+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();
+}