MCPcopy Index your code
hub / github.com/coderoad/coderoad-vscode / onValidateSetup

Function onValidateSetup

src/actions/onValidateSetup.ts:7–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { validateGitConfig } from '../services/git'
6
7const onValidateSetup = async (): Promise<void> => {
8 try {
9 // check workspace is selected
10 const isEmptyWorkspace = await checkWorkspaceEmpty()
11 if (!isEmptyWorkspace) {
12 const error: E.ErrorMessage = {
13 type: 'WorkspaceNotEmpty',
14 message: '',
15 actions: [
16 {
17 label: 'Open Workspace',
18 transition: 'REQUEST_WORKSPACE',
19 },
20 {
21 label: 'Check Again',
22 transition: 'RETRY',
23 },
24 ],
25 }
26 send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
27 return
28 }
29 // check Git is installed.
30 // Should wait for workspace before running otherwise requires access to root folder
31 const { version, error: gitError } = await getVersion('git')
32 if (gitError) {
33 // git config issue
34 const error: E.ErrorMessage = {
35 type: 'GitConfigError',
36 message: gitError.message,
37 actions: [
38 {
39 label: 'Check Again',
40 transition: 'TRY_AGAIN',
41 },
42 ],
43 }
44 send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
45 return
46 }
47 if (!version) {
48 const error: E.ErrorMessage = {
49 type: 'GitNotFound',
50 message: '',
51 actions: [
52 {
53 label: 'Check Again',
54 transition: 'RETRY',
55 },
56 ],
57 }
58 send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
59 return
60 }
61
62 const isGitUserNameConfigured = await validateGitConfig('user.name')
63 const isGitUserEmailConfigured = await validateGitConfig('user.email')
64

Callers

nothing calls this directly

Calls 4

checkWorkspaceEmptyFunction · 0.90
sendFunction · 0.90
getVersionFunction · 0.90
validateGitConfigFunction · 0.90

Tested by

no test coverage detected