({
projectId,
workspaceId,
filepath,
staged,
}: {
projectId: string;
workspaceId?: string;
filepath: string;
staged: boolean;
})
| 3677 | * takes doesn't hold up showing the diff. |
| 3678 | */ |
| 3679 | export const fileFormatIssueLoader = async ({ |
| 3680 | projectId, |
| 3681 | workspaceId, |
| 3682 | filepath, |
| 3683 | staged, |
| 3684 | }: { |
| 3685 | projectId: string; |
| 3686 | workspaceId?: string; |
| 3687 | filepath: string; |
| 3688 | staged: boolean; |
| 3689 | }): Promise<InsomniaFileFormatIssue | null> => { |
| 3690 | try { |
| 3691 | await getGitRepository({ workspaceId, projectId }); |
| 3692 | const fileStatus = await GitVCS.fileStatus(filepath); |
| 3693 | // The raw contents: the diff's `before` is migrated and reordered for display |
| 3694 | const sides = staged |
| 3695 | ? [fileStatus.rawHead, fileStatus.rawStage] |
| 3696 | : [fileStatus.rawStage || fileStatus.rawHead, fileStatus.workdir]; |
| 3697 | const issues = await Promise.all(sides.map(getInsomniaFileFormatIssue)); |
| 3698 | return issues.includes('invalid') ? 'invalid' : issues.includes('non-canonical') ? 'non-canonical' : null; |
| 3699 | } catch (err) { |
| 3700 | console.warn('[git] Failed to check the format of the file', filepath, err); |
| 3701 | return null; |
| 3702 | } |
| 3703 | }; |
| 3704 | |
| 3705 | interface GitRepoFile { |
| 3706 | id: string; |
no test coverage detected