Skip to content

Commit 957bb7c

Browse files
committed
Add GitLab source component
Implement GitLab source functionality to mirror GitHub source implementation: - Implement GitLab server configuration registry - Support global server configurations - Add content filtering capabilities - Include example configuration
1 parent 4f6291f commit 957bb7c

15 files changed

+1397
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
########################################
2+
# GitLab Source Configuration Examples
3+
########################################
4+
5+
# Global GitLab server configurations
6+
# These can be referenced in individual source configurations
7+
settings:
8+
gitlab:
9+
servers:
10+
# Default configuration for gitlab.com
11+
default:
12+
url: https://gitlab.com
13+
token: ${GITLAB_TOKEN}
14+
15+
# Company self-hosted GitLab instance
16+
company:
17+
url: https://gitlab.example.com
18+
token: ${COMPANY_GITLAB_TOKEN}
19+
headers:
20+
X-Custom-Header: "custom-value"
21+
22+
# Another GitLab instance with custom headers
23+
internal:
24+
url: https://gitlab.internal.org
25+
token: ${INTERNAL_GITLAB_TOKEN}
26+
headers:
27+
X-Api-Version: "2"
28+
X-Organization-ID: "org123"
29+
30+
# Document configurations
31+
documents:
32+
# Example 1: Basic GitLab source with direct configuration
33+
- description: Basic GitLab Source Example
34+
outputPath: docs/generated/basic-gitlab-example.md
35+
sources:
36+
- type: gitlab
37+
description: Public GitLab Repository
38+
repository: namespace/project-name
39+
branch: main
40+
sourcePaths:
41+
- src
42+
gitlabToken: ${GITLAB_TOKEN}
43+
showTreeView: true
44+
45+
# Example 2: Using a reference to a pre-configured server
46+
- description: Using GitLab Server Configuration
47+
outputPath: docs/generated/company-gitlab-example.md
48+
sources:
49+
- type: gitlab
50+
description: Internal Company GitLab Repository
51+
server: company # References the 'company' server in settings
52+
repository: internal/project
53+
branch: develop
54+
sourcePaths:
55+
- src/core
56+
- src/modules
57+
filePattern: "*.php"
58+
showTreeView: true
59+
60+
# Example 3: Multiple GitLab sources with different filtering
61+
- description: Multiple GitLab Sources with Filtering
62+
outputPath: docs/generated/filtered-gitlab-example.md
63+
sources:
64+
# Source 1: Controllers only
65+
- type: gitlab
66+
description: Controllers
67+
server: internal
68+
repository: app/backend
69+
branch: feature/api-refactor
70+
sourcePaths:
71+
- src/Controllers
72+
filePattern: "*Controller.php"
73+
74+
# Source 2: Models from the same repository
75+
- type: gitlab
76+
description: Models
77+
server: internal
78+
repository: app/backend
79+
branch: feature/api-refactor
80+
sourcePaths:
81+
- src/Models
82+
filePattern: "*.php"
83+
notPath:
84+
- "*Test.php"
85+
- "*Factory.php"
86+
87+
# Example 4: Advanced filtering with content matching
88+
- description: Advanced GitLab Content Filtering
89+
outputPath: docs/generated/advanced-gitlab-filtering.md
90+
sources:
91+
- type: gitlab
92+
description: Service Classes
93+
repository: app/services
94+
server: internal
95+
sourcePaths:
96+
- src
97+
filePattern: "*.php"
98+
path:
99+
- "src/Services/**"
100+
contains:
101+
- "implements ServiceInterface"
102+
- "@Service"
103+
notContains:
104+
- "@deprecated"
105+
modifiers:
106+
- trim-php-comments
107+
showTreeView: true
108+
109+
# Example 5: Self-hosted GitLab with direct server configuration
110+
- description: Self-hosted GitLab Example
111+
outputPath: docs/generated/self-hosted-gitlab.md
112+
sources:
113+
- type: gitlab
114+
description: Self-hosted Project
115+
repository: group/project
116+
branch: main
117+
# Direct server configuration instead of referencing a pre-configured server
118+
server:
119+
url: https://gitlab.example.com
120+
token: ${COMPANY_GITLAB_TOKEN}
121+
headers:
122+
X-Custom-Header: "custom-value"
123+
sourcePaths:
124+
- docs
125+
filePattern:
126+
- "*.md"
127+
- "*.txt"
128+
showTreeView: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Butschster\ContextGenerator\Application\Bootloader;
6+
7+
use Butschster\ContextGenerator\Lib\GitlabClient\GitlabClient;
8+
use Butschster\ContextGenerator\Lib\GitlabClient\GitlabClientInterface;
9+
use Spiral\Boot\Bootloader\Bootloader;
10+
11+
/**
12+
* Bootloader for GitLab client
13+
*/
14+
final class GitlabClientBootloader extends Bootloader
15+
{
16+
#[\Override]
17+
public function defineDependencies(): array
18+
{
19+
return [
20+
HttpClientBootloader::class,
21+
];
22+
}
23+
24+
#[\Override]
25+
public function defineSingletons(): array
26+
{
27+
return [
28+
GitlabClientInterface::class => GitlabClient::class,
29+
];
30+
}
31+
}

src/Application/Kernel.php

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Butschster\ContextGenerator\Application\Bootloader\ContentRendererBootloader;
1212
use Butschster\ContextGenerator\Application\Bootloader\CoreBootloader;
1313
use Butschster\ContextGenerator\Application\Bootloader\GithubClientBootloader;
14+
use Butschster\ContextGenerator\Application\Bootloader\GitlabClientBootloader;
1415
use Butschster\ContextGenerator\Application\Bootloader\HttpClientBootloader;
1516
use Butschster\ContextGenerator\Application\Bootloader\LoggerBootloader;
1617
use Butschster\ContextGenerator\Application\Bootloader\McpServerBootloader;
@@ -26,6 +27,7 @@
2627
use Butschster\ContextGenerator\Source\File\FileSourceBootloader;
2728
use Butschster\ContextGenerator\Source\GitDiff\GitDiffSourceBootloader;
2829
use Butschster\ContextGenerator\Source\Github\GithubSourceBootloader;
30+
use Butschster\ContextGenerator\Source\Gitlab\GitlabSourceBootloader;
2931
use Butschster\ContextGenerator\Source\MCP\McpSourceBootloader;
3032
use Butschster\ContextGenerator\Source\Registry\SourceRegistryBootloader;
3133
use Butschster\ContextGenerator\Source\Text\TextSourceBootloader;
@@ -52,6 +54,7 @@ protected function defineBootloaders(): array
5254
return [
5355
CoreBootloader::class,
5456
HttpClientBootloader::class,
57+
GitlabClientBootloader::class,
5558
GithubClientBootloader::class,
5659
ComposerClientBootloader::class,
5760
ConfigLoaderBootloader::class,
@@ -67,6 +70,7 @@ protected function defineBootloaders(): array
6770
ComposerSourceBootloader::class,
6871
UrlSourceBootloader::class,
6972
GithubSourceBootloader::class,
73+
GitlabSourceBootloader::class,
7074
GitDiffSourceBootloader::class,
7175
TreeSourceBootloader::class,
7276
McpSourceBootloader::class,

0 commit comments

Comments
 (0)