aboutsummaryrefslogtreecommitdiff
path: root/Program.cs
diff options
context:
space:
mode:
authorTim <contact@bytim.eu>2025-01-02 15:47:10 +0100
committerTim <contact@bytim.eu>2025-01-02 15:47:10 +0100
commit64203ec7c0a7ea9466d6a013f18fddc5af7db77b (patch)
tree953cacb7262cf9e502706a9584ce85dbbff18d61 /Program.cs
downloadGitAutoFetch-64203ec7c0a7ea9466d6a013f18fddc5af7db77b.tar.xz
GitAutoFetch-64203ec7c0a7ea9466d6a013f18fddc5af7db77b.zip
Initial commit
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();
+}