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

Function cbm_artifact_commit

src/pipeline/artifact.c:741–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739/* ── Commit hash extraction ──────────────────────────────────────── */
740
741char *cbm_artifact_commit(const char *repo_path) {
742 if (!repo_path) {
743 return NULL;
744 }
745
746 char meta_path[CBM_SZ_4K];
747 artifact_path(meta_path, sizeof(meta_path), repo_path, CBM_ARTIFACT_META);
748
749 size_t len = 0;
750 char *json = read_file_alloc(meta_path, &len);
751 if (!json) {
752 return NULL;
753 }
754
755 yyjson_doc *doc = yyjson_read(json, len, 0);
756 free(json);
757 if (!doc) {
758 return NULL;
759 }
760
761 yyjson_val *root = yyjson_doc_get_root(doc);
762 yyjson_val *val = yyjson_obj_get(root, "commit");
763 char *result = NULL;
764 if (val) {
765 const char *s = yyjson_get_str(val);
766 if (s && s[0]) {
767 size_t slen = strlen(s);
768 result = malloc(slen + ART_NUL);
769 if (result) {
770 memcpy(result, s, slen + ART_NUL);
771 }
772 }
773 }
774 yyjson_doc_free(doc);
775 return result;
776}

Callers 1

test_artifact.cFile · 0.85

Calls 2

artifact_pathFunction · 0.85
read_file_allocFunction · 0.85

Tested by

no test coverage detected