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

Commit

Permalink
fix: add more error handling per commit
Browse files Browse the repository at this point in the history
if we fail to process a commit title, log it and the error that caused it.
  • Loading branch information
Shesekino committed Aug 2, 2020
1 parent 17551ce commit 1334fa3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 59 deletions.
2 changes: 1 addition & 1 deletion dist/commit.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 31 additions & 26 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9576,33 +9576,38 @@ function processCommits(commitHeaders) {
others: [],
};
for (const commitHeader of commitHeaders) {
const line = commitHeader.trim();
console.log('processing line:', line);
const words = line.split(' ');
if (words.length <= 1) {
console.log('missing commit message, not processing it');
continue;
}
if (words[1] === 'Merge') { // hack
console.log('treating line as a merge commit, not processing it');
continue;
}
if (!words[1].endsWith(':')) {
console.log('unknown prefix', words[1], 'treating it as misc');
processedCommits['others'].push(line);
continue;
}
const hash = words[0];
const prefix = words[1].split(':')[0];
const rest = words.slice(2).join(' ');
const lineDescription = `${rest} (${hash})`;
if (prefix in processedCommits) {
console.log(`adding "${lineDescription}" to ${prefix}`);
processedCommits[prefix].push(lineDescription);
try {
const line = commitHeader.trim();
console.log('processing line:', line);
const words = line.split(' ');
if (words.length <= 1) {
console.log('missing commit message, not processing it');
continue;
}
if (words[1] === 'Merge') { // hack
console.log('treating line as a merge commit, not processing it');
continue;
}
if (!words[1].endsWith(':')) {
console.log('unknown prefix', words[1], 'treating it as misc');
processedCommits['others'].push(line);
continue;
}
const hash = words[0];
const prefix = words[1].split(':')[0];
const rest = words.slice(2).join(' ');
const lineDescription = `${rest} (${hash})`;
if (prefix in processedCommits) {
console.log(`adding "${lineDescription}" to ${prefix}`);
processedCommits[prefix].push(lineDescription);
}
else {
console.log(`adding "${lineDescription}" to others`);
processedCommits['others'].push(lineDescription);
}
}
else {
console.log(`adding "${lineDescription}" to others`);
processedCommits['others'].push(lineDescription);
catch (err) {
console.log(`couldn't handle commit title ${commitHeader}: ${err}`);
}
}
return processedCommits;
Expand Down
2 changes: 1 addition & 1 deletion dist/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
"signature": "2d70434304a480b8f4936755cf835ac95e4230d0db854d5bc3d7c543eabfdaa4"
},
"../src/commit.ts": {
"version": "2077c5eb145eca91ea0b5c1829022aa8527370c1159047aa36a376dfcea91766",
"version": "228daee483f6216b64f467db3296cfe1cb03a34732309d6b2e676efc09fecace",
"signature": "dfa1b07ec47e1bbdb8b80f4eac4320a04330d2cce41cc13c028c87cbe6ab8a3d"
},
"../src/compose.ts": {
Expand Down
66 changes: 35 additions & 31 deletions src/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,41 @@ function processCommits(commitHeaders: string[]): ICommitData {
};

for (const commitHeader of commitHeaders) {
const line = commitHeader.trim();
console.log('processing line:', line);
const words = line.split(' ');

if (words.length <= 1) {
console.log('missing commit message, not processing it');
continue;
}

if (words[1] === 'Merge') { // hack
console.log('treating line as a merge commit, not processing it');
continue;
}

if (!words[1].endsWith(':')) {
console.log('unknown prefix', words[1], 'treating it as misc');
processedCommits['others'].push(line);
continue;
}

const hash = words[0];
const prefix = words[1].split(':')[0];
const rest = words.slice(2).join(' ');

const lineDescription = `${rest} (${hash})`;
if (prefix in processedCommits) {
console.log(`adding "${lineDescription}" to ${prefix}`);
processedCommits[prefix].push(lineDescription);
} else {
console.log(`adding "${lineDescription}" to others`);
processedCommits['others'].push(lineDescription);
try {
const line = commitHeader.trim();
console.log('processing line:', line);
const words = line.split(' ');

if (words.length <= 1) {
console.log('missing commit message, not processing it');
continue;
}

if (words[1] === 'Merge') { // hack
console.log('treating line as a merge commit, not processing it');
continue;
}

if (!words[1].endsWith(':')) {
console.log('unknown prefix', words[1], 'treating it as misc');
processedCommits['others'].push(line);
continue;
}

const hash = words[0];
const prefix = words[1].split(':')[0];
const rest = words.slice(2).join(' ');

const lineDescription = `${rest} (${hash})`;
if (prefix in processedCommits) {
console.log(`adding "${lineDescription}" to ${prefix}`);
processedCommits[prefix].push(lineDescription);
} else {
console.log(`adding "${lineDescription}" to others`);
processedCommits['others'].push(lineDescription);
}
} catch (err) {
console.log(`couldn't handle commit title ${commitHeader}: ${err}`);
}
}

Expand Down

0 comments on commit 1334fa3

Please sign in to comment.