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

Function commitToGitRepoAction

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

Source from the content-addressed store, hash-verified

2006}
2007
2008export const commitToGitRepoAction = async ({
2009 projectId,
2010 workspaceId,
2011 message,
2012}: {
2013 projectId: string;
2014 workspaceId?: string;
2015 message: string;
2016}): Promise<CommitToGitRepoResult> => {
2017 try {
2018 const gitRepository = await getGitRepository({ workspaceId, projectId });
2019 // Flush DB changes to disk before committing
2020 await repoFileWatcherRegistry.flushNow(gitRepository._id);
2021 await GitVCS.setAuthor();
2022 await GitVCS.commit(message);
2023
2024 let providerName = 'custom';
2025 if (gitRepository?.credentialsId) {
2026 const credentials = await services.gitCredentials.getById(gitRepository.credentialsId);
2027 invariant(credentials, 'Git Credentials not found');
2028 providerName = credentials.provider;
2029 }
2030
2031 trackAnalyticsEvent(AnalyticsEvent.vcsAction, {
2032 ...vcsEventProperties('git', 'commit'),
2033 providerName,
2034 repoId: gitRepository._id,
2035 });
2036
2037 const hasUnpushedChanges = await GitVCS.canPush(gitRepository.credentialsId);
2038 // update workspace meta with git sync data, use for show unpushed changes on collection card
2039 await services.gitRepository.update(gitRepository, {
2040 hasUnpushedChanges,
2041 cachedGitLastCommitTime: Date.now(),
2042 });
2043 } catch (e) {
2044 const message = e instanceof Error ? e.message : 'Error while committing changes';
2045 return { errors: [message] };
2046 }
2047
2048 return {
2049 errors: [],
2050 };
2051};
2052
2053export const multipleCommitToGitRepoAction = async ({
2054 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