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

Function shebang_probe

tests/test_discover.c:2142–2162  ·  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

2140 * -- otherwise a negative expectation (CBM_LANG_COUNT) could pass vacuously
2141 * when setup silently failed. */
2142static bool shebang_probe(const char *prefix, const char *rel, const char *content,
2143 CBMLanguage *out_lang) {
2144 *out_lang = CBM_LANG_COUNT;
2145 char *base = th_mktempdir(prefix);
2146 if (!base) {
2147 return false;
2148 }
2149 bool ok = false;
2150 if (th_write_file(TH_PATH(base, rel), content) == 0) {
2151 cbm_discover_opts_t opts = {0};
2152 cbm_file_info_t *files = NULL;
2153 int count = 0;
2154 if (cbm_discover(base, &opts, &files, &count) == 0) {
2155 *out_lang = discover_lang_of(files, count, rel);
2156 ok = true;
2157 }
2158 cbm_discover_free(files, count);
2159 }
2160 th_cleanup(base);
2161 return ok;
2162}
2163
2164TEST(shebang_direct_python_path) {
2165 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