Skip to content

Commit 0ed970e

Browse files
committed
bugfix: block approval when rendered diff output is reformatted
1 parent 921df14 commit 0ed970e

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"status": "closed",
33
"resolution": "implemented",
4-
"dependencies": [],
5-
"blocks": [],
64
"target_branch": "v2.1"
75
}

client/src/main/java/io/github/cowwoc/cat/hooks/ask/WarnApprovalWithoutRenderDiff.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
* from blocking because those workflows do not change the working tree.
3232
* <p>
3333
* When cat:get-diff was invoked but the output appears reformatted (sparse box characters
34-
* with many manual diff signs), the handler issues a warning via additional context
35-
* rather than blocking.
34+
* with many manual diff signs), the handler blocks the approval gate.
3635
*/
3736
public final class WarnApprovalWithoutRenderDiff implements AskHandler
3837
{
@@ -135,7 +134,7 @@ private Result checkSessionForGetDiff(Path sessionFile)
135134
DO NOT extract into code blocks or reformat as standard diff.
136135
137136
The user must see the actual 4-column table output.""";
138-
return Result.withContext(warning);
137+
return Result.block(warning);
139138
}
140139
}
141140
catch (IOException e)

client/src/test/java/io/github/cowwoc/cat/hooks/test/WarnApprovalWithoutRenderDiffTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ public void presentGetDiffWithBoxCharsAllows() throws IOException
246246
}
247247

248248
/**
249-
* Verifies that the sparse box character warning triggers when "get-diff" is present
249+
* Verifies that the sparse box character check blocks approval when "get-diff" is present
250250
* but box characters are insufficient and manual diff signs are present.
251251
*
252252
* @throws IOException if test setup fails
253253
*/
254254
@Test
255-
public void getDiffPresentButSparseBoxCharsTriggersReformatWarning() throws IOException
255+
public void getDiffPresentButSparseBoxCharsBlocksApproval() throws IOException
256256
{
257257
Path tempDir = Files.createTempDirectory("test-warn-approval-");
258258
try (TestClaudeHook scope = new TestClaudeHook(tempDir, tempDir, tempDir))
@@ -288,7 +288,7 @@ public void getDiffPresentButSparseBoxCharsTriggersReformatWarning() throws IOEx
288288

289289
AskHandler.Result result = handler.check(toolInput, sessionId);
290290

291-
requireThat(result.additionalContext(), "additionalContext").contains("RENDER-DIFF OUTPUT MAY BE REFORMATTED");
291+
requireThat(result.blocked(), "blocked").isTrue();
292292
}
293293
finally
294294
{

0 commit comments

Comments
 (0)