aboutsummaryrefslogtreecommitdiff
path: root/Program.cs
blob: 79ed13b29aa9598ffdde4a1abfd267ab04d99f55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
}