Skip to content

Commit 484bbc0

Browse files
committed
fix: simplify gpg signature handling
1 parent 87abc97 commit 484bbc0

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/proxy/processors/push-action/parsePush.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,10 @@ const getCommitData = (contents: CommitContent[]) => {
159159

160160
const allLines = x.content.split('\n');
161161
let headerEndIndex = -1;
162-
let inGpgSig = false;
163162

164-
// Find index that separates headers/message since GPG sig. may contain '\n\n'
163+
// First empty line marks end of header
165164
for (let i = 0; i < allLines.length; i++) {
166-
const line = allLines[i];
167-
168-
if (line.includes('gpgsig ') && line.includes('-----BEGIN PGP SIGNATURE-----')) {
169-
inGpgSig = true;
170-
continue;
171-
}
172-
if (inGpgSig) {
173-
if (line.includes('-----END PGP SIGNATURE-----')) {
174-
inGpgSig = false;
175-
}
176-
continue;
177-
}
178-
179-
// The first blank line NOT inside a GPG block is the real separator
180-
if (line === '') {
165+
if (allLines[i] === '') {
181166
headerEndIndex = i;
182167
break;
183168
}

test/testParsePush.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ describe('parsePackFile', () => {
610610
"parent 01dbeef9876543210fedcba9876543210fedcba\n" +
611611
"author Test Author <[email protected]> 1744814600 +0100\n" +
612612
"committer Test Committer <[email protected]> 1744814610 +0200\n" +
613-
"gpgsig -----BEGIN PGP SIGNATURE-----\n\n" +
613+
"gpgsig -----BEGIN PGP SIGNATURE-----\n \n" +
614614
" wsFcBAABCAAQBQJn/8ISCRC1aQ7uu5UhlAAAntAQACeyQd6IykNXiN6m9DfVp8DJ\n" +
615615
" UsY64ws+Td0inrEee+cHXVI9uJn15RJYQkICwlM4TZsVGav7nYaVqO+gfAg2ORAH\n" +
616616
" ghUnwSFFs7ucN/p0a47ItkJmt04+jQIFlZIC+wy1u2H3aKJwqaF+kGP5SA33ahgV\n" +

0 commit comments

Comments
 (0)