Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 1334fa3

Browse files
committed
fix: add more error handling per commit
if we fail to process a commit title, log it and the error that caused it.
1 parent 17551ce commit 1334fa3

File tree

4 files changed

+68
-59
lines changed

4 files changed

+68
-59
lines changed

dist/commit.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9576,33 +9576,38 @@ function processCommits(commitHeaders) {
95769576
others: [],
95779577
};
95789578
for (const commitHeader of commitHeaders) {
9579-
const line = commitHeader.trim();
9580-
console.log('processing line:', line);
9581-
const words = line.split(' ');
9582-
if (words.length <= 1) {
9583-
console.log('missing commit message, not processing it');
9584-
continue;
9585-
}
9586-
if (words[1] === 'Merge') { // hack
9587-
console.log('treating line as a merge commit, not processing it');
9588-
continue;
9589-
}
9590-
if (!words[1].endsWith(':')) {
9591-
console.log('unknown prefix', words[1], 'treating it as misc');
9592-
processedCommits['others'].push(line);
9593-
continue;
9594-
}
9595-
const hash = words[0];
9596-
const prefix = words[1].split(':')[0];
9597-
const rest = words.slice(2).join(' ');
9598-
const lineDescription = `${rest} (${hash})`;
9599-
if (prefix in processedCommits) {
9600-
console.log(`adding "${lineDescription}" to ${prefix}`);
9601-
processedCommits[prefix].push(lineDescription);
9579+
try {
9580+
const line = commitHeader.trim();
9581+
console.log('processing line:', line);
9582+
const words = line.split(' ');
9583+
if (words.length <= 1) {
9584+
console.log('missing commit message, not processing it');
9585+
continue;
9586+
}
9587+
if (words[1] === 'Merge') { // hack
9588+
console.log('treating line as a merge commit, not processing it');
9589+
continue;
9590+
}
9591+
if (!words[1].endsWith(':')) {
9592+
console.log('unknown prefix', words[1], 'treating it as misc');
9593+
processedCommits['others'].push(line);
9594+
continue;
9595+
}
9596+
const hash = words[0];
9597+
const prefix = words[1].split(':')[0];
9598+
const rest = words.slice(2).join(' ');
9599+
const lineDescription = `${rest} (${hash})`;
9600+
if (prefix in processedCommits) {
9601+
console.log(`adding "${lineDescription}" to ${prefix}`);
9602+
processedCommits[prefix].push(lineDescription);
9603+
}
9604+
else {
9605+
console.log(`adding "${lineDescription}" to others`);
9606+
processedCommits['others'].push(lineDescription);
9607+
}
96029608
}
9603-
else {
9604-
console.log(`adding "${lineDescription}" to others`);
9605-
processedCommits['others'].push(lineDescription);
9609+
catch (err) {
9610+
console.log(`couldn't handle commit title ${commitHeader}: ${err}`);
96069611
}
96079612
}
96089613
return processedCommits;

dist/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334
"signature": "2d70434304a480b8f4936755cf835ac95e4230d0db854d5bc3d7c543eabfdaa4"
335335
},
336336
"../src/commit.ts": {
337-
"version": "2077c5eb145eca91ea0b5c1829022aa8527370c1159047aa36a376dfcea91766",
337+
"version": "228daee483f6216b64f467db3296cfe1cb03a34732309d6b2e676efc09fecace",
338338
"signature": "dfa1b07ec47e1bbdb8b80f4eac4320a04330d2cce41cc13c028c87cbe6ab8a3d"
339339
},
340340
"../src/compose.ts": {

src/commit.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,41 @@ function processCommits(commitHeaders: string[]): ICommitData {
3636
};
3737

3838
for (const commitHeader of commitHeaders) {
39-
const line = commitHeader.trim();
40-
console.log('processing line:', line);
41-
const words = line.split(' ');
42-
43-
if (words.length <= 1) {
44-
console.log('missing commit message, not processing it');
45-
continue;
46-
}
47-
48-
if (words[1] === 'Merge') { // hack
49-
console.log('treating line as a merge commit, not processing it');
50-
continue;
51-
}
52-
53-
if (!words[1].endsWith(':')) {
54-
console.log('unknown prefix', words[1], 'treating it as misc');
55-
processedCommits['others'].push(line);
56-
continue;
57-
}
58-
59-
const hash = words[0];
60-
const prefix = words[1].split(':')[0];
61-
const rest = words.slice(2).join(' ');
62-
63-
const lineDescription = `${rest} (${hash})`;
64-
if (prefix in processedCommits) {
65-
console.log(`adding "${lineDescription}" to ${prefix}`);
66-
processedCommits[prefix].push(lineDescription);
67-
} else {
68-
console.log(`adding "${lineDescription}" to others`);
69-
processedCommits['others'].push(lineDescription);
39+
try {
40+
const line = commitHeader.trim();
41+
console.log('processing line:', line);
42+
const words = line.split(' ');
43+
44+
if (words.length <= 1) {
45+
console.log('missing commit message, not processing it');
46+
continue;
47+
}
48+
49+
if (words[1] === 'Merge') { // hack
50+
console.log('treating line as a merge commit, not processing it');
51+
continue;
52+
}
53+
54+
if (!words[1].endsWith(':')) {
55+
console.log('unknown prefix', words[1], 'treating it as misc');
56+
processedCommits['others'].push(line);
57+
continue;
58+
}
59+
60+
const hash = words[0];
61+
const prefix = words[1].split(':')[0];
62+
const rest = words.slice(2).join(' ');
63+
64+
const lineDescription = `${rest} (${hash})`;
65+
if (prefix in processedCommits) {
66+
console.log(`adding "${lineDescription}" to ${prefix}`);
67+
processedCommits[prefix].push(lineDescription);
68+
} else {
69+
console.log(`adding "${lineDescription}" to others`);
70+
processedCommits['others'].push(lineDescription);
71+
}
72+
} catch (err) {
73+
console.log(`couldn't handle commit title ${commitHeader}: ${err}`);
7074
}
7175
}
7276

0 commit comments

Comments
 (0)