Author: Andy Green Date: Fri Oct 23 14:45:43 2020 +0100 align-with-libwebsockets-org-version diff --git a/assets/sai.js b/assets/sai.js index a727411..8900d1b 100644 --- a/assets/sai.js +++ b/assets/sai.js @@ -562,7 +562,7 @@ function sai_taskinfo_render(t, now_ut) s = "
" + sai_event_render(t, now_ut, 0) + "
" + - "" + sai_plat_icon(t.t.platform, 2) + + "" + sai_plat_icon(t.t.platform, 2) + san(t.t.platform) + " "; if (authd && t.t.state != 0 && t.t.state != 3 && t.t.state != 4 && t.t.state != 5) s += "\"stopspecific, "refs/heads/", 11); pss->specificity = SAIM_SPECIFIC_H; } else - if (lws_get_urlarg_by_name(wsi, "id", - (char *)buf, + if (lws_get_urlarg_by_name(wsi, "id", (char *)buf, sizeof(buf))) { - lws_strncpy(pss->specific, - (const char *)buf + 3, + lws_strncpy(pss->specific, (const char *)buf + 3, sizeof(pss->specific)); pss->specificity = SAIM_SPECIFIC_ID; } else { @@ -1060,8 +1058,9 @@ clean_spa: "refs/heads/master", sizeof(pss->specific)); } - lwsl_info("%s: spec %d, '%s'\n", __func__, - pss->specificity, pss->specific); + + //lwsl_notice("%s: spec %d, '%s'\n", __func__, + // pss->specificity, pss->specific); break; } diff --git a/src/master/m-notification.c b/src/master/m-notification.c index 2412054..207e097 100644 --- a/src/master/m-notification.c +++ b/src/master/m-notification.c @@ -828,6 +828,8 @@ sai_notification_file_upload_cb(void *data, const char *name, return m; } + lwsl_notice("%s: m = %d\n", __func__, m); + if (m != 1) break; @@ -841,6 +843,34 @@ sai_notification_file_upload_cb(void *data, const char *name, } lwsl_notice("%s: hmac OK\n", __func__); + /* + * We have the notification metadata JSON parsed into pss->sn.e, + * eg, pss->sn->e.hash ... since it's common to, eg, push a tree + * in a branch and then later tag the same commit, we don't want + * to pointlessly repeat CI for the same tree multiple times, + * and need to basically dedupe. + */ + + { + uint64_t rid = 0; + char qu[192]; + + lws_snprintf(qu, sizeof(qu), "select rowid from events " + "where hash='%s'", + pss->sn.e.hash); + + if (sqlite3_exec(pss->vhd->master.pdb, qu, + sai_sql3_get_uint64_cb, + &rid, NULL) == SQLITE_OK && rid) { + /* it already exists */ + lwsl_notice("%s: ignoring notification as " + "tree hash event exists\n", + __func__); + + return 0; + } + } + if (!pss->sn.saifile) return -1; diff --git a/src/master/m-ws-browser.c b/src/master/m-ws-browser.c index dab9256..58f0e3f 100644 --- a/src/master/m-ws-browser.c +++ b/src/master/m-ws-browser.c @@ -779,15 +779,22 @@ again: e = lws_container_of(pss->walk, sai_event_t, list); if (pss->specificity) { - lwsl_info("%s: specificity: e->hash: %s, e->ref: %s, pss->specific: %s\n", - __func__, e->hash, e->ref, pss->specific); - if (strcmp(e->hash, pss->specific) && - strcmp(e->ref, pss->specific)) { - pss->walk = pss->walk->next; - continue; + lwsl_notice("%s: Specificity: e->hash: %s, e->ref: '%s', pss->specific: '%s'\n", + __func__, e->hash, e->ref, pss->specific); + + if (!strcmp(pss->specific, "refs/heads/master") && !strcmp(e->ref, "refs/heads/main")) { + lwsl_notice("master->main\n"); + any = 1; + } else { + + if (strcmp(e->hash, pss->specific) && + strcmp(e->ref, pss->specific)) { + pss->walk = pss->walk->next; + continue; + } + //lwsl_notice("%s: match\n", __func__); + any = 1; } - //lwsl_notice("%s: match\n", __func__); - any = 1; } js = lws_struct_json_serialize_create(