MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / incremental_dockerfile_delete

Function incremental_dockerfile_delete

tests/test_pipeline.c:3877–3904  ·  view source on GitHub ↗

Deleting the only Dockerfile naming an image leaves no Image node behind; * the image another Dockerfile still names stays. `legacy`: through the * full-load route, else the closure-repair route. Returns the Image count * after the deletion, or -1; *route: the route taken. */

Source from the content-addressed store, hash-verified

3875 * full-load route, else the closure-repair route. Returns the Image count
3876 * after the deletion, or -1; *route: the route taken. */
3877static int incremental_dockerfile_delete(bool legacy, cbm_incremental_route_t *route) {
3878 char tmp[256];
3879 snprintf(tmp, sizeof(tmp), "/tmp/cbm_imagegc_XXXXXX");
3880 if (!cbm_mkdtemp(tmp)) {
3881 return -1;
3882 }
3883 write_temp_file(tmp, "a/Dockerfile",
3884 "FROM alpine:3.20\nCOPY --from=docker.io/bitnami/kubectl:1.30 /k /k\n");
3885 write_temp_file(tmp, "b/Dockerfile", "FROM alpine:3.19\n");
3886 char db_path[512];
3887 snprintf(db_path, sizeof(db_path), "%s/imagegc.db", tmp);
3888 static const char images[] = "SELECT COUNT(*) FROM nodes WHERE label='Image'";
3889 int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, images) : -1;
3890 char path[512];
3891 snprintf(path, sizeof(path), "%s/a/Dockerfile", tmp);
3892 (void)remove(path);
3893#if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API
3894 if (legacy) {
3895 cbm_pipeline_incremental_test_force_legacy_partial_once();
3896 }
3897#else
3898 (void)legacy;
3899#endif
3900 int after = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, images) : -1;
3901 *route = cbm_pipeline_incremental_test_last_route();
3902 th_rmtree(tmp);
3903 return full == 2 ? after : -1;
3904}
3905
3906/* Editing one Dockerfile keeps every image's build edge -- also the one
3907 * between nodes that both pre-existed (Image -> the unchanged Dockerfile),

Callers 1

test_pipeline.cFile · 0.85

Calls 8

cbm_mkdtempFunction · 0.85
write_temp_fileFunction · 0.85
k8s_inc_indexFunction · 0.85
k8s_inc_countFunction · 0.85
removeFunction · 0.85
th_rmtreeFunction · 0.85

Tested by

no test coverage detected