MCPcopy Create free account
hub / github.com/Kong/insomnia / fileFormatIssueLoader

Function fileFormatIssueLoader

packages/insomnia/src/main/git-service.ts:3679–3703  ·  view source on GitHub ↗
({
  projectId,
  workspaceId,
  filepath,
  staged,
}: {
  projectId: string;
  workspaceId?: string;
  filepath: string;
  staged: boolean;
})

Source from the content-addressed store, hash-verified

3677 * takes doesn't hold up showing the diff.
3678 */
3679export 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
3705interface GitRepoFile {
3706 id: string;

Callers 1

registerGitServiceAPIFunction · 0.85

Calls 4

getGitRepositoryFunction · 0.85
fileStatusMethod · 0.80
mapMethod · 0.80
allMethod · 0.65

Tested by

no test coverage detected