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

Function shebang_probe

tests/test_discover.c:1469–1489  ·  view source on GitHub ↗

Discover a single file with the given first-line content and report the * language it was classified as via *out_lang (CBM_LANG_COUNT if unindexed). * Returns true only when temp-dir creation, the file write, and discovery all * succeeded, so callers can assert setup success before asserting the language * -- otherwise a negative expectation (CBM_LANG_COUNT) could pass vacuously * when setup

Source from the content-addressed store, hash-verified

1467 * -- otherwise a negative expectation (CBM_LANG_COUNT) could pass vacuously
1468 * when setup silently failed. */
1469static bool shebang_probe(const char *prefix, const char *rel, const char *content,
1470 CBMLanguage *out_lang) {
1471 *out_lang = CBM_LANG_COUNT;
1472 char *base = th_mktempdir(prefix);
1473 if (!base) {
1474 return false;
1475 }
1476 bool ok = false;
1477 if (th_write_file(TH_PATH(base, rel), content) == 0) {
1478 cbm_discover_opts_t opts = {0};
1479 cbm_file_info_t *files = NULL;
1480 int count = 0;
1481 if (cbm_discover(base, &opts, &files, &count) == 0) {
1482 *out_lang = discover_lang_of(files, count, rel);
1483 ok = true;
1484 }
1485 cbm_discover_free(files, count);
1486 }
1487 th_cleanup(base);
1488 return ok;
1489}
1490
1491TEST(shebang_direct_python_path) {
1492 CBMLanguage lang;

Callers 1

test_discover.cFile · 0.85

Calls 6

th_mktempdirFunction · 0.85
th_write_fileFunction · 0.85
cbm_discoverFunction · 0.85
discover_lang_ofFunction · 0.85
cbm_discover_freeFunction · 0.85
th_cleanupFunction · 0.85

Tested by

no test coverage detected