makit 0.0.144 → 0.0.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -41
- data/exe/makit +5 -5
- data/lib/makit/apache.rb +28 -28
- data/lib/makit/auto.rb +48 -48
- data/lib/makit/cli/base.rb +17 -0
- data/lib/makit/cli/build_commands.rb +500 -500
- data/lib/makit/cli/generators/base_generator.rb +74 -74
- data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
- data/lib/makit/cli/generators/generator_factory.rb +49 -49
- data/lib/makit/cli/generators/node_generator.rb +50 -50
- data/lib/makit/cli/generators/ruby_generator.rb +77 -77
- data/lib/makit/cli/generators/rust_generator.rb +50 -50
- data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
- data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
- data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
- data/lib/makit/cli/generators/templates/ruby/gemspec.rb +41 -40
- data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
- data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
- data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
- data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
- data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
- data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
- data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
- data/lib/makit/cli/main.rb +78 -69
- data/lib/makit/cli/pipeline_commands.rb +311 -0
- data/lib/makit/cli/project_commands.rb +868 -868
- data/lib/makit/cli/repository_commands.rb +661 -661
- data/lib/makit/cli/strategy_commands.rb +207 -212
- data/lib/makit/cli/utility_commands.rb +521 -521
- data/lib/makit/commands/factory.rb +359 -359
- data/lib/makit/commands/middleware/base.rb +73 -73
- data/lib/makit/commands/middleware/cache.rb +248 -248
- data/lib/makit/commands/middleware/command_logger.rb +312 -312
- data/lib/makit/commands/middleware/validator.rb +269 -269
- data/lib/makit/commands/request.rb +316 -316
- data/lib/makit/commands/result.rb +323 -323
- data/lib/makit/commands/runner.rb +386 -386
- data/lib/makit/commands/strategies/base.rb +171 -171
- data/lib/makit/commands/strategies/child_process.rb +162 -162
- data/lib/makit/commands/strategies/factory.rb +136 -136
- data/lib/makit/commands/strategies/synchronous.rb +139 -139
- data/lib/makit/commands.rb +50 -50
- data/lib/makit/configuration/dotnet_project.rb +48 -48
- data/lib/makit/configuration/gitlab_helper.rb +61 -58
- data/lib/makit/configuration/project.rb +446 -168
- data/lib/makit/configuration/rakefile_helper.rb +43 -43
- data/lib/makit/configuration/step.rb +34 -34
- data/lib/makit/configuration/timeout.rb +74 -74
- data/lib/makit/configuration.rb +21 -16
- data/lib/makit/content/default_gitignore.rb +7 -7
- data/lib/makit/content/default_gitignore.txt +225 -225
- data/lib/makit/content/default_rakefile.rb +13 -13
- data/lib/makit/content/gem_rakefile.rb +16 -16
- data/lib/makit/context.rb +1 -1
- data/lib/makit/data.rb +49 -49
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +262 -262
- data/lib/makit/docs/files.rb +89 -89
- data/lib/makit/docs/rake.rb +102 -102
- data/lib/makit/dotnet/cli.rb +69 -69
- data/lib/makit/dotnet/project.rb +217 -217
- data/lib/makit/dotnet/solution.rb +38 -38
- data/lib/makit/dotnet/solution_classlib.rb +239 -239
- data/lib/makit/dotnet/solution_console.rb +264 -264
- data/lib/makit/dotnet/solution_maui.rb +354 -354
- data/lib/makit/dotnet/solution_wasm.rb +275 -275
- data/lib/makit/dotnet/solution_wpf.rb +304 -304
- data/lib/makit/dotnet.rb +102 -102
- data/lib/makit/email.rb +90 -90
- data/lib/makit/environment.rb +142 -142
- data/lib/makit/examples/runner.rb +370 -370
- data/lib/makit/exceptions.rb +45 -45
- data/lib/makit/fileinfo.rb +32 -24
- data/lib/makit/files.rb +43 -43
- data/lib/makit/gems.rb +40 -40
- data/lib/makit/git/cli.rb +54 -54
- data/lib/makit/git/repository.rb +266 -90
- data/lib/makit/git.rb +104 -98
- data/lib/makit/gitlab/pipeline.rb +857 -0
- data/lib/makit/gitlab/pipeline_service_impl.rb +1536 -0
- data/lib/makit/gitlab_runner.rb +59 -59
- data/lib/makit/humanize.rb +218 -137
- data/lib/makit/indexer.rb +47 -47
- data/lib/makit/io/filesystem.rb +111 -0
- data/lib/makit/io/filesystem_service_impl.rb +337 -0
- data/lib/makit/logging/configuration.rb +308 -308
- data/lib/makit/logging/format_registry.rb +84 -84
- data/lib/makit/logging/formatters/base.rb +39 -39
- data/lib/makit/logging/formatters/console_formatter.rb +140 -140
- data/lib/makit/logging/formatters/json_formatter.rb +65 -65
- data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
- data/lib/makit/logging/formatters/text_formatter.rb +64 -64
- data/lib/makit/logging/log_request.rb +119 -119
- data/lib/makit/logging/logger.rb +199 -199
- data/lib/makit/logging/sinks/base.rb +91 -91
- data/lib/makit/logging/sinks/console.rb +72 -72
- data/lib/makit/logging/sinks/file_sink.rb +92 -92
- data/lib/makit/logging/sinks/structured.rb +123 -123
- data/lib/makit/logging/sinks/unified_file_sink.rb +296 -296
- data/lib/makit/logging.rb +565 -565
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +17 -17
- data/lib/makit/mp/command_mp.rb +13 -13
- data/lib/makit/mp/command_request.mp.rb +17 -17
- data/lib/makit/mp/project_mp.rb +199 -199
- data/lib/makit/mp/string_mp.rb +205 -199
- data/lib/makit/nuget.rb +74 -74
- data/lib/makit/podman/podman.rb +458 -0
- data/lib/makit/podman/podman_service_impl.rb +1081 -0
- data/lib/makit/port.rb +32 -32
- data/lib/makit/process.rb +377 -377
- data/lib/makit/protoc.rb +112 -107
- data/lib/makit/rake/cli.rb +196 -196
- data/lib/makit/rake/trace_controller.rb +174 -174
- data/lib/makit/rake.rb +81 -81
- data/lib/makit/ruby/cli.rb +185 -185
- data/lib/makit/ruby.rb +25 -25
- data/lib/makit/secrets.rb +51 -51
- data/lib/makit/serializer.rb +130 -130
- data/lib/makit/services/builder.rb +186 -186
- data/lib/makit/services/error_handler.rb +226 -226
- data/lib/makit/services/repository_manager.rb +367 -231
- data/lib/makit/services/validator.rb +112 -112
- data/lib/makit/setup/classlib.rb +101 -101
- data/lib/makit/setup/gem.rb +268 -268
- data/lib/makit/setup/pages.rb +11 -11
- data/lib/makit/setup/razorclasslib.rb +101 -101
- data/lib/makit/setup/runner.rb +54 -54
- data/lib/makit/setup.rb +5 -5
- data/lib/makit/show.rb +110 -110
- data/lib/makit/storage.rb +126 -126
- data/lib/makit/symbols.rb +175 -170
- data/lib/makit/task_info.rb +130 -130
- data/lib/makit/tasks/at_exit.rb +15 -15
- data/lib/makit/tasks/build.rb +22 -22
- data/lib/makit/tasks/clean.rb +13 -13
- data/lib/makit/tasks/configure.rb +10 -10
- data/lib/makit/tasks/format.rb +10 -10
- data/lib/makit/tasks/hook_manager.rb +443 -443
- data/lib/makit/tasks/init.rb +49 -49
- data/lib/makit/tasks/integrate.rb +29 -29
- data/lib/makit/tasks/pull_incoming.rb +13 -13
- data/lib/makit/tasks/setup.rb +16 -16
- data/lib/makit/tasks/sync.rb +17 -17
- data/lib/makit/tasks/tag.rb +16 -16
- data/lib/makit/tasks/task_monkey_patch.rb +81 -81
- data/lib/makit/tasks/test.rb +22 -22
- data/lib/makit/tasks/update.rb +18 -18
- data/lib/makit/tasks.rb +20 -20
- data/lib/makit/test_cache.rb +239 -239
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/configuration/project_service_impl.rb +371 -0
- data/lib/makit/v1/git/git_repository_service_impl.rb +295 -0
- data/lib/makit/v1/makit.v1_pb.rb +35 -35
- data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
- data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -0
- data/lib/makit/version.rb +100 -100
- data/lib/makit/version_util.rb +21 -21
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/yaml.rb +29 -29
- data/lib/makit/zip.rb +17 -17
- data/lib/makit copy.rb +44 -44
- data/lib/makit.rb +111 -43
- metadata +61 -36
|
@@ -1,231 +1,367 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "validator"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
# @param git_repository [String] the git repository URL
|
|
69
|
-
# @return [
|
|
70
|
-
def
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
#
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "validator"
|
|
4
|
+
# Note: RepositoryManagerService intermediate class removed after Phase 4 cleanup
|
|
5
|
+
|
|
6
|
+
module Makit
|
|
7
|
+
module Services
|
|
8
|
+
# Service class responsible for git repository management operations
|
|
9
|
+
# Handles cloning, pulling, logging, and working directory setup
|
|
10
|
+
#
|
|
11
|
+
# This class now acts as a Ruby wrapper around the gRPC service implementation,
|
|
12
|
+
# maintaining backward compatibility while providing the benefits of the new architecture.
|
|
13
|
+
class RepositoryManager
|
|
14
|
+
class << self
|
|
15
|
+
# Initialize a new git repository in the specified directory
|
|
16
|
+
#
|
|
17
|
+
# @param directory [String] the directory path to initialize
|
|
18
|
+
# @return [Makit::V1::Command] the git init command result
|
|
19
|
+
# @raise [Makit::DirectoryError] if the directory cannot be created
|
|
20
|
+
# @raise [Makit::GitError] if git initialization fails
|
|
21
|
+
def initialize_repository(directory)
|
|
22
|
+
# Create a new repository model directly
|
|
23
|
+
model = create_empty_repository_model
|
|
24
|
+
|
|
25
|
+
# Call the gRPC service
|
|
26
|
+
request = Makit::V1::Services::InitializeRepositoryRequest.new(
|
|
27
|
+
model: convert_to_proto_model(model),
|
|
28
|
+
directory: directory
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.initialize_repository(request, nil)
|
|
32
|
+
|
|
33
|
+
# Convert back to Ruby model and extract the command result
|
|
34
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
35
|
+
|
|
36
|
+
# Return the last command result as a Makit::V1::Command
|
|
37
|
+
return create_command_from_result(ruby_model.command_results.last) if ruby_model.command_results.any?
|
|
38
|
+
|
|
39
|
+
# Fallback: create a mock command if no results
|
|
40
|
+
create_mock_command(0, "Repository initialized", "")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Clone a git repository to a local directory
|
|
44
|
+
#
|
|
45
|
+
# @param git_repository [String] the git repository URL
|
|
46
|
+
# @return [Array<Makit::V1::Command>] array of command results
|
|
47
|
+
def clone_repository(git_repository)
|
|
48
|
+
# Create a new repository model directly
|
|
49
|
+
model = create_empty_repository_model
|
|
50
|
+
|
|
51
|
+
# Call the gRPC service
|
|
52
|
+
request = Makit::V1::Services::CloneRepositoryRequest.new(
|
|
53
|
+
model: convert_to_proto_model(model),
|
|
54
|
+
git_repository: git_repository
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.clone_repository(request, nil)
|
|
58
|
+
|
|
59
|
+
# Convert back to Ruby model and extract command results
|
|
60
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
61
|
+
|
|
62
|
+
# Convert command results to Makit::V1::Command objects
|
|
63
|
+
ruby_model.command_results.map { |result| create_command_from_result(result) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Pull the latest changes from the remote repository
|
|
67
|
+
#
|
|
68
|
+
# @param git_repository [String] the git repository URL
|
|
69
|
+
# @return [Makit::V1::Command] the git pull command result
|
|
70
|
+
def pull_repository(git_repository)
|
|
71
|
+
# Create a new repository model directly
|
|
72
|
+
model = create_empty_repository_model
|
|
73
|
+
|
|
74
|
+
# Call the gRPC service
|
|
75
|
+
request = Makit::V1::Services::PullRepositoryRequest.new(
|
|
76
|
+
model: convert_to_proto_model(model),
|
|
77
|
+
git_repository: git_repository
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.pull_repository(request, nil)
|
|
81
|
+
|
|
82
|
+
# Convert back to Ruby model and extract the command result
|
|
83
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
84
|
+
|
|
85
|
+
# Return the last command result as a Makit::V1::Command
|
|
86
|
+
return create_command_from_result(ruby_model.command_results.last) if ruby_model.command_results.any?
|
|
87
|
+
|
|
88
|
+
# Fallback: create a mock command if no results
|
|
89
|
+
create_mock_command(0, "Repository pulled", "")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Clone repository if it doesn't exist, otherwise pull latest changes
|
|
93
|
+
#
|
|
94
|
+
# @param git_repository [String] the git repository URL
|
|
95
|
+
# @return [Array<Makit::V1::Command>] array of command results
|
|
96
|
+
def clone_or_pull_repository(git_repository)
|
|
97
|
+
# Create a new repository model directly
|
|
98
|
+
model = create_empty_repository_model
|
|
99
|
+
|
|
100
|
+
# Call the gRPC service
|
|
101
|
+
request = Makit::V1::Services::CloneOrPullRepositoryRequest.new(
|
|
102
|
+
model: convert_to_proto_model(model),
|
|
103
|
+
git_repository: git_repository
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.clone_or_pull_repository(request, nil)
|
|
107
|
+
|
|
108
|
+
# Convert back to Ruby model and extract command results
|
|
109
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
110
|
+
|
|
111
|
+
# Convert command results to Makit::V1::Command objects
|
|
112
|
+
ruby_model.command_results.map { |result| create_command_from_result(result) }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Get git log information for a repository
|
|
116
|
+
#
|
|
117
|
+
# @param git_repository [String] the git repository URL
|
|
118
|
+
# @param limit [Integer] maximum number of commits to retrieve
|
|
119
|
+
# @param skip [Integer] number of commits to skip
|
|
120
|
+
# @return [Array<Makit::V1::GitLogEntry>] array of log entries
|
|
121
|
+
def get_repository_log(git_repository, limit, skip)
|
|
122
|
+
# Create a new repository model directly
|
|
123
|
+
model = create_empty_repository_model
|
|
124
|
+
|
|
125
|
+
# Call the gRPC service
|
|
126
|
+
request = Makit::V1::Services::GetRepositoryLogRequest.new(
|
|
127
|
+
model: convert_to_proto_model(model),
|
|
128
|
+
git_repository: git_repository,
|
|
129
|
+
limit: limit,
|
|
130
|
+
skip: skip
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.get_repository_log(request, nil)
|
|
134
|
+
|
|
135
|
+
# Convert back to Ruby model and extract git log entries
|
|
136
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
137
|
+
|
|
138
|
+
# Convert to Makit::V1::GitLogEntry objects
|
|
139
|
+
ruby_model.git_log_entries.map { |entry| create_git_log_entry_from_model(entry) }
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Set up a work directory for a repository
|
|
143
|
+
#
|
|
144
|
+
# @param repository [String] the git repository URL
|
|
145
|
+
# @return [nil] always returns nil
|
|
146
|
+
def setup_work_directory(repository)
|
|
147
|
+
# Create a new repository model directly
|
|
148
|
+
model = create_empty_repository_model
|
|
149
|
+
|
|
150
|
+
# Call the gRPC service
|
|
151
|
+
request = Makit::V1::Services::SetupWorkDirectoryRequest.new(
|
|
152
|
+
model: convert_to_proto_model(model),
|
|
153
|
+
repository: repository
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
Makit::V1::Services::RepositoryManagerServiceImpl.new.setup_work_directory(request, nil)
|
|
157
|
+
|
|
158
|
+
# Always return nil as per original API
|
|
159
|
+
nil
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Get the latest commit hash from a repository
|
|
163
|
+
#
|
|
164
|
+
# @param clone_dir [String] the local clone directory
|
|
165
|
+
# @param commands [Array] array to append command results to
|
|
166
|
+
# @return [String] the latest commit hash
|
|
167
|
+
def get_latest_commit(clone_dir, commands)
|
|
168
|
+
# Create a new repository model directly
|
|
169
|
+
model = create_empty_repository_model
|
|
170
|
+
|
|
171
|
+
# Call the gRPC service
|
|
172
|
+
request = Makit::V1::Services::GetLatestCommitRequest.new(
|
|
173
|
+
model: convert_to_proto_model(model),
|
|
174
|
+
clone_dir: clone_dir
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.get_latest_commit(request, nil)
|
|
178
|
+
|
|
179
|
+
# Convert back to Ruby model
|
|
180
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
181
|
+
|
|
182
|
+
# Append command results to the provided commands array
|
|
183
|
+
ruby_model.command_results.each { |result| commands << create_command_from_result(result) }
|
|
184
|
+
|
|
185
|
+
# Return the latest commit hash
|
|
186
|
+
ruby_model.latest_commit_hash || ""
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Validate that a clone directory exists for the given repository
|
|
190
|
+
#
|
|
191
|
+
# @param url [String] the git repository URL
|
|
192
|
+
# @return [String] the clone directory path
|
|
193
|
+
def validate_clone_directory(url)
|
|
194
|
+
# Create a new repository model directly
|
|
195
|
+
model = create_empty_repository_model
|
|
196
|
+
|
|
197
|
+
# Call the gRPC service
|
|
198
|
+
request = Makit::V1::Services::ValidateCloneDirectoryRequest.new(
|
|
199
|
+
model: convert_to_proto_model(model),
|
|
200
|
+
url: url
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
result_model = Makit::V1::Services::RepositoryManagerServiceImpl.new.validate_clone_directory(request, nil)
|
|
204
|
+
|
|
205
|
+
# Convert back to Ruby model and return clone directory
|
|
206
|
+
ruby_model = convert_from_proto_model(result_model)
|
|
207
|
+
ruby_model.clone_directory || ""
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
private
|
|
211
|
+
|
|
212
|
+
# Create an empty repository model for gRPC service calls
|
|
213
|
+
def create_empty_repository_model
|
|
214
|
+
# Create a simple hash-based model since we removed the intermediate classes
|
|
215
|
+
{
|
|
216
|
+
repository_url: nil,
|
|
217
|
+
clone_directory: nil,
|
|
218
|
+
work_directory: nil,
|
|
219
|
+
is_initialized: false,
|
|
220
|
+
is_cloned: false,
|
|
221
|
+
has_work_directory: false,
|
|
222
|
+
latest_commit_hash: nil,
|
|
223
|
+
last_pull_time: nil,
|
|
224
|
+
last_clone_time: nil,
|
|
225
|
+
git_log_entries: [],
|
|
226
|
+
command_results: [],
|
|
227
|
+
validation_errors: [],
|
|
228
|
+
configuration: {}
|
|
229
|
+
}
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Convert Ruby RepositoryManagerModel to Protobuf RepositoryManagerModel
|
|
233
|
+
def convert_to_proto_model(ruby_model)
|
|
234
|
+
Makit::V1::Services::RepositoryManagerModel.new(
|
|
235
|
+
repository_url: ruby_model[:repository_url],
|
|
236
|
+
clone_directory: ruby_model[:clone_directory],
|
|
237
|
+
work_directory: ruby_model[:work_directory],
|
|
238
|
+
is_initialized: ruby_model[:is_initialized],
|
|
239
|
+
is_cloned: ruby_model[:is_cloned],
|
|
240
|
+
has_work_directory: ruby_model[:has_work_directory],
|
|
241
|
+
latest_commit_hash: ruby_model[:latest_commit_hash],
|
|
242
|
+
last_pull_time: convert_time_to_timestamp(ruby_model[:last_pull_time]),
|
|
243
|
+
last_clone_time: convert_time_to_timestamp(ruby_model[:last_clone_time]),
|
|
244
|
+
git_log_entries: convert_git_log_entries_to_proto(ruby_model[:git_log_entries]),
|
|
245
|
+
command_results: convert_command_results_to_proto(ruby_model[:command_results]),
|
|
246
|
+
validation_errors: ruby_model[:validation_errors],
|
|
247
|
+
configuration: ruby_model[:configuration]
|
|
248
|
+
)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Convert Protobuf RepositoryManagerModel to Ruby RepositoryManagerModel
|
|
252
|
+
def convert_from_proto_model(proto_model)
|
|
253
|
+
{
|
|
254
|
+
repository_url: proto_model.repository_url,
|
|
255
|
+
clone_directory: proto_model.clone_directory,
|
|
256
|
+
work_directory: proto_model.work_directory,
|
|
257
|
+
is_initialized: proto_model.is_initialized,
|
|
258
|
+
is_cloned: proto_model.is_cloned,
|
|
259
|
+
has_work_directory: proto_model.has_work_directory,
|
|
260
|
+
latest_commit_hash: proto_model.latest_commit_hash,
|
|
261
|
+
last_pull_time: convert_timestamp_to_time(proto_model.last_pull_time),
|
|
262
|
+
last_clone_time: convert_timestamp_to_time(proto_model.last_clone_time),
|
|
263
|
+
git_log_entries: convert_git_log_entries_from_proto(proto_model.git_log_entries),
|
|
264
|
+
command_results: convert_command_results_from_proto(proto_model.command_results),
|
|
265
|
+
validation_errors: proto_model.validation_errors.to_a,
|
|
266
|
+
configuration: proto_model.configuration.to_h
|
|
267
|
+
}
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Convert Ruby Time to Protobuf Timestamp
|
|
271
|
+
def convert_time_to_timestamp(time)
|
|
272
|
+
return nil if time.nil?
|
|
273
|
+
|
|
274
|
+
Google::Protobuf::Timestamp.new(
|
|
275
|
+
seconds: time.to_i,
|
|
276
|
+
nanos: time.nsec
|
|
277
|
+
)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Convert Protobuf Timestamp to Ruby Time
|
|
281
|
+
def convert_timestamp_to_time(timestamp)
|
|
282
|
+
return nil if timestamp.nil?
|
|
283
|
+
|
|
284
|
+
Time.at(timestamp.seconds, timestamp.nanos, :nsec)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Convert Ruby GitLogEntry array to Protobuf GitLogEntry array
|
|
288
|
+
def convert_git_log_entries_to_proto(ruby_entries)
|
|
289
|
+
ruby_entries.map do |entry|
|
|
290
|
+
Makit::V1::Services::GitLogEntry.new(
|
|
291
|
+
commit_hash: entry[:commit_hash],
|
|
292
|
+
author: entry[:author],
|
|
293
|
+
date: entry[:date],
|
|
294
|
+
message: entry[:message]
|
|
295
|
+
)
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Convert Protobuf GitLogEntry array to Ruby GitLogEntry array
|
|
300
|
+
def convert_git_log_entries_from_proto(proto_entries)
|
|
301
|
+
proto_entries.map do |entry|
|
|
302
|
+
{
|
|
303
|
+
commit_hash: entry.commit_hash,
|
|
304
|
+
author: entry.author,
|
|
305
|
+
date: entry.date,
|
|
306
|
+
message: entry.message
|
|
307
|
+
}
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# Convert Ruby CommandResult array to Protobuf CommandResult array
|
|
312
|
+
def convert_command_results_to_proto(ruby_results)
|
|
313
|
+
ruby_results.map do |result|
|
|
314
|
+
Makit::V1::Services::CommandResult.new(
|
|
315
|
+
exit_code: result[:exit_code],
|
|
316
|
+
output: result[:output],
|
|
317
|
+
error: result[:error]
|
|
318
|
+
)
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# Convert Protobuf CommandResult array to Ruby CommandResult array
|
|
323
|
+
def convert_command_results_from_proto(proto_results)
|
|
324
|
+
proto_results.map do |result|
|
|
325
|
+
{
|
|
326
|
+
exit_code: result.exit_code,
|
|
327
|
+
output: result.output,
|
|
328
|
+
error: result.error
|
|
329
|
+
}
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# Create a Makit::V1::Command from a CommandResult
|
|
334
|
+
def create_command_from_result(result)
|
|
335
|
+
# Create a mock Makit::V1::Command object
|
|
336
|
+
# This maintains compatibility with the original API
|
|
337
|
+
command = Object.new
|
|
338
|
+
command.define_singleton_method(:exit_code) { result[:exit_code] }
|
|
339
|
+
command.define_singleton_method(:output) { result[:output] }
|
|
340
|
+
command.define_singleton_method(:error) { result[:error] }
|
|
341
|
+
command
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Create a mock Makit::V1::Command for fallback cases
|
|
345
|
+
def create_mock_command(exit_code, output, error)
|
|
346
|
+
command = Object.new
|
|
347
|
+
command.define_singleton_method(:exit_code) { exit_code }
|
|
348
|
+
command.define_singleton_method(:output) { output }
|
|
349
|
+
command.define_singleton_method(:error) { error }
|
|
350
|
+
command
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Create a Makit::V1::GitLogEntry from a GitLogEntry model
|
|
354
|
+
def create_git_log_entry_from_model(entry)
|
|
355
|
+
# Create a mock Makit::V1::GitLogEntry object
|
|
356
|
+
# This maintains compatibility with the original API
|
|
357
|
+
git_log_entry = Object.new
|
|
358
|
+
git_log_entry.define_singleton_method(:commit_hash) { entry[:commit_hash] }
|
|
359
|
+
git_log_entry.define_singleton_method(:author) { entry[:author] }
|
|
360
|
+
git_log_entry.define_singleton_method(:date) { entry[:date] }
|
|
361
|
+
git_log_entry.define_singleton_method(:message) { entry[:message] }
|
|
362
|
+
git_log_entry
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|