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

Function commitToGitRepoAction

packages/insomnia/src/main/git-service.ts:2331–2374  ·  view source on GitHub ↗
({
  projectId,
  workspaceId,
  message,
}: {
  projectId: string;
  workspaceId?: string;
  message: string;
})

Source from the content-addressed store, hash-verified

2329}
2330
2331export const commitToGitRepoAction = async ({
2332 projectId,
2333 workspaceId,
2334 message,
2335}: {
2336 projectId: string;
2337 workspaceId?: string;
2338 message: string;
2339}): Promise<CommitToGitRepoResult> => {
2340 try {
2341 const gitRepository = await getGitRepository({ workspaceId, projectId });
2342 // Flush DB changes to disk before committing
2343 await repoFileWatcherRegistry.flushNow(gitRepository._id);
2344 await GitVCS.setAuthor();
2345 await GitVCS.commit(message);
2346
2347 let providerName = 'custom';
2348 if (gitRepository?.credentialsId) {
2349 const credentials = await services.gitCredentials.getById(gitRepository.credentialsId);
2350 invariant(credentials, 'Git Credentials not found');
2351 providerName = credentials.provider;
2352 }
2353
2354 trackAnalyticsEvent(AnalyticsEvent.vcsAction, {
2355 ...vcsEventProperties('git', 'commit'),
2356 providerName,
2357 repoId: gitRepository._id,
2358 });
2359
2360 const hasUnpushedChanges = await GitVCS.canPush(gitRepository.credentialsId);
2361 // update workspace meta with git sync data, use for show unpushed changes on collection card
2362 await services.gitRepository.update(gitRepository, {
2363 hasUnpushedChanges,
2364 cachedGitLastCommitTime: Date.now(),
2365 });
2366 } catch (e) {
2367 const message = e instanceof Error ? e.message : 'Error while committing changes';
2368 return { errors: [message] };
2369 }
2370
2371 return {
2372 errors: [],
2373 };
2374};
2375
2376export const multipleCommitToGitRepoAction = async ({
2377 projectId,

Callers 2

registerGitServiceAPIFunction · 0.85

Calls 9

invariantFunction · 0.90
trackAnalyticsEventFunction · 0.90
getGitRepositoryFunction · 0.85
setAuthorMethod · 0.80
commitMethod · 0.80
canPushMethod · 0.80
vcsEventPropertiesFunction · 0.70
updateMethod · 0.65
flushNowMethod · 0.45

Tested by

no test coverage detected