| 105 | } |
| 106 | |
| 107 | bool te_git(te_ctx_t *c) { |
| 108 | char git[4096]; |
| 109 | if (!cbm_test_impact_find_git(git, sizeof(git))) { |
| 110 | return te_fallback(c, CBM_TEST_RESULT_FALLBACK_GIT_UNAVAILABLE, "no git on PATH") && false; |
| 111 | } |
| 112 | cbm_git_facts_options_t options = {.root = c->rq->repo_root, |
| 113 | .base_ref = c->rq->base_ref, |
| 114 | .git_executable = git, |
| 115 | .deadline_ms = c->rq->deadline_ms, |
| 116 | .command_limit = 4096, |
| 117 | .stdout_limit = (size_t)512 << 20, |
| 118 | .stderr_limit = 65536, |
| 119 | .total_output_limit = (size_t)2048 << 20}; |
| 120 | cbm_git_facts_error_t error; |
| 121 | c->facts = cbm_git_facts_open(&options, &error); |
| 122 | if (!c->facts || !cbm_git_facts_diff(c->facts, &c->diff, &error)) { |
| 123 | char text[700]; |
| 124 | snprintf(text, sizeof(text), "git: %s", error.diagnostic); |
| 125 | return te_fallback(c, CBM_TEST_RESULT_FALLBACK_GIT_UNAVAILABLE, text) && false; |
| 126 | } |
| 127 | c->id = cbm_git_facts_identity(c->facts); |
| 128 | cbm_changes_status_t status = |
| 129 | cbm_changes_parse(c->diff.name_status.data, c->diff.name_status.length, c->diff.patch.data, |
| 130 | c->diff.patch.length, &c->changes); |
| 131 | if (status == CBM_CHANGES_OOM) { |
| 132 | return te_oom(c); |
| 133 | } |
| 134 | cbm_changes_state_t state = cbm_changes_state(c->changes); |
| 135 | c->diff_complete = status == CBM_CHANGES_OK && state != CBM_CHANGES_UNKNOWN && |
| 136 | cbm_changes_patch_reconciled(c->changes); |
| 137 | c->has_changes = state != CBM_CHANGES_EMPTY; |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | /* ── Query-time configuration: the merge base's (M-4) ────────────── */ |
| 142 |
no test coverage detected