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

Function cbm_artifact_commit

src/pipeline/artifact.c:1236–1271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234/* ── Commit hash extraction ──────────────────────────────────────── */
1235
1236char *cbm_artifact_commit(const char *repo_path) {
1237 if (!repo_path) {
1238 return NULL;
1239 }
1240
1241 char meta_path[CBM_SZ_4K];
1242 artifact_path(meta_path, sizeof(meta_path), repo_path, CBM_ARTIFACT_META);
1243
1244 size_t len = 0;
1245 char *json = read_file_alloc(meta_path, &len);
1246 if (!json) {
1247 return NULL;
1248 }
1249
1250 yyjson_doc *doc = yyjson_read(json, len, 0);
1251 free(json);
1252 if (!doc) {
1253 return NULL;
1254 }
1255
1256 yyjson_val *root = yyjson_doc_get_root(doc);
1257 yyjson_val *val = yyjson_obj_get(root, "commit");
1258 char *result = NULL;
1259 if (val) {
1260 const char *s = yyjson_get_str(val);
1261 if (s && s[0]) {
1262 size_t slen = strlen(s);
1263 result = malloc(slen + ART_NUL);
1264 if (result) {
1265 memcpy(result, s, slen + ART_NUL);
1266 }
1267 }
1268 }
1269 yyjson_doc_free(doc);
1270 return result;
1271}
1272
1273/* ── Bootstrap reconciliation ─────────────────────────────────────── */
1274

Callers 2

test_artifact.cFile · 0.85

Calls 2

artifact_pathFunction · 0.85
read_file_allocFunction · 0.85

Tested by

no test coverage detected