Skip to content

Commit

Permalink
Added TimedOut check
Browse files Browse the repository at this point in the history
  • Loading branch information
derekantrican committed Oct 18, 2024
1 parent e824b40 commit 2c74c88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ClockworkFramework.Core/ClockworkFramework.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Version>6.5.0</Version>
<Version>6.6.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 10 additions & 1 deletion ClockworkFramework.Core/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class ProcessResult
public string StdOut { get; set; }
public string StdErr { get; set; }
public int ExitCode { get; set; }
public bool TimedOut { get; set; }
}

public static ProcessResult RunProcess(string process, string location = null, TimeSpan? timeout = null)
Expand Down Expand Up @@ -142,7 +143,15 @@ public static ProcessResult RunProcess(string process, string location = null, T
p.BeginOutputReadLine();
p.BeginErrorReadLine();

p.WaitForExit(timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : -1);
bool success = p.WaitForExit(timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : -1);

if (!success)
{
return new ProcessResult
{
TimedOut = true,
};
}

return new ProcessResult
{
Expand Down
7 changes: 6 additions & 1 deletion ClockworkFramework/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ await Task.Run(() =>
Console.WriteLine($"Updating library {library.Name}");

var result = Utilities.RunProcess("git pull", library.Path, TimeSpan.FromMinutes(15));
if (result.ExitCode != 0)
if (result.TimedOut || result.ExitCode != 0)
{
Utilities.WriteToConsoleWithColor($"Failed to update library {library.Name} ({result.ExitCode}). Log output below.\n\n{result.StdOut}\n\n{result.StdErr}", ConsoleColor.Red);

Expand All @@ -127,6 +127,11 @@ await Task.Run(() =>
message += " If this is not a git repository, turn off updateRepository in config.json";
}

if (result.TimedOut)
{
message += " Process timed out. Perhaps it was waiting for input? Try storing your git credentials";
}

CallHook(h => h.Warning(message));

continue;
Expand Down

0 comments on commit 2c74c88

Please sign in to comment.