MCPcopy
hub / github.com/di-sukharev/opencommit / prepareRepo

Function prepareRepo

test/e2e/utils.ts:137–165  ·  view source on GitHub ↗
(
  gitDir: string,
  files: Record<string, string>,
  options: {
    stage?: string[] | true;
    commitMessage?: string;
  } = {}
)

Source from the content-addressed store, hash-verified

135};
136
137export const prepareRepo = async (
138 gitDir: string,
139 files: Record<string, string>,
140 options: {
141 stage?: string[] | true;
142 commitMessage?: string;
143 } = {}
144): Promise<void> => {
145 for (const [relativePath, content] of Object.entries(files)) {
146 writeRepoFile(gitDir, relativePath, content);
147 }
148
149 const stageFiles =
150 options.stage === true
151 ? Object.keys(files)
152 : Array.isArray(options.stage)
153 ? options.stage
154 : options.commitMessage
155 ? Object.keys(files)
156 : [];
157
158 if (stageFiles.length > 0) {
159 await runGit(['add', ...stageFiles], gitDir);
160 }
161
162 if (options.commitMessage) {
163 await runGit(['commit', '-m', options.commitMessage], gitDir);
164 }
165};
166
167export const writeRepoFile = (
168 gitDir: string,

Callers 5

gitPush.test.tsFile · 0.90
oneFile.test.tsFile · 0.90
commitlint.test.tsFile · 0.90

Calls 4

writeRepoFileFunction · 0.85
runGitFunction · 0.85
entriesMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…