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

Function incremental_docker_build_keep

tests/test_pipeline.c:4245–4277  ·  view source on GitHub ↗

Editing a Dockerfile keeps the build edge an unchanged script declares * for it: image build edges are recomputed whole, so the files that declared * builds before are read again. `legacy`: through the full-load route, else * the closure-repair route. Returns "full=N inc=M", or NULL. */

Source from the content-addressed store, hash-verified

4243 * builds before are read again. `legacy`: through the full-load route, else
4244 * the closure-repair route. Returns "full=N inc=M", or NULL. */
4245static char *incremental_docker_build_keep(bool legacy, cbm_incremental_route_t *route) {
4246 char tmp[256];
4247 snprintf(tmp, sizeof(tmp), "/tmp/cbm_dockerbuild_XXXXXX");
4248 if (!cbm_mkdtemp(tmp)) {
4249 return NULL;
4250 }
4251 write_temp_file(tmp, "svc/Dockerfile", "FROM golang:1.22\n");
4252 write_temp_file(tmp, "build.sh",
4253 "#!/bin/sh\ncd \"$(dirname \"$0\")\"\ndocker build -t ghcr.io/acme/svc:1 svc\n");
4254 char db_path[512];
4255 snprintf(db_path, sizeof(db_path), "%s/dockerbuild.db", tmp);
4256 static const char builds[] =
4257 "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id WHERE e.type='DEPENDS_ON' "
4258 "AND s.label='Image' AND json_extract(e.properties,'$.tool')='docker-build'";
4259 int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, builds) : -1;
4260 write_temp_file(tmp, "svc/Dockerfile", "FROM golang:1.22\n# edited\n");
4261#if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API
4262 if (legacy) {
4263 cbm_pipeline_incremental_test_force_legacy_partial_once();
4264 }
4265#else
4266 (void)legacy;
4267#endif
4268 char *out = NULL;
4269 if (k8s_inc_index(tmp, db_path) == 0) {
4270 char buf[64];
4271 snprintf(buf, sizeof(buf), "full=%d inc=%d", full, k8s_inc_count(db_path, builds));
4272 out = strdup(buf);
4273 }
4274 *route = cbm_pipeline_incremental_test_last_route();
4275 th_rmtree(tmp);
4276 return out;
4277}
4278
4279TEST(incremental_dockerfile_edit_keeps_docker_build_edges) {
4280 cbm_incremental_route_t route = CBM_INCREMENTAL_ROUTE_NONE;

Callers 1

test_pipeline.cFile · 0.85

Calls 7

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

Tested by

no test coverage detected