MCPcopy Create free account
hub / github.com/anomalyco/opencode-bench / finalizeChanges

Function finalizeChanges

src/eval.ts:168–222  ·  view source on GitHub ↗
(baselineCommit: string)

Source from the content-addressed store, hash-verified

166 }
167
168 async function finalizeChanges(baselineCommit: string) {
169 try {
170 await $`git config user.email "opencode-bench@example.com"`.quiet();
171 await $`git config user.name "opencode-bench"`.quiet();
172 } catch (error) {
173 console.error(
174 "Failed to configure git user for agent diff:",
175 error instanceof Error ? error.message : error,
176 );
177 }
178
179 try {
180 await $`git add --all`.quiet();
181 } catch (e) {
182 console.error(
183 "Failed to stage agent changes:",
184 e instanceof Error ? e.message : e,
185 );
186 }
187
188 let hasStagedChanges = false;
189 try {
190 await $`git diff --cached --quiet`.quiet();
191 } catch {
192 hasStagedChanges = true;
193 }
194
195 if (hasStagedChanges) {
196 try {
197 await $`git commit --no-verify -m "opencode-bench-agent-snapshot"`.quiet();
198 } catch (e) {
199 console.error("Failed to commit agent changes:", e);
200 }
201 }
202
203 try {
204 await $`git diff --exit-code ${baselineCommit} HEAD`.quiet();
205 return false;
206 } catch (e) {
207 if (
208 typeof e === "object" &&
209 e !== null &&
210 "status" in e &&
211 (e as { status?: number }).status === 1
212 ) {
213 return true;
214 }
215
216 console.error(
217 "Failed to check final agent diff:",
218 e instanceof Error ? e.message : e,
219 );
220 return false;
221 }
222 }
223
224 async function generateDiff(baselineCommit: string) {
225 let diff;

Callers 1

runOnceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected