Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in project metadata gathering causing build failures #1131

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion node-src/git/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ describe('getCommittedFileCount', () => {
it('constructs the correct command', async () => {
await getCommittedFileCount(['page', 'screen'], ['js', 'ts']);
expect(execGitCommandCountLines).toHaveBeenCalledWith(
'git ls-files -- "*page*.js" "*page*.ts" "*Page*.js" "*Page*.ts" "*screen*.js" "*screen*.ts" "*Screen*.js" "*Screen*.ts"'
'git ls-files -- "*page*.js" "*page*.ts" "*Page*.js" "*Page*.ts" "*screen*.js" "*screen*.ts" "*Screen*.js" "*Screen*.ts"',
expect.anything()
);
});
it('parses the count successfully', async () => {
Expand Down
6 changes: 4 additions & 2 deletions node-src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export async function getStorybookCreationDate(ctx: {
*/
export async function getNumberOfComitters() {
try {
return execGitCommandCountLines(`git shortlog -sn --all --since="6 months ago"`, {
return await execGitCommandCountLines(`git shortlog -sn --all --since="6 months ago"`, {
timeout: 5000,
});
} catch {
Expand All @@ -462,7 +462,9 @@ export async function getCommittedFileCount(nameMatches: string[], extensions: s
extensions.map((extension) => `"*${match}*.${extension}"`)
);

return execGitCommandCountLines(`git ls-files -- ${globs.join(' ')}`);
return await execGitCommandCountLines(`git ls-files -- ${globs.join(' ')}`, {
timeout: 5000,
});
} catch {
return undefined;
}
Expand Down
18 changes: 11 additions & 7 deletions node-src/tasks/gitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ export const setGitInfo = async (ctx: Context, task: Task) => {
...commitAndBranchInfo,
};

ctx.projectMetadata = {
hasRouter: getHasRouter(ctx.packageJson),
creationDate: await getRepositoryCreationDate(),
storybookCreationDate: await getStorybookCreationDate(ctx),
numberOfCommitters: await getNumberOfComitters(),
numberOfAppFiles: await getCommittedFileCount(['page', 'screen'], ['js', 'jsx', 'ts', 'tsx']),
};
try {
ctx.projectMetadata = {
hasRouter: getHasRouter(ctx.packageJson),
creationDate: await getRepositoryCreationDate(),
storybookCreationDate: await getStorybookCreationDate(ctx),
numberOfCommitters: await getNumberOfComitters(),
numberOfAppFiles: await getCommittedFileCount(['page', 'screen'], ['js', 'jsx', 'ts', 'tsx']),
};
} catch (err) {
ctx.log.debug('Failed to gather project metadata', err);
}

if (isLocalBuild && !ctx.git.gitUserEmail) {
throw new Error(gitUserEmailNotFound());
Expand Down
Loading