| 3752 | } |
| 3753 | |
| 3754 | static int sh_link_hit(cbm_pipeline_ctx_t *ctx, const sh_hit_t *x, int64_t src, |
| 3755 | CBMHashTable *modules) { |
| 3756 | if (x->spawn) { |
| 3757 | return src > 0 ? sh_link_spawn(ctx, src, x, modules) : 0; |
| 3758 | } |
| 3759 | if (x->http) { |
| 3760 | return sh_link_http(ctx, src, x); |
| 3761 | } |
| 3762 | int64_t tgt = x->tgt > 0 ? x->tgt : sh_external_chart(ctx, x->ext, x->file); |
| 3763 | if (src <= 0 || tgt <= 0 || src == tgt) { |
| 3764 | return 0; |
| 3765 | } |
| 3766 | char esc[CBM_SZ_1K]; |
| 3767 | char ci[CBM_SZ_1K]; |
| 3768 | char props[CBM_SZ_4K]; |
| 3769 | cbm_json_escape(esc, (int)sizeof(esc), x->path ? x->path : ""); |
| 3770 | sh_ci_props(x, ci, sizeof(ci)); |
| 3771 | snprintf(props, sizeof(props), "{\"via\":\"%s\",\"%s\":\"%s\"%s%s,\"line\":%d}", x->via, |
| 3772 | x->chart ? "chart" : "path", esc, x->tgt > 0 ? "" : ",\"external\":true", ci, x->line); |
| 3773 | cbm_gbuf_insert_edge(ctx->gbuf, src, tgt, "DEPLOYS", props); |
| 3774 | return SKIP_ONE; |
| 3775 | } |
| 3776 | |
| 3777 | static int sh_link(cbm_pipeline_ctx_t *ctx, const sh_hits_t *h) { |
| 3778 | CBMHashTable *files = cbm_ht_create(0); |
no test coverage detected