aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-ci-github-gq.cxx53
-rw-r--r--mod/mod-ci-github-gq.hxx8
2 files changed, 34 insertions, 27 deletions
diff --git a/mod/mod-ci-github-gq.cxx b/mod/mod-ci-github-gq.cxx
index 9d74b5a..e5ea0c5 100644
--- a/mod/mod-ci-github-gq.cxx
+++ b/mod/mod-ci-github-gq.cxx
@@ -349,13 +349,17 @@ namespace brep
// other states.
//
static string
- gq_mutation_create_check_runs (const string& ri, // Repository ID
- const string& hs, // Head SHA
- const string& du, // Details URL.
+ gq_mutation_create_check_runs (const string& ri, // Repository ID
+ const string& hs, // Head SHA
+ const optional<string>& du, // Details URL.
const vector<check_run>& crs,
- const string& st, // Check run status.
+ const string& st, // Check run status.
optional<gq_built_result> br = nullopt)
{
+ // Ensure details URL is non-empty if present.
+ //
+ assert (!du || !du->empty ());
+
ostringstream os;
os << "mutation {" << '\n';
@@ -371,10 +375,10 @@ namespace brep
<< " repositoryId: " << gq_str (ri) << '\n'
<< " headSha: " << gq_str (hs) << '\n'
<< " status: " << gq_enum (st);
- if (!du.empty ())
+ if (du)
{
os << '\n';
- os << " detailsUrl: " << gq_str (du);
+ os << " detailsUrl: " << gq_str (*du);
}
if (br)
{
@@ -409,13 +413,17 @@ namespace brep
// conclusion.
//
static string
- gq_mutation_update_check_run (const string& ri, // Repository ID.
- const string& ni, // Node ID.
- const string& du, // Details URL.
- const string& st, // Check run status.
- optional<timestamp> sa, // Started at.
+ gq_mutation_update_check_run (const string& ri, // Repository ID.
+ const string& ni, // Node ID.
+ const optional<string>& du, // Details URL.
+ const string& st, // Check run status.
+ optional<timestamp> sa, // Started at.
optional<gq_built_result> br)
{
+ // Ensure details URL is non-empty if present.
+ //
+ assert (!du || !du->empty ());
+
ostringstream os;
os << "mutation {" << '\n'
@@ -428,10 +436,10 @@ namespace brep
os << '\n';
os << " startedAt: " << gq_str (gh_to_iso8601 (*sa));
}
- if (!du.empty ())
+ if (du)
{
os << '\n';
- os << " detailsUrl: " << gq_str (du);
+ os << " detailsUrl: " << gq_str (*du);
}
if (br)
{
@@ -472,8 +480,11 @@ namespace brep
// Empty details URL because it's not available until building.
//
string rq (
- gq_serialize_request (
- gq_mutation_create_check_runs (rid, hs, "", crs, gh_to_status (st))));
+ gq_serialize_request (gq_mutation_create_check_runs (rid,
+ hs,
+ nullopt,
+ crs,
+ gh_to_status (st))));
return gq_mutate_check_runs (error, crs, iat, move (rq), st);
}
@@ -484,7 +495,7 @@ namespace brep
const string& iat,
const string& rid,
const string& hs,
- const string& du,
+ const optional<string>& du,
build_state st,
optional<gq_built_result> br)
{
@@ -492,10 +503,6 @@ namespace brep
//
assert (st != build_state::built || br);
- // Must have a details URL because `st` should never be queued.
- //
- assert (!du.empty ());
-
vector<check_run> crs {move (cr)};
string rq (
@@ -520,7 +527,7 @@ namespace brep
const string& iat,
const string& rid,
const string& nid,
- const string& du,
+ const optional<string>& du,
build_state st,
optional<gq_built_result> br)
{
@@ -528,10 +535,6 @@ namespace brep
//
assert (st != build_state::built || br);
- // Must have a details URL for building and built.
- //
- assert (!du.empty ());
-
// Set `startedAt` to current time if updating to building.
//
optional<timestamp> sa;
diff --git a/mod/mod-ci-github-gq.hxx b/mod/mod-ci-github-gq.hxx
index 3d697a9..9721b6e 100644
--- a/mod/mod-ci-github-gq.hxx
+++ b/mod/mod-ci-github-gq.hxx
@@ -38,6 +38,8 @@ namespace brep
// state and the node ID. Return false and issue diagnostics if the request
// failed.
//
+ // If the details_url is absent GitHub will use the app's homepage.
+ //
// The gq_built_result is required if the build_state is built because
// GitHub does not allow a check run status of `completed` without at least
// a conclusion.
@@ -55,7 +57,7 @@ namespace brep
const string& installation_access_token,
const string& repository_id,
const string& head_sha,
- const string& details_url,
+ const optional<string>& details_url,
build_state,
optional<gq_built_result> = nullopt);
@@ -65,6 +67,8 @@ namespace brep
// with the new state. Return false and issue diagnostics if the request
// failed.
//
+ // If the details_url is absent GitHub will use the app's homepage.
+ //
// The gq_built_result is required if the build_state is built because
// GitHub does not allow a check run status of `completed` without at least
// a conclusion.
@@ -75,7 +79,7 @@ namespace brep
const string& installation_access_token,
const string& repository_id,
const string& node_id,
- const string& details_url,
+ const optional<string>& details_url,
build_state,
optional<gq_built_result> = nullopt);