diff options
author | Francois Kritzinger <francois@codesynthesis.com> | 2024-12-13 16:07:14 +0200 |
---|---|---|
committer | Francois Kritzinger <francois@codesynthesis.com> | 2024-12-17 14:51:11 +0200 |
commit | 17d5a70735ae954ef6eefdc9190c6164440de312 (patch) | |
tree | b1edb7e4cc5fba58bab53ed931d52d964cd769b5 | |
parent | bcecc41a017f4f4ed46bbe0ab2decdffe53a2130 (diff) |
ci-github: Handle branch deletions in handle_push_event()
-rw-r--r-- | mod/mod-ci-github-gh.cxx | 7 | ||||
-rw-r--r-- | mod/mod-ci-github-gh.hxx | 4 | ||||
-rw-r--r-- | mod/mod-ci-github.cxx | 24 |
3 files changed, 22 insertions, 13 deletions
diff --git a/mod/mod-ci-github-gh.cxx b/mod/mod-ci-github-gh.cxx index dc85ba2..2e886ac 100644 --- a/mod/mod-ci-github-gh.cxx +++ b/mod/mod-ci-github-gh.cxx @@ -663,8 +663,8 @@ namespace brep { p.next_expect (event::begin_object); - bool rf (false), bf (false), af (false), fd (false), rp (false), - in (false); + bool rf (false), bf (false), af (false), fd (false), dl (false), + rp (false), in (false); // Skip unknown/uninteresting members. // @@ -679,6 +679,7 @@ namespace brep else if (c (bf, "before")) before = p.next_expect_string (); else if (c (af, "after")) after = p.next_expect_string (); else if (c (fd, "forced")) forced = p.next_expect_boolean<bool> (); + else if (c (dl, "deleted")) deleted = p.next_expect_boolean<bool> (); else if (c (rp, "repository")) repository = gh_repository (p); else if (c (in, "installation")) installation = gh_installation (p); else p.next_expect_value_skip (); @@ -688,6 +689,7 @@ namespace brep if (!bf) missing_member (p, "gh_push_event", "before"); if (!af) missing_member (p, "gh_push_event", "after"); if (!fd) missing_member (p, "gh_push_event", "forced"); + if (!dl) missing_member (p, "gh_push_event", "deleted"); if (!rp) missing_member (p, "gh_push_event", "repository"); if (!in) missing_member (p, "gh_push_event", "installation"); } @@ -699,6 +701,7 @@ namespace brep << ", before: " << p.before << ", after: " << p.after << ", forced: " << p.forced + << ", deleted: " << p.deleted << ", repository { " << p.repository << " }" << ", installation { " << p.installation << " }"; diff --git a/mod/mod-ci-github-gh.hxx b/mod/mod-ci-github-gh.hxx index e5654ff..91f5bfe 100644 --- a/mod/mod-ci-github-gh.hxx +++ b/mod/mod-ci-github-gh.hxx @@ -241,6 +241,10 @@ namespace brep // bool forced; + // True if this was a branch deletion. + // + bool deleted; + gh_repository repository; gh_installation installation; diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 28af0fa..ac98785 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -529,8 +529,6 @@ namespace brep // Note that the push request event has no action. // - // @@ TMP I said no before but there is a `deleted` member... - // return handle_push_request (move (ps), warning_success); } else @@ -1499,16 +1497,16 @@ namespace brep l3 ([&]{trace << "push event { " << ps << " }";}); - // The common log entry subject. - // - string sub ((ps.forced ? "forced push " : "push ") + ps.after + " to " + - ps.ref); - - // Cancel the CI tenant associated with the overwritten previous head - // commit if this is a forced push. + // Cancel the CI tenant associated with the overwritten/deleted previous + // head commit if this is a forced push or a branch deletion. // - if (ps.forced) + if (ps.forced || ps.deleted) { + // The common log entry subject. + // + string sub (ps.forced ? "forced push " + ps.after + " to " + ps.ref + : "deletion of " + ps.ref); + // Service id that will uniquely identify the CI tenant. // string sid (ps.repository.node_id + ':' + ps.before); @@ -1536,6 +1534,9 @@ namespace brep } } + if (ps.deleted) + return true; // Do nothing further if this was a branch deletion. + // While we don't need the installation access token in this request, // let's obtain it to flush out any permission issues early. Also, it is // valid for an hour so we will most likely make use of it. @@ -1600,7 +1601,8 @@ namespace brep chrono::seconds (0) /* delay */, duplicate_tenant_mode::ignore)) { - fail << sub << ": unable to create unloaded CI tenant"; + fail << "push " + ps.after + " to " + ps.ref + << ": unable to create unloaded CI tenant"; } return true; |