MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / collectGitLabConfig

Function collectGitLabConfig

packages/setupWizard/src/gitlab.ts:86–239  ·  view source on GitHub ↗
(connectionName: string)

Source from the content-addressed store, hash-verified

84}
85
86export async function collectGitLabConfig(connectionName: string): Promise<CollectResult> {
87 const env: EnvVars = {};
88 const config: GitlabConnectionConfig = { type: 'gitlab' };
89
90 const url = await input({
91 message: 'GitLab URL',
92 default: 'https://gitlab.com',
93 theme: INPUT_THEME,
94 validate: (v) => {
95 if (!v?.trim()) {
96 return 'URL is required';
97 }
98 if (!/^https?:\/\//.test(v)) {
99 return 'Must start with http:// or https://';
100 }
101 return true;
102 },
103 });
104 if (url !== 'https://gitlab.com') {
105 config.url = url;
106 }
107
108 note(
109 [
110 'Create a PAT:',
111 ` ${url}/-/user_settings/personal_access_tokens`,
112 ' Required scope: read_api',
113 ].join('\n'),
114 'Create a GitLab Personal Access Token',
115 );
116
117 const gitlabEnvKey = toEnvKey(connectionName, 'TOKEN');
118 const gitlabToken = await password({
119 message: `GitLab Personal Access Token (stored locally in .env as ${gitlabEnvKey}, leave blank for public repos only)`,
120 mask: true,
121 });
122 if (gitlabToken.trim()) {
123 env[gitlabEnvKey] = gitlabToken;
124 config.token = { env: gitlabEnvKey };
125 }
126
127 const apiBase = gitlabApiBase(url);
128 const isSelfHosted = url !== 'https://gitlab.com';
129
130 const targets = await checkbox<string>({
131 message: 'What do you want to index?',
132 choices: [
133 ...(isSelfHosted
134 ? [{ value: 'all', name: 'Everything', description: 'Index every project visible to the token on this self-hosted instance' }]
135 : []),
136 { value: 'groups', name: 'Groups', description: 'Index every project each chosen group owns' },
137 { value: 'projects', name: 'Specific projects', description: 'Hand-pick individual projects to index' },
138 { value: 'users', name: 'Users', description: 'Index every project each chosen user owns' },
139 ],
140 required: true,
141 });
142
143 if (targets.includes('all')) {

Callers 1

mainFunction · 0.85

Calls 5

noteFunction · 0.85
toEnvKeyFunction · 0.85
gitlabApiBaseFunction · 0.85
searchGitLabFunction · 0.85

Tested by

no test coverage detected