From 9d0e65dcf51ac2f7baaf93c277fb2428cb0eb6f2 Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Tue, 28 May 2024 09:37:16 +0200 Subject: Add fields for PRs to service_data --- mod/mod-ci-github-service-data.cxx | 29 ++++++++++++++++++++++++++++- mod/mod-ci-github-service-data.hxx | 9 ++++++++- mod/mod-ci-github.cxx | 4 +++- 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/mod-ci-github-service-data.cxx b/mod/mod-ci-github-service-data.cxx index 10de076..8c6970c 100644 --- a/mod/mod-ci-github-service-data.cxx +++ b/mod/mod-ci-github-service-data.cxx @@ -38,7 +38,17 @@ namespace brep installation_id = p.next_expect_member_number ("installation_id"); + repository_node_id = p.next_expect_member_string ("repository_node_id"); + + { + string* s (p.next_expect_member_string_null ("repository_clone_url")); + if (s) + repository_clone_url = *s; + } + + pr_number = p.next_expect_member_number_null ("pr_number"); + head_sha = p.next_expect_member_string ("head_sha"); p.next_expect_member_array ("check_runs"); @@ -71,11 +81,15 @@ namespace brep timestamp iat_ea, uint64_t iid, string rid, - string hs) + string hs, + optional rcu, + optional prn) : warning_success (ws), installation_access (move (iat_tok), iat_ea), installation_id (iid), repository_node_id (move (rid)), + repository_clone_url (move (rcu)), + pr_number (prn), head_sha (move (hs)) { } @@ -101,6 +115,19 @@ namespace brep s.member ("installation_id", installation_id); s.member ("repository_node_id", repository_node_id); + + s.member_name ("repository_clone_url"); + if (repository_clone_url) + s.value (*repository_clone_url); + else + s.value (nullptr); + + s.member_name ("pr_number"); + if (pr_number) + s.value (*pr_number); + else + s.value (nullptr); + s.member ("head_sha", head_sha); s.member_begin_array ("check_runs"); diff --git a/mod/mod-ci-github-service-data.hxx b/mod/mod-ci-github-service-data.hxx index afcf082..252f992 100644 --- a/mod/mod-ci-github-service-data.hxx +++ b/mod/mod-ci-github-service-data.hxx @@ -59,6 +59,11 @@ namespace brep string repository_node_id; // GitHub-internal opaque repository id. + // The following two are only used for pull requests. + // + optional repository_clone_url; + optional pr_number; + // The commit ID the check suite or pull request (and its check runs) are // associated with. In the case of a pull request this will be // `pull_request.head.sha`. @@ -85,7 +90,9 @@ namespace brep timestamp iat_expires_at, uint64_t installation_id, string repository_node_id, - string head_sha); + string head_sha, + optional repository_clone_url = nullopt, + optional pr_number = nullopt); service_data () = default; diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index b09124f..573c1a1 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -555,7 +555,9 @@ namespace brep iat->expires_at, pr.installation.id, move (pr.repository.node_id), - pr.pull_request.head_sha) + pr.pull_request.head_sha, + pr.repository.clone_url, + pr.pull_request.number) .json ()); optional tid ( -- cgit v1.1