Skip to content

Commit

Permalink
chore: add debug logging to generatePartialSHA
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent 921d58d commit 74440b1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/helpers/src/sha-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export function generatePartialSHA({
const result: number[] = [];
let i = 0;

// Debug logging
console.log('Original body:', bodyBuffer.toString());

while (i < bodyBuffer.length) {
// Skip soft line breaks
if (i < bodyBuffer.length - 2 &&
Expand Down Expand Up @@ -82,12 +85,19 @@ export function generatePartialSHA({
const decoder = new TextDecoder();
const decodedStr = decoder.decode(new Uint8Array(result));

// Debug logging
console.log('Decoded body:', decodedStr);
console.log('Looking for selector:', selectorString);

// Find the selector in decoded content
const selectorIndex = decodedStr.indexOf(selectorString);
if (selectorIndex === -1) {
throw new Error(`SHA precompute selector "${selectorString}" not found in body`);
throw new Error(`SHA precompute selector "${selectorString}" not found in cleaned body`);
}

// Debug logging
console.log('Found selector at index:', selectorIndex);

// Map back to original index
let originalIndex = 0;
let decodedIndex = 0;
Expand All @@ -111,6 +121,10 @@ export function generatePartialSHA({
}
}
shaCutoffIndex = originalIndex;

// Debug logging
console.log('Original cutoff index:', shaCutoffIndex);
console.log('Original content at cutoff:', bodyBuffer.slice(shaCutoffIndex, shaCutoffIndex + 50).toString());
}

if (shaCutoffIndex < 0) {
Expand Down

0 comments on commit 74440b1

Please sign in to comment.