From caa6de3a9b0aeea90b4048fdd95542243bd36910 Mon Sep 17 00:00:00 2001 From: half-ogre Date: Mon, 9 Dec 2013 09:59:51 -0800 Subject: [PATCH] use different function for GitHub commit status --- .../GetGitHubBuildStatusDescription.cs | 28 +++++++++++++++++++ qed/Functions/SetGitHubBuildStatus.cs | 2 +- qed/qed.csproj | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 qed/Functions/GetGitHubBuildStatusDescription.cs diff --git a/qed/Functions/GetGitHubBuildStatusDescription.cs b/qed/Functions/GetGitHubBuildStatusDescription.cs new file mode 100644 index 0000000..7292fb7 --- /dev/null +++ b/qed/Functions/GetGitHubBuildStatusDescription.cs @@ -0,0 +1,28 @@ +using System; + +namespace qed +{ + public static partial class Functions + { + internal static string GetGitHubBuildStatusDescription(Build build) + { + if (build == null) throw new ArgumentNullException("build"); + + var now = DateTimeOffset.UtcNow; + + if (!build.Started.HasValue) + return String.Format("Build #{0} queued.", build.Id); + + if (!build.Finished.HasValue) + return String.Format("Build #{0} started.", build.Id); + + if (!build.Succeeded.HasValue) + return String.Format("Build #{0} finished in {1} seconds.", build.Id, build.Started.Value.Until(build.Finished.Value)); + + if (build.Succeeded.Value) + return String.Format("Build #{0} succeeded in {1} seconds.", build.Id, build.Started.Value.Until(build.Finished.Value)); + + return String.Format("Build #{0} failed in {1} seconds.", build.Id, build.Started.Value.Until(build.Finished.Value)); + } + } +} diff --git a/qed/Functions/SetGitHubBuildStatus.cs b/qed/Functions/SetGitHubBuildStatus.cs index 260667a..c9c03ba 100644 --- a/qed/Functions/SetGitHubBuildStatus.cs +++ b/qed/Functions/SetGitHubBuildStatus.cs @@ -13,7 +13,7 @@ public static void SetGitHubBuildStatus( build, state, GetBuildConfiguration, - GetBuildDescription, + GetGitHubBuildStatusDescription, GetHost, (token, owner, name, sha, commitState, targetUrl, description) => { diff --git a/qed/qed.csproj b/qed/qed.csproj index 5b4025b..11557ee 100644 --- a/qed/qed.csproj +++ b/qed/qed.csproj @@ -113,6 +113,7 @@ +