MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / getDiff

Function getDiff

src/utils/git.ts:106–128  ·  view source on GitHub ↗
({ files }: { files: string[] })

Source from the content-addressed store, hash-verified

104 file.includes('.gif');
105
106export const getDiff = async ({ files }: { files: string[] }) => {
107 const gitDir = await getGitDir();
108
109 const excludedFiles = files.filter(isFileExcludedFromDiff);
110
111 if (excludedFiles.length) {
112 outro(
113 `Some files are excluded by default from 'git diff'. No commit messages are generated for this files:\n${excludedFiles.join(
114 '\n'
115 )}`
116 );
117 }
118
119 const diffableFiles = files.filter((file) => !isFileExcludedFromDiff(file));
120
121 const { stdout: diff } = await execa(
122 'git',
123 ['diff', '--staged', '--', ...diffableFiles],
124 { cwd: gitDir }
125 );
126
127 return diff;
128};
129
130export const getGitDir = async (): Promise<string> => {
131 const { stdout: gitDir } = await execa('git', [

Callers 2

prepareCommitMessageHookFunction · 0.90
commitFunction · 0.90

Calls 4

execaFunction · 0.85
filterMethod · 0.80
getGitDirFunction · 0.70
isFileExcludedFromDiffFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…