code_healer 0.1.7 → 0.1.8
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/CHANGELOG.md +7 -1
- data/lib/code_healer/evolution_job.rb +1 -1
- data/lib/code_healer/healing_job.rb +1 -1
- data/lib/code_healer/healing_workspace_manager.rb +67 -6
- data/lib/code_healer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f73aedfb97cff3da7cb4a3f62b631886ad5cd377796473b705fe86a6311ff74
|
4
|
+
data.tar.gz: 9e7ce1d1b49920f763684844e799724078919f657c559d49e96a2784200323d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6038730a1146276943b9ec4c7e81569a1977873c303c1b36339b589800d55acd1d05beea95808fc34d71cafc0709cfcaaa0fa1940162f9437087baa5a49f0013
|
7
|
+
data.tar.gz: 85a7f04e29e7ae8b4ea0cb7e130432d8b5253f7fe6a0e72baa0cd826bbe6a061ee3787a8bcbe7c9080c70b08aebd8c786701aa6940ecffdff57e20e81881baa1
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [0.1.
|
8
|
+
## [0.1.8] - 2025-01-14
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- **Production safety** - Healing workspace no longer modifies main directory directly
|
12
|
+
- **Git workflow** - Changes are applied to isolated healing branches only
|
13
|
+
- **Pull request automation** - Automatic PR creation when configured
|
14
|
+
- **Method renaming** - `merge_fixes_back` → `create_healing_branch` for clarity
|
9
15
|
|
10
16
|
### Fixed
|
11
17
|
- **Git operations in isolated healing workspace** - Preserved .git directory during cloning for proper Git operations
|
@@ -22,7 +22,7 @@ class EvolutionJob
|
|
22
22
|
|
23
23
|
if test_success
|
24
24
|
# Merge back to main repo
|
25
|
-
healing_branch = CodeHealer::HealingWorkspaceManager.
|
25
|
+
healing_branch = CodeHealer::HealingWorkspaceManager.create_healing_branch(
|
26
26
|
Rails.root.to_s,
|
27
27
|
workspace_path,
|
28
28
|
CodeHealer::ConfigManager.git_settings['pr_target_branch'] || 'main'
|
@@ -33,7 +33,7 @@ module CodeHealer
|
|
33
33
|
|
34
34
|
if test_success
|
35
35
|
# Merge back to main repo
|
36
|
-
healing_branch = CodeHealer::HealingWorkspaceManager.
|
36
|
+
healing_branch = CodeHealer::HealingWorkspaceManager.create_healing_branch(
|
37
37
|
Rails.root.to_s,
|
38
38
|
workspace_path,
|
39
39
|
CodeHealer::ConfigManager.git_settings['pr_target_branch'] || 'main'
|
@@ -120,8 +120,8 @@ module CodeHealer
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
def
|
124
|
-
puts "🔄
|
123
|
+
def create_healing_branch(repo_path, workspace_path, branch_name)
|
124
|
+
puts "🔄 Creating healing branch for code review"
|
125
125
|
|
126
126
|
begin
|
127
127
|
# Create healing branch in main repo
|
@@ -134,22 +134,38 @@ module CodeHealer
|
|
134
134
|
healing_branch = "code-healer-fix-#{Time.now.to_i}"
|
135
135
|
system("git checkout -b #{healing_branch}")
|
136
136
|
|
137
|
-
# Copy fixed files from workspace
|
137
|
+
# Copy fixed files from workspace to the new branch
|
138
|
+
# This is safe as we're on a new branch, not the main branch
|
138
139
|
copy_fixed_files(workspace_path, repo_path)
|
139
140
|
|
140
|
-
# Commit changes
|
141
|
+
# Commit changes to the healing branch
|
141
142
|
system("git add .")
|
142
143
|
commit_message = "Fix applied by CodeHealer: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
143
144
|
system("git commit -m '#{commit_message}'")
|
144
145
|
|
145
|
-
# Push branch
|
146
|
+
# Push healing branch (this doesn't affect the main branch)
|
146
147
|
system("git push origin #{healing_branch}")
|
147
148
|
|
148
149
|
puts "✅ Healing branch created: #{healing_branch}"
|
150
|
+
puts "🔒 Main branch (#{branch_name}) remains unchanged"
|
151
|
+
puts "📝 Changes are now available in branch: #{healing_branch}"
|
152
|
+
|
153
|
+
# Create pull request if auto-create is enabled
|
154
|
+
if should_create_pull_request?
|
155
|
+
pr_url = create_pull_request(healing_branch, branch_name)
|
156
|
+
if pr_url
|
157
|
+
puts "🔗 Pull request created: #{pr_url}"
|
158
|
+
else
|
159
|
+
puts "⚠️ Failed to create pull request, but branch is ready"
|
160
|
+
end
|
161
|
+
else
|
162
|
+
puts "🔍 Review the changes and create a pull request when ready"
|
163
|
+
end
|
164
|
+
|
149
165
|
healing_branch
|
150
166
|
end
|
151
167
|
rescue => e
|
152
|
-
puts "❌ Failed to
|
168
|
+
puts "❌ Failed to create healing branch: #{e.message}"
|
153
169
|
nil
|
154
170
|
end
|
155
171
|
end
|
@@ -197,6 +213,51 @@ module CodeHealer
|
|
197
213
|
|
198
214
|
private
|
199
215
|
|
216
|
+
def should_create_pull_request?
|
217
|
+
config = CodeHealer::ConfigManager.config
|
218
|
+
auto_create = config.dig('pull_request', 'auto_create')
|
219
|
+
auto_create = config.dig(:pull_request, :auto_create) if auto_create.nil?
|
220
|
+
auto_create == true
|
221
|
+
end
|
222
|
+
|
223
|
+
def create_pull_request(healing_branch, target_branch)
|
224
|
+
puts "🔗 Creating pull request for #{healing_branch} → #{target_branch}"
|
225
|
+
|
226
|
+
begin
|
227
|
+
require 'octokit'
|
228
|
+
|
229
|
+
config = CodeHealer::ConfigManager.config
|
230
|
+
github_token = ENV['GITHUB_TOKEN']
|
231
|
+
repo_name = config['github_repo'] || config[:github_repo]
|
232
|
+
|
233
|
+
unless github_token && repo_name
|
234
|
+
puts "❌ Missing GitHub token or repository configuration"
|
235
|
+
return nil
|
236
|
+
end
|
237
|
+
|
238
|
+
# Parse repo name (owner/repo)
|
239
|
+
owner, repo = repo_name.split('/')
|
240
|
+
|
241
|
+
client = Octokit::Client.new(access_token: github_token)
|
242
|
+
|
243
|
+
# Create pull request
|
244
|
+
pr = client.create_pull_request(
|
245
|
+
repo_name,
|
246
|
+
target_branch,
|
247
|
+
healing_branch,
|
248
|
+
"CodeHealer: Automated Fix",
|
249
|
+
"This pull request contains automated fixes generated by CodeHealer.\n\n" \
|
250
|
+
"**Please review the changes before merging.**\n\n" \
|
251
|
+
"Generated at: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
252
|
+
)
|
253
|
+
|
254
|
+
pr.html_url
|
255
|
+
rescue => e
|
256
|
+
puts "❌ Failed to create pull request: #{e.message}"
|
257
|
+
nil
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
200
261
|
def clone_strategy
|
201
262
|
cfg = CodeHealer::ConfigManager.code_heal_directory_config
|
202
263
|
cfg['clone_strategy'] || cfg[:clone_strategy] || "branch"
|
data/lib/code_healer/version.rb
CHANGED