diff --git a/change/workspace-tools-111fb811-de8e-4bc5-8902-ac403da1326f.json b/change/workspace-tools-111fb811-de8e-4bc5-8902-ac403da1326f.json new file mode 100644 index 0000000..76da014 --- /dev/null +++ b/change/workspace-tools-111fb811-de8e-4bc5-8902-ac403da1326f.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "getRecentCommitMessages: return empty array if no commits", + "packageName": "workspace-tools", + "email": "elcraig@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/workspace-tools/src/git/gitUtilities.ts b/packages/workspace-tools/src/git/gitUtilities.ts index d45ee57..a23ae97 100644 --- a/packages/workspace-tools/src/git/gitUtilities.ts +++ b/packages/workspace-tools/src/git/gitUtilities.ts @@ -93,7 +93,10 @@ export function getRecentCommitMessages(branch: string, cwd: string) { return []; } - return results.stdout.split(/\n/).map((line) => line.trim()); + return results.stdout + .trim() + .split(/\n/) + .map((line) => line.trim()); } catch (e) { throw new GitError(`Cannot gather information about recent commits`, e); }