MCPcopy
hub / github.com/Kong/insomnia / init

Method init

packages/insomnia/src/sync/git/git-vcs.ts:150–189  ·  view source on GitHub ↗
({ directory, fs, gitDirectory, credentialsId, uri = '', repoId, legacyDiff = false, ref }: InitOptions)

Source from the content-addressed store, hash-verified

148 _baseOpts: BaseOpts = gitCallbacks();
149
150 async init({ directory, fs, gitDirectory, credentialsId, uri = '', repoId, legacyDiff = false, ref }: InitOptions) {
151 this._baseOpts = {
152 ...this._baseOpts,
153 dir: directory,
154 ...gitCallbacks(credentialsId),
155 gitdir: gitDirectory,
156 fs,
157 http: httpClient,
158 uri,
159 repoId,
160 legacyDiff,
161 ref,
162 };
163
164 if (await this.repoExists()) {
165 console.log(`[git] Opened repo for ${gitDirectory}`);
166 } else {
167 console.log(`[git] Initialized repo in ${gitDirectory}`);
168 let defaultBranch = 'main';
169
170 try {
171 const url = await this.getRemoteOriginURI();
172 if (!url) {
173 throw new Error('No remote origin URL');
174 }
175 const [mainRef] = await git.listServerRefs({
176 ...this._baseOpts,
177 url,
178 prefix: 'HEAD',
179 symrefs: true,
180 });
181
182 defaultBranch = mainRef?.target?.replace('refs/heads/', '') || 'main';
183 } catch {
184 // Ignore error
185 }
186
187 await git.init({ ...this._baseOpts, defaultBranch });
188 }
189 }
190
191 async getRemoteOriginURI() {
192 try {

Callers

nothing calls this directly

Calls 5

repoExistsMethod · 0.95
getRemoteOriginURIMethod · 0.95
gitCallbacksFunction · 0.90
initMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected