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

Function commitToGitRepoAction

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

Source from the content-addressed store, hash-verified

2386}
2387
2388export const commitToGitRepoAction = async ({
2389 projectId,
2390 workspaceId,
2391 message,
2392}: {
2393 projectId: string;
2394 workspaceId?: string;
2395 message: string;
2396}): Promise<CommitToGitRepoResult> => {
2397 try {
2398 const gitRepository = await getGitRepository({ workspaceId, projectId });
2399 // Flush DB changes to disk before committing
2400 await repoFileWatcherRegistry.flushNow(gitRepository._id);
2401 await GitVCS.setAuthor();
2402 await GitVCS.commit(message);
2403
2404 let providerName = 'custom';
2405 if (gitRepository?.credentialsId) {
2406 const credentials = await services.gitCredentials.getById(gitRepository.credentialsId);
2407 invariant(credentials, 'Git Credentials not found');
2408 providerName = credentials.provider;
2409 }
2410
2411 trackAnalyticsEvent(AnalyticsEvent.vcsAction, {
2412 ...vcsEventProperties('git', 'commit'),
2413 providerName,
2414 repoId: gitRepository._id,
2415 });
2416
2417 const hasUnpushedChanges = await GitVCS.canPush(gitRepository.credentialsId);
2418 // update workspace meta with git sync data, use for show unpushed changes on collection card
2419 await services.gitRepository.update(gitRepository, {
2420 hasUnpushedChanges,
2421 cachedGitLastCommitTime: Date.now(),
2422 });
2423 } catch (e) {
2424 const message = e instanceof Error ? e.message : 'Error while committing changes';
2425 return { errors: [message] };
2426 }
2427
2428 return {
2429 errors: [],
2430 };
2431};
2432
2433export const multipleCommitToGitRepoAction = async ({
2434 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